Skip to content

Commit

Permalink
Add e2e FSR tests
Browse files Browse the repository at this point in the history
Signed-off-by: Connor Catlett <conncatl@amazon.com>
  • Loading branch information
ConnorJC3 committed Nov 29, 2023
1 parent 517d181 commit caf5951
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 1 deletion.
3 changes: 2 additions & 1 deletion hack/kops-patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ spec:
"ec2:DescribeSnapshots",
"ec2:DescribeTags",
"ec2:DescribeVolumes",
"ec2:DescribeVolumesModifications"
"ec2:DescribeVolumesModifications",
"ec2:EnableFastSnapshotRestores",
],
"Resource": "*"
},
Expand Down
88 changes: 88 additions & 0 deletions tests/e2e/requires_aws_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,4 +256,92 @@ var _ = Describe("[ebs-csi-e2e] [single-az] [requires-aws-api] Dynamic Provision
}
test.Run(cs, snapshotrcs, ns)
})

It("should create a snapshot with FSR enabled", func() {
azList, err := ec2Client.DescribeAvailabilityZones(&ec2.DescribeAvailabilityZonesInput{})
if err != nil {
Fail(fmt.Sprintf("failed to list AZs: %v", err))
}
fsrAvailabilityZone := *azList.AvailabilityZones[0].ZoneName

pod := testsuites.PodDetails{
// sync before taking a snapshot so that any cached data is written to the EBS volume
Cmd: "echo 'hello world' >> /mnt/test-1/data && grep 'hello world' /mnt/test-1/data && sync",
Volumes: []testsuites.VolumeDetails{
{
CreateVolumeParameters: map[string]string{
ebscsidriver.VolumeTypeKey: awscloud.VolumeTypeGP3,
ebscsidriver.FSTypeKey: ebscsidriver.FSTypeExt4,
},
ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeGP3),
VolumeMount: testsuites.VolumeMountDetails{
NameGenerate: "test-volume-",
MountPathGenerate: "/mnt/test-",
},
},
},
}
restoredPod := testsuites.PodDetails{
Cmd: "grep 'hello world' /mnt/test-1/data",
Volumes: []testsuites.VolumeDetails{
{
CreateVolumeParameters: map[string]string{
ebscsidriver.VolumeTypeKey: awscloud.VolumeTypeGP3,
ebscsidriver.FSTypeKey: ebscsidriver.FSTypeExt4,
},
ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeGP3),
VolumeMount: testsuites.VolumeMountDetails{
NameGenerate: "test-volume-",
MountPathGenerate: "/mnt/test-",
},
},
},
}
test := testsuites.DynamicallyProvisionedVolumeSnapshotTest{
CSIDriver: ebsDriver,
Pod: pod,
RestoredPod: restoredPod,
Parameters: map[string]string{
ebscsidriver.FastSnapshotRestoreAvailabilityZones: fsrAvailabilityZone,
},
ValidateFunc: func(snapshot *volumesnapshotv1.VolumeSnapshot) {
describeResult, err := ec2Client.DescribeSnapshots(&ec2.DescribeSnapshotsInput{
Filters: []*ec2.Filter{
{
Name: aws.String("tag:" + awscloud.SnapshotNameTagKey),
Values: []*string{aws.String("snapshot-" + string(snapshot.UID))},
},
},
})
if err != nil {
Fail(fmt.Sprintf("failed to describe snapshot: %v", err))
}

if len(describeResult.Snapshots) != 1 {
Fail(fmt.Sprintf("expected 1 snapshot, got %d", len(describeResult.Snapshots)))
}

result, err := ec2Client.DescribeFastSnapshotRestores(&ec2.DescribeFastSnapshotRestoresInput{
Filters: []*ec2.Filter{
{
Name: aws.String("snapshot-id"),
Values: []*string{describeResult.Snapshots[0].SnapshotId},
},
},
})
if err != nil {
Fail(fmt.Sprintf("failed to list AZs: %v", err))
}

if len(result.FastSnapshotRestores) != 1 {
Fail(fmt.Sprintf("expected 1 FSR, got %d", len(result.FastSnapshotRestores)))
}

if *result.FastSnapshotRestores[0].AvailabilityZone != fsrAvailabilityZone {
Fail(fmt.Sprintf("expected FSR to be enabled for %s, got %s", fsrAvailabilityZone, *result.FastSnapshotRestores[0].AvailabilityZone))
}
},
}
test.Run(cs, snapshotrcs, ns)
})
})

0 comments on commit caf5951

Please sign in to comment.