88 "strings"
99 "testing"
1010
11- "github.com/IBM/go-sdk-core/core"
1211 "github.com/gruntwork-io/terratest/modules/files"
1312 "github.com/gruntwork-io/terratest/modules/logger"
1413 "github.com/gruntwork-io/terratest/modules/random"
@@ -32,10 +31,11 @@ const resourceGroup = "geretain-test-base-ocp-vpc"
3231const yamlLocation = "../common-dev-assets/common-go-assets/common-permanent-resources.yaml"
3332
3433// Ensure there is one test per supported OCP version
35- const ocpVersion1 = "4.18" // used by TestRunFullyConfigurable, TestRunUpgradeFullyConfigurable, TestFSCloudInSchematic and TestRunMultiClusterExample
36- const ocpVersion2 = "4.17" // used by TestCustomSGExample and TestRunCustomsgExample
37- const ocpVersion3 = "4.16" // used by TestRunAdvancedExample and TestCrossKmsSupportExample
38- const ocpVersion4 = "4.15" // used by TestRunAddRulesToSGExample and TestRunBasicExample
34+ const ocpVersion1 = "4.18" // used by TestRunFullyConfigurable, TestRunUpgradeFullyConfigurable, TestFSCloudInSchematic and TestRunMultiClusterExample
35+ const ocpVersion2 = "4.17" // used by TestCustomSGExample and TestRunCustomsgExample
36+ const ocpVersion3 = "4.16" // used by TestRunAdvancedExample and TestCrossKmsSupportExample
37+ const ocpVersion4 = "4.15" // used by TestRunAddRulesToSGExample and TestRunBasicExample
38+ const terraformVersion = "terraform_v1.10" // This should match the version in the ibm_catalog.json
3939
4040var (
4141 sharedInfoSvc * cloudinfo.CloudInfoService
@@ -100,10 +100,12 @@ func setupQuickstartOptions(t *testing.T, prefix string) *testschematic.TestSche
100100 "*.tf" ,
101101 quickStartTerraformDir + "/*.tf" , "scripts/*.sh" , "kubeconfig/README.md" ,
102102 },
103- TemplateFolder : quickStartTerraformDir ,
104- Tags : []string {"test-schematic" },
105- DeleteWorkspaceOnFail : false ,
106- WaitJobCompleteMinutes : 360 ,
103+ TemplateFolder : quickStartTerraformDir ,
104+ Tags : []string {"test-schematic" },
105+ DeleteWorkspaceOnFail : false ,
106+ WaitJobCompleteMinutes : 360 ,
107+ TerraformVersion : terraformVersion ,
108+ CheckApplyResultForUpgrade : true ,
107109 })
108110 options .TerraformVars = []testschematic.TestSchematicTerraformVar {
109111 {Name : "ibmcloud_api_key" , Value : options .RequiredEnvironmentVars ["TF_VAR_ibmcloud_api_key" ], DataType : "string" , Secure : true },
@@ -141,6 +143,7 @@ func TestRunFullyConfigurableInSchematics(t *testing.T) {
141143 TemplateFolder : fullyConfigurableTerraformDir ,
142144 Tags : []string {"test-schematic" },
143145 DeleteWorkspaceOnFail : false ,
146+ TerraformVersion : terraformVersion ,
144147 })
145148
146149 options .TerraformVars = []testschematic.TestSchematicTerraformVar {
@@ -171,12 +174,14 @@ func TestRunUpgradeFullyConfigurable(t *testing.T) {
171174 existingTerraformOptions := setupTerraform (t , prefix , "./existing-resources" )
172175
173176 options := testschematic .TestSchematicOptionsDefault (& testschematic.TestSchematicOptions {
174- Testing : t ,
175- Prefix : "fc-upg" ,
176- TarIncludePatterns : []string {"*.tf" , fullyConfigurableTerraformDir + "/*.*" , fullyConfigurableTerraformDir + "/scripts/*.*" , "scripts/*.sh" , "kubeconfig/README.md" , "modules/kube-audit/*.*" , "modules/kube-audit/kubeconfig/README.md" , "modules/kube-audit/scripts/*.sh" , fullyConfigurableTerraformDir + "/kubeconfig/README.md" , "modules/kube-audit/helm-charts/kube-audit/*.*" , "modules/kube-audit/helm-charts/kube-audit/templates/*.*" },
177- TemplateFolder : fullyConfigurableTerraformDir ,
178- Tags : []string {"test-schematic" },
179- DeleteWorkspaceOnFail : false ,
177+ Testing : t ,
178+ Prefix : "fc-upg" ,
179+ TarIncludePatterns : []string {"*.tf" , fullyConfigurableTerraformDir + "/*.*" , fullyConfigurableTerraformDir + "/scripts/*.*" , "scripts/*.sh" , "kubeconfig/README.md" , "modules/kube-audit/*.*" , "modules/kube-audit/kubeconfig/README.md" , "modules/kube-audit/scripts/*.sh" , fullyConfigurableTerraformDir + "/kubeconfig/README.md" , "modules/kube-audit/helm-charts/kube-audit/*.*" , "modules/kube-audit/helm-charts/kube-audit/templates/*.*" },
180+ TemplateFolder : fullyConfigurableTerraformDir ,
181+ Tags : []string {"test-schematic" },
182+ DeleteWorkspaceOnFail : false ,
183+ TerraformVersion : terraformVersion ,
184+ CheckApplyResultForUpgrade : true ,
180185 })
181186
182187 options .IgnoreUpdates = testhelper.Exemptions {List : []string {"module.kube_audit[0].helm_release.kube_audit" }}
@@ -264,54 +269,40 @@ func TestRoksAddonDefaultConfiguration(t *testing.T) {
264269 "deploy-arch-ibm-slz-ocp" ,
265270 "fully-configurable" ,
266271 map [string ]interface {}{
267- "prefix" : options .Prefix ,
268- "region" : "eu-de" ,
269- "secrets_manager_service_plan" : "trial" ,
272+ "prefix" : options .Prefix ,
273+ "region" : "eu-de" ,
270274 },
271275 )
272276
273- /*
274- Secrets manager is manually disabled in this test because it deploys Event notification
275- and event notifications DA creates kms keys and during undeploy the order of key protect and event notifications
276- is not considered by projects as EN is not a direct dependency of OCP DA. So undeploy fails, because
277- key protect instance can't be deleted because of active keys created by EN. Hence for now, we don't want to deploy
278- EN so SM is being disabled.
279- Issue has been created for projects team. https://github.ibm.com/epx/projects/issues/4750
280- Once that is fixed, we can remove the logic to disable SM
281- */
277+ // use existing secrets manager instance to help prevent hitting trial instance limit in account
282278 options .AddonConfig .Dependencies = []cloudinfo.AddonConfig {
283279 {
284280 OfferingName : "deploy-arch-ibm-secrets-manager" ,
285281 OfferingFlavor : "fully-configurable" ,
286- Enabled : core .BoolPtr (false ), // explicitly disabled
282+ Inputs : map [string ]interface {}{
283+ "existing_secrets_manager_crn" : permanentResources ["privateOnlySecMgrCRN" ],
284+ "service_plan" : "__NULL__" , // no plan value needed when using existing SM
285+ "skip_secrets_manager_iam_auth_policy" : true , // since using an existing Secrets Manager instance, attempting to re-create auth policy can cause conflicts if the policy already exists
286+ "secret_groups" : []string {}, // passing empty array for secret groups as default value is creating general group and it will cause conflicts as we are using an existing SM
287+ },
287288 },
288- }
289-
290- err := options .RunAddonTest ()
291- require .NoError (t , err )
292- }
293-
294- // TestDependencyPermutations runs dependency permutations for OCP and all its dependencies
295- func TestRoksDependencyPermutations (t * testing.T ) {
296-
297- t .Skip ("Skipping dependency permutations until the test is fixed" )
298- t .Parallel ()
299-
300- options := testaddons .TestAddonsOptionsDefault (& testaddons.TestAddonOptions {
301- Testing : t ,
302- Prefix : "ocp-per" ,
303- AddonConfig : cloudinfo.AddonConfig {
304- OfferingName : "deploy-arch-ibm-slz-ocp" ,
289+ // // Disable target / route creation to help prevent hitting quota in account
290+ {
291+ OfferingName : "deploy-arch-ibm-cloud-monitoring" ,
305292 OfferingFlavor : "fully-configurable" ,
306293 Inputs : map [string ]interface {}{
307- "prefix" : "ocp-per" ,
308- "region" : "eu-de" ,
309- "secrets_manager_service_plan" : "trial" ,
310- "existing_cos_instance_crn" : permanentResources ["general_test_storage_cos_instance_crn" ],
294+ "enable_metrics_routing_to_cloud_monitoring" : false ,
311295 },
312296 },
313- })
297+ {
298+ OfferingName : "deploy-arch-ibm-activity-tracker" ,
299+ OfferingFlavor : "fully-configurable" ,
300+ Inputs : map [string ]interface {}{
301+ "enable_activity_tracker_event_routing_to_cloud_logs" : false ,
302+ },
303+ },
304+ }
314305
315- err := options .RunAddonPermutationTest ()
316- assert .NoError (t , err , "Dependency permutation test should not fail" )
306+ err := options .RunAddonTest ()
307+ require .NoError (t , err )
317308}
0 commit comments