Skip to content

Commit

Permalink
adding secret logic test
Browse files Browse the repository at this point in the history
Signed-off-by: Vivek Reddy <[email protected]>
  • Loading branch information
Vivek Reddy committed Oct 13, 2024
1 parent 5fe1e34 commit 25ea86d
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 8 deletions.
5 changes: 5 additions & 0 deletions test/appframework_gcp/c3/manager_appframework_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,11 @@ var _ = Describe("c3appfw test", func() {
Expect(err).To(Succeed(), "Unable to download license file from Azure")
// Create License Config Map
testcaseEnvInst.CreateLicenseConfigMap(licenseFilePath)
case "gcp":
licenseFilePath, err := testenv.DownloadLicenseFromGCPBucket()
Expect(err).To(Succeed(), "Unable to download license file from S3")
// Create License Config Map
testcaseEnvInst.CreateLicenseConfigMap(licenseFilePath)
default:
fmt.Printf("Unable to download license file")
testcaseEnvInst.Log.Info(fmt.Sprintf("Unable to download license file with Cluster Provider set as %v", testenv.ClusterProvider))
Expand Down
5 changes: 5 additions & 0 deletions test/licensemanager/lm_s1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ var _ = Describe("Licensemanager test", func() {
Expect(err).To(Succeed(), "Unable to download license file from Azure")
// Create License Config Map
testcaseEnvInst.CreateLicenseConfigMap(licenseFilePath)
case "gcp":
licenseFilePath, err := testenv.DownloadLicenseFromGCPBucket()
Expect(err).To(Succeed(), "Unable to download license file from S3")
// Create License Config Map
testcaseEnvInst.CreateLicenseConfigMap(licenseFilePath)
default:
fmt.Printf("Unable to download license file")
testcaseEnvInst.Log.Info(fmt.Sprintf("Unable to download license file with Cluster Provider set as %v", testenv.ClusterProvider))
Expand Down
33 changes: 33 additions & 0 deletions test/licensemanager/manager_lm_c3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ var _ = Describe("Licensemanager test", func() {
Expect(err).To(Succeed(), "Unable to download license file from Azure")
// Create License Config Map
testcaseEnvInst.CreateLicenseConfigMap(licenseFilePath)
case "gcp":
licenseFilePath, err := testenv.DownloadLicenseFromGCPBucket()
Expect(err).To(Succeed(), "Unable to download license file from S3")
// Create License Config Map
testcaseEnvInst.CreateLicenseConfigMap(licenseFilePath)
default:
fmt.Printf("Unable to download license file")
testcaseEnvInst.Log.Info(fmt.Sprintf("Unable to download license file with Cluster Provider set as %v", testenv.ClusterProvider))
Expand Down Expand Up @@ -155,6 +160,9 @@ var _ = Describe("Licensemanager test", func() {
containerName := "/" + AzureDataContainer + "/" + appDirV1
err := testenv.DownloadFilesFromAzure(ctx, testenv.GetAzureEndpoint(ctx), testenv.StorageAccountKey, testenv.StorageAccount, downloadDirV1, containerName, appFileList)
Expect(err).To(Succeed(), "Unable to download V1 app files")
case "gcp":
err := testenv.DownloadFilesFromGCP(testDataS3Bucket, appDirV1, downloadDirV1, appFileList)
Expect(err).To(Succeed(), "Unable to download V1 app files")
}

// Upload V1 apps
Expand All @@ -171,6 +179,12 @@ var _ = Describe("Licensemanager test", func() {
uploadedFiles, err := testenv.UploadFilesToAzure(ctx, testenv.StorageAccount, testenv.StorageAccountKey, downloadDirV1, testDir, appFileList)
Expect(err).To(Succeed(), fmt.Sprintf("Unable to upload %s apps to Azure", appVersion))
uploadedApps = append(uploadedApps, uploadedFiles...)
case "gcp":
testcaseEnvInst.Log.Info(fmt.Sprintf("Upload %s apps to S3", appVersion))
testDir = "lm-" + testenv.RandomDNSName(4)
uploadedFiles, err := testenv.UploadFilesToGCP(testS3Bucket, testDir, appFileList, downloadDirV1)
Expect(err).To(Succeed(), fmt.Sprintf("Unable to upload %s apps to gcp", appVersion))
uploadedApps = append(uploadedApps, uploadedFiles...)
}

// Download License File
Expand All @@ -186,6 +200,11 @@ var _ = Describe("Licensemanager test", func() {
Expect(err).To(Succeed(), "Unable to download license file from Azure")
// Create License Config Map
testcaseEnvInst.CreateLicenseConfigMap(licenseFilePath)
case "gcp":
licenseFilePath, err := testenv.DownloadLicenseFromGCPBucket()
Expect(err).To(Succeed(), "Unable to download license file from GCP")
// Create License Config Map
testcaseEnvInst.CreateLicenseConfigMap(licenseFilePath)
default:
fmt.Printf("Unable to download license file")
testcaseEnvInst.Log.Info(fmt.Sprintf("Unable to download license file with Cluster Provider set as %v", testenv.ClusterProvider))
Expand All @@ -199,6 +218,8 @@ var _ = Describe("Licensemanager test", func() {
volumeSpec = []enterpriseApi.VolumeSpec{testenv.GenerateIndexVolumeSpec(volumeName, testenv.GetS3Endpoint(), testcaseEnvInst.GetIndexSecretName(), "aws", "s3", testenv.GetDefaultS3Region())}
case "azure":
volumeSpec = []enterpriseApi.VolumeSpec{testenv.GenerateIndexVolumeSpecAzure(volumeName, testenv.GetAzureEndpoint(ctx), testcaseEnvInst.GetIndexSecretName(), "azure", "blob")}
case "gcp":
volumeSpec = []enterpriseApi.VolumeSpec{testenv.GenerateIndexVolumeSpec(volumeName, testenv.GetS3Endpoint(), testcaseEnvInst.GetIndexSecretName(), "gcp", "blob", testenv.GetDefaultS3Region())}
}

// AppSourceDefaultSpec: Remote Storage volume name and Scope of App deployment
Expand Down Expand Up @@ -262,6 +283,8 @@ var _ = Describe("Licensemanager test", func() {
case "azure":
azureBlobClient := &testenv.AzureBlobClient{}
azureBlobClient.DeleteFilesOnAzure(ctx, testenv.GetAzureEndpoint(ctx), testenv.StorageAccountKey, testenv.StorageAccount, uploadedApps)
case "gcp":
testenv.DeleteFilesOnGCP(testS3Bucket, uploadedApps)
}
uploadedApps = nil

Expand All @@ -278,6 +301,9 @@ var _ = Describe("Licensemanager test", func() {
containerName := "/" + AzureDataContainer + "/" + appDirV2
err := testenv.DownloadFilesFromAzure(ctx, testenv.GetAzureEndpoint(ctx), testenv.StorageAccountKey, testenv.StorageAccount, downloadDirV2, containerName, appFileList)
Expect(err).To(Succeed(), "Unable to download V2 app files")
case "gcp":
err := testenv.DownloadFilesFromGCP(testDataS3Bucket, appDirV2, downloadDirV2, appFileList)
Expect(err).To(Succeed(), "Unable to download V2 app files")
}

// Upload V2 apps
Expand All @@ -292,6 +318,11 @@ var _ = Describe("Licensemanager test", func() {
uploadedFiles, err := testenv.UploadFilesToAzure(ctx, testenv.StorageAccount, testenv.StorageAccountKey, downloadDirV2, testDir, appFileList)
Expect(err).To(Succeed(), fmt.Sprintf("Unable to upload %s apps to Azure", appVersion))
uploadedApps = append(uploadedApps, uploadedFiles...)
case "gcp":
testcaseEnvInst.Log.Info(fmt.Sprintf("Upload %s apps to S3", appVersion))
uploadedFiles, err := testenv.UploadFilesToGCP(testS3Bucket, testDir, appFileList, downloadDirV2)
Expect(err).To(Succeed(), fmt.Sprintf("Unable to upload %s apps to Gcp", appVersion))
uploadedApps = append(uploadedApps, uploadedFiles...)
}

// Wait for the poll period for the apps to be downloaded
Expand All @@ -313,6 +344,8 @@ var _ = Describe("Licensemanager test", func() {
case "azure":
azureBlobClient := &testenv.AzureBlobClient{}
azureBlobClient.DeleteFilesOnAzure(ctx, testenv.GetAzureEndpoint(ctx), testenv.StorageAccountKey, testenv.StorageAccount, uploadedApps)
case "gcp":
testenv.DeleteFilesOnGCP(testS3Bucket, uploadedApps)
}

// Delete locally downloaded app files
Expand Down
5 changes: 5 additions & 0 deletions test/licensemanager/manager_lm_m4_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ var _ = Describe("Licensemanager test", func() {
Expect(err).To(Succeed(), "Unable to download license file from Azure")
// Create License Config Map
testcaseEnvInst.CreateLicenseConfigMap(licenseFilePath)
case "gcp":
licenseFilePath, err := testenv.DownloadLicenseFromGCPBucket()
Expect(err).To(Succeed(), "Unable to download license file from GCP")
// Create License Config Map
testcaseEnvInst.CreateLicenseConfigMap(licenseFilePath)
default:
fmt.Printf("Unable to download license file")
testcaseEnvInst.Log.Info(fmt.Sprintf("Unable to download license file with Cluster Provider set as %v", testenv.ClusterProvider))
Expand Down
28 changes: 28 additions & 0 deletions test/licensemaster/lm_c3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ var _ = Describe("licensemaster test", func() {
Expect(err).To(Succeed(), "Unable to download license file from Azure")
// Create License Config Map
testcaseEnvInst.CreateLicenseConfigMap(licenseFilePath)
case "gcp":
licenseFilePath, err := testenv.DownloadLicenseFromGCPBucket()
Expect(err).To(Succeed(), "Unable to download license file from GCP")
// Create License Config Map
testcaseEnvInst.CreateLicenseConfigMap(licenseFilePath)
default:
fmt.Printf("Unable to download license file")
testcaseEnvInst.Log.Info(fmt.Sprintf("Unable to download license file with Cluster Provider set as %v", testenv.ClusterProvider))
Expand Down Expand Up @@ -172,6 +177,12 @@ var _ = Describe("licensemaster test", func() {
uploadedFiles, err := testenv.UploadFilesToAzure(ctx, testenv.StorageAccount, testenv.StorageAccountKey, downloadDirV1, testDir, appFileList)
Expect(err).To(Succeed(), fmt.Sprintf("Unable to upload %s apps to Azure", appVersion))
uploadedApps = append(uploadedApps, uploadedFiles...)
case "gcp":
testcaseEnvInst.Log.Info(fmt.Sprintf("Upload %s apps to GCP", appVersion))
testDir = "lm-" + testenv.RandomDNSName(4)
uploadedFiles, err := testenv.UploadFilesToGCP(testS3Bucket, testDir, appFileList, downloadDirV1)
Expect(err).To(Succeed(), fmt.Sprintf("Unable to upload %s apps to S3", appVersion))
uploadedApps = append(uploadedApps, uploadedFiles...)
}

// Download License File
Expand All @@ -187,6 +198,11 @@ var _ = Describe("licensemaster test", func() {
Expect(err).To(Succeed(), "Unable to download license file from Azure")
// Create License Config Map
testcaseEnvInst.CreateLicenseConfigMap(licenseFilePath)
case "gcp":
licenseFilePath, err := testenv.DownloadLicenseFromGCPBucket()
Expect(err).To(Succeed(), "Unable to download license file from GCP")
// Create License Config Map
testcaseEnvInst.CreateLicenseConfigMap(licenseFilePath)
default:
fmt.Printf("Unable to download license file")
testcaseEnvInst.Log.Info(fmt.Sprintf("Unable to download license file with Cluster Provider set as %v", testenv.ClusterProvider))
Expand All @@ -200,6 +216,8 @@ var _ = Describe("licensemaster test", func() {
volumeSpec = []enterpriseApi.VolumeSpec{testenv.GenerateIndexVolumeSpec(volumeName, testenv.GetS3Endpoint(), testcaseEnvInst.GetIndexSecretName(), "aws", "s3", testenv.GetDefaultS3Region())}
case "azure":
volumeSpec = []enterpriseApi.VolumeSpec{testenv.GenerateIndexVolumeSpecAzure(volumeName, testenv.GetAzureEndpoint(ctx), testcaseEnvInst.GetIndexSecretName(), "azure", "blob")}
case "gcp":
volumeSpec = []enterpriseApi.VolumeSpec{testenv.GenerateIndexVolumeSpec(volumeName, testenv.GetS3Endpoint(), testcaseEnvInst.GetIndexSecretName(), "gcp", "blob", testenv.GetDefaultS3Region())}
}

// AppSourceDefaultSpec: Remote Storage volume name and Scope of App deployment
Expand Down Expand Up @@ -280,6 +298,9 @@ var _ = Describe("licensemaster test", func() {
containerName := "/" + AzureDataContainer + "/" + appDirV2
err := testenv.DownloadFilesFromAzure(ctx, testenv.GetAzureEndpoint(ctx), testenv.StorageAccountKey, testenv.StorageAccount, downloadDirV2, containerName, appFileList)
Expect(err).To(Succeed(), "Unable to download V2 app files")
case "gcp":
err := testenv.DownloadFilesFromGCP(testDataS3Bucket, appDirV2, downloadDirV2, appFileList)
Expect(err).To(Succeed(), "Unable to download V2 app files")
}

// Upload V2 apps
Expand All @@ -294,6 +315,11 @@ var _ = Describe("licensemaster test", func() {
uploadedFiles, err := testenv.UploadFilesToAzure(ctx, testenv.StorageAccount, testenv.StorageAccountKey, downloadDirV2, testDir, appFileList)
Expect(err).To(Succeed(), fmt.Sprintf("Unable to upload %s apps to Azure", appVersion))
uploadedApps = append(uploadedApps, uploadedFiles...)
case "gcp":
testcaseEnvInst.Log.Info(fmt.Sprintf("Upload %s apps to S3", appVersion))
uploadedFiles, err := testenv.UploadFilesToGCP(testS3Bucket, testDir, appFileList, downloadDirV2)
Expect(err).To(Succeed(), fmt.Sprintf("Unable to upload %s apps to GCP", appVersion))
uploadedApps = append(uploadedApps, uploadedFiles...)
}

// Wait for the poll period for the apps to be downloaded
Expand All @@ -315,6 +341,8 @@ var _ = Describe("licensemaster test", func() {
case "azure":
azureBlobClient := &testenv.AzureBlobClient{}
azureBlobClient.DeleteFilesOnAzure(ctx, testenv.GetAzureEndpoint(ctx), testenv.StorageAccountKey, testenv.StorageAccount, uploadedApps)
case "gcp":
testenv.DeleteFilesOnGCP(testS3Bucket, uploadedApps)
}

// Delete locally downloaded app files
Expand Down
5 changes: 5 additions & 0 deletions test/licensemaster/lm_m4_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ var _ = Describe("Licensemaster test", func() {
Expect(err).To(Succeed(), "Unable to download license file from Azure")
// Create License Config Map
testcaseEnvInst.CreateLicenseConfigMap(licenseFilePath)
case "gcp":
licenseFilePath, err := testenv.DownloadLicenseFromGCPBucket()
Expect(err).To(Succeed(), "Unable to download license file from GCP")
// Create License Config Map
testcaseEnvInst.CreateLicenseConfigMap(licenseFilePath)
default:
fmt.Printf("Unable to download license file")
testcaseEnvInst.Log.Info(fmt.Sprintf("Unable to download license file with Cluster Provider set as %v", testenv.ClusterProvider))
Expand Down
5 changes: 5 additions & 0 deletions test/licensemaster/lm_s1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ var _ = Describe("Licensemanager test", func() {
Expect(err).To(Succeed(), "Unable to download license file from Azure")
// Create License Config Map
testcaseEnvInst.CreateLicenseConfigMap(licenseFilePath)
case "gcp":
licenseFilePath, err := testenv.DownloadLicenseFromGCPBucket()
Expect(err).To(Succeed(), "Unable to download license file from GCP")
// Create License Config Map
testcaseEnvInst.CreateLicenseConfigMap(licenseFilePath)
default:
fmt.Printf("Unable to download license file")
testcaseEnvInst.Log.Info(fmt.Sprintf("Unable to download license file with Cluster Provider set as %v", testenv.ClusterProvider))
Expand Down
10 changes: 2 additions & 8 deletions test/testenv/appframework_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,15 +377,9 @@ func GenerateAppFrameworkSpec(ctx context.Context, testenvInstance *TestCaseEnv,
volumeSpec = []enterpriseApi.VolumeSpec{GenerateIndexVolumeSpecAzureManagedID(volumeName, GetAzureEndpoint(ctx), "azure", "blob")}
}
case "gcp":
managedID := os.Getenv("AZURE_MANAGED_ID_ENABLED")
if managedID == "false" {
volumeSpec = []enterpriseApi.VolumeSpec{GenerateIndexVolumeSpecAzure(volumeName, GetGCPEndpoint(), testenvInstance.GetIndexSecretName(), "gcp", "blob")}
} else {
volumeSpec = []enterpriseApi.VolumeSpec{GenerateIndexVolumeSpecAzureManagedID(volumeName, GetGCPEndpoint(), "gcp", "blob")}
}

volumeSpec = []enterpriseApi.VolumeSpec{GenerateIndexVolumeSpec(volumeName, GetS3Endpoint(), testenvInstance.GetIndexSecretName(), "gcp", "blob", GetDefaultS3Region())}
default:
testenvInstance.Log.Info("Failed to identify cluster provider name: Should be 'eks' or 'azure' ")
testenvInstance.Log.Info("Failed to identify cluster provider name: Should be 'eks' or 'azure' or 'gcp' ")
}

// AppSourceDefaultSpec: Remote Storage volume name and Scope of App deployment
Expand Down

0 comments on commit 25ea86d

Please sign in to comment.