Skip to content

Commit

Permalink
Fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
yiweng-amz committed Sep 11, 2020
1 parent 05f7a3d commit e07ff68
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 64 deletions.
25 changes: 12 additions & 13 deletions pkg/cloud/cloud.go
Expand Up @@ -66,18 +66,18 @@ type FileSystem struct {

// FileSystemOptions represents the options to create FSx for Lustre filesystem
type FileSystemOptions struct {
CapacityGiB int64
SubnetId string
SecurityGroupIds []string
AutoImportPolicy string
S3ImportPath string
S3ExportPath string
DeploymentType string
KmsKeyId string
PerUnitStorageThroughput int64
DailyAutomaticBackupStartTime string
AutomaticBackupRetentionDays int64
CopyTagsToBackups bool
CapacityGiB int64
SubnetId string
SecurityGroupIds []string
AutoImportPolicy string
S3ImportPath string
S3ExportPath string
DeploymentType string
KmsKeyId string
PerUnitStorageThroughput int64
DailyAutomaticBackupStartTime string
AutomaticBackupRetentionDays int64
CopyTagsToBackups bool
}

// FSx abstracts FSx client to facilitate its mocking.
Expand Down Expand Up @@ -139,7 +139,6 @@ func (c *cloud) CreateFileSystem(ctx context.Context, volumeName string, fileSys
lustreConfiguration.SetPerUnitStorageThroughput(fileSystemOptions.PerUnitStorageThroughput)
}


if fileSystemOptions.AutomaticBackupRetentionDays != 0 {
lustreConfiguration.SetAutomaticBackupRetentionDays(fileSystemOptions.AutomaticBackupRetentionDays)
if fileSystemOptions.DailyAutomaticBackupStartTime != "" {
Expand Down
61 changes: 30 additions & 31 deletions pkg/cloud/cloud_test.go
Expand Up @@ -29,22 +29,22 @@ import (

func TestCreateFileSystem(t *testing.T) {
var (
volumeName = "volumeName"
fileSystemId = "fs-1234"
volumeSizeGiB int64 = 1200
subnetId = "subnet-056da83524edbe641"
securityGroupIds = []string{"sg-086f61ea73388fb6b", "sg-0145e55e976000c9e"}
dnsname = "test.fsx.us-west-2.amazoawd.com"
autoImportPolicy = "NEW_CHANGED"
s3ImportPath = "s3://fsx-s3-data-repository"
s3ExportPath = "s3://fsx-s3-data-repository/export"
deploymentType = fsx.LustreDeploymentTypeScratch2
mountName = "fsx"
kmsKeyId = "arn:aws:kms:us-east-1:215474938041:key/48313a27-7d88-4b51-98a4-fdf5bc80dbbe"
perUnitStorageThroughput int64 = 200
DailyAutomaticBackupStartTime = "00:00:00"
volumeName = "volumeName"
fileSystemId = "fs-1234"
volumeSizeGiB int64 = 1200
subnetId = "subnet-056da83524edbe641"
securityGroupIds = []string{"sg-086f61ea73388fb6b", "sg-0145e55e976000c9e"}
dnsname = "test.fsx.us-west-2.amazoawd.com"
autoImportPolicy = "NEW_CHANGED"
s3ImportPath = "s3://fsx-s3-data-repository"
s3ExportPath = "s3://fsx-s3-data-repository/export"
deploymentType = fsx.LustreDeploymentTypeScratch2
mountName = "fsx"
kmsKeyId = "arn:aws:kms:us-east-1:215474938041:key/48313a27-7d88-4b51-98a4-fdf5bc80dbbe"
perUnitStorageThroughput int64 = 200
DailyAutomaticBackupStartTime = "00:00:00"
AutomaticBackupRetentionDays int64 = 1
CopyTagsToBackups = true
CopyTagsToBackups = true
)
testCases := []struct {
name string
Expand Down Expand Up @@ -393,20 +393,19 @@ func TestCreateFileSystem(t *testing.T) {
}

req := &FileSystemOptions{
CapacityGiB: volumeSizeGiB,
SubnetId: subnetId,
SecurityGroupIds: securityGroupIds,
AutomaticBackupRetentionDays: AutomaticBackupRetentionDays,
CapacityGiB: volumeSizeGiB,
SubnetId: subnetId,
SecurityGroupIds: securityGroupIds,
AutomaticBackupRetentionDays: AutomaticBackupRetentionDays,
DailyAutomaticBackupStartTime: DailyAutomaticBackupStartTime,
CopyTagsToBackups: CopyTagsToBackups,
CopyTagsToBackups: CopyTagsToBackups,
}


lustreFileSystemConfiguration := &fsx.LustreFileSystemConfiguration{
MountName: aws.String(mountName),
AutomaticBackupRetentionDays: aws.Int64(AutomaticBackupRetentionDays),
MountName: aws.String(mountName),
AutomaticBackupRetentionDays: aws.Int64(AutomaticBackupRetentionDays),
DailyAutomaticBackupStartTime: aws.String(DailyAutomaticBackupStartTime),
CopyTagsToBackups: aws.Bool(CopyTagsToBackups),
CopyTagsToBackups: aws.Bool(CopyTagsToBackups),
}

output := &fsx.CreateFileSystemOutput{
Expand Down Expand Up @@ -510,13 +509,13 @@ func TestDeleteFileSystem(t *testing.T) {

func TestDescribeFileSystem(t *testing.T) {
var (
fileSystemId = "fs-1234"
volumeSizeGiB int64 = 1200
dnsname = "test.fsx.us-west-2.amazoawd.com"
autoImportPolicy = "NEW_CHANGED"
s3ImportPath = "s3://fsx-s3-data-repository"
s3ExportPath = "s3://fsx-s3-data-repository/export"
mountName = "fsx"
fileSystemId = "fs-1234"
volumeSizeGiB int64 = 1200
dnsname = "test.fsx.us-west-2.amazoawd.com"
autoImportPolicy = "NEW_CHANGED"
s3ImportPath = "s3://fsx-s3-data-repository"
s3ExportPath = "s3://fsx-s3-data-repository/export"
mountName = "fsx"
)
testCases := []struct {
name string
Expand Down
24 changes: 12 additions & 12 deletions pkg/driver/controller.go
Expand Up @@ -40,17 +40,17 @@ const (
volumeContextDnsName = "dnsname"
volumeContextMountName = "mountname"

volumeParamsSubnetId = "subnetId"
volumeParamsSecurityGroupIds = "securityGroupIds"
volumeParamsAutoImportPolicy = "autoImportPolicy"
volumeParamsS3ImportPath = "s3ImportPath"
volumeParamsS3ExportPath = "s3ExportPath"
volumeParamsDeploymentType = "deploymentType"
volumeParamsKmsKeyId = "kmsKeyId"
volumeParamsPerUnitStorageThroughput = "perUnitStorageThroughput"
volumeParamsAutomaticBackupRetentionDays = "automaticBackupRetentionDays"
volumeParamsDailyAutomaticBackupStartTime = "dailyAutomaticBackupStartTime"
volumeParamsCopyTagsToBackups = "copyTagsToBackups"
volumeParamsSubnetId = "subnetId"
volumeParamsSecurityGroupIds = "securityGroupIds"
volumeParamsAutoImportPolicy = "autoImportPolicy"
volumeParamsS3ImportPath = "s3ImportPath"
volumeParamsS3ExportPath = "s3ExportPath"
volumeParamsDeploymentType = "deploymentType"
volumeParamsKmsKeyId = "kmsKeyId"
volumeParamsPerUnitStorageThroughput = "perUnitStorageThroughput"
volumeParamsAutomaticBackupRetentionDays = "automaticBackupRetentionDays"
volumeParamsDailyAutomaticBackupStartTime = "dailyAutomaticBackupStartTime"
volumeParamsCopyTagsToBackups = "copyTagsToBackups"
)

func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) (*csi.CreateVolumeResponse, error) {
Expand Down Expand Up @@ -82,7 +82,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
if val, ok := volumeParams[volumeParamsAutoImportPolicy]; ok {
fsOptions.AutoImportPolicy = val
}

if val, ok := volumeParams[volumeParamsS3ImportPath]; ok {
fsOptions.S3ImportPath = val
}
Expand Down
14 changes: 7 additions & 7 deletions pkg/driver/controller_test.go
Expand Up @@ -210,14 +210,14 @@ func TestCreateVolume(t *testing.T) {
stdVolCap,
},
Parameters: map[string]string{
volumeParamsSubnetId: subnetId,
volumeParamsSecurityGroupIds: securityGroupIds,
volumeParamsDeploymentType: fsx.LustreDeploymentTypePersistent1,
volumeParamsKmsKeyId: "arn:aws:kms:us-east-1:215474938041:key/48313a27-7d88-4b51-98a4-fdf5bc80dbbe",
volumeParamsPerUnitStorageThroughput: "200",
volumeParamsAutomaticBackupRetentionDays: "1",
volumeParamsSubnetId: subnetId,
volumeParamsSecurityGroupIds: securityGroupIds,
volumeParamsDeploymentType: fsx.LustreDeploymentTypePersistent1,
volumeParamsKmsKeyId: "arn:aws:kms:us-east-1:215474938041:key/48313a27-7d88-4b51-98a4-fdf5bc80dbbe",
volumeParamsPerUnitStorageThroughput: "200",
volumeParamsAutomaticBackupRetentionDays: "1",
volumeParamsDailyAutomaticBackupStartTime: "00:00",
volumeParamsCopyTagsToBackups: "true",
volumeParamsCopyTagsToBackups: "true",
},
}

Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/dynamic_provisioning_test.go
Expand Up @@ -158,7 +158,7 @@ var _ = Describe("[fsx-csi-e2e] Dynamic Provisioning with s3 data repository", f
Parameters: map[string]string{
"subnetId": subnetId,
"securityGroupIds": strings.Join(securityGroupIds, ","),
"autoImportPolicy": "NEW_CHANGED"
"autoImportPolicy": "NEW_CHANGED",
"s3ImportPath": fmt.Sprintf("s3://%s", bucketName),
"s3ExportPath": fmt.Sprintf("s3://%s/export", bucketName),
},
Expand Down

0 comments on commit e07ff68

Please sign in to comment.