diff --git a/tests/pr_test.go b/tests/pr_test.go index 362af949..0e4e6459 100644 --- a/tests/pr_test.go +++ b/tests/pr_test.go @@ -70,18 +70,6 @@ func setupOptions(t *testing.T, prefix string, checkApplyResultForUpgrade bool) return options } -func TestRunUpgradeExample(t *testing.T) { - t.Parallel() - - options := setupOptions(t, "secrets-mgr-upg", true) - - output, err := options.RunTestUpgrade() - if !options.UpgradeTestSkipped { - assert.Nil(t, err, "This should not have errored") - assert.NotNil(t, output, "Expected some output") - } -} - func TestRunDASolutionSchematics(t *testing.T) { t.Parallel() @@ -237,3 +225,52 @@ func TestRunExistingResourcesInstances(t *testing.T) { logger.Log(t, "END: Destroy (existing resources)") } } + +func TestRunSecretsManagerSolutionUpgradeSchematic(t *testing.T) { + t.Parallel() + + acme_letsencrypt_private_key := GetSecretsManagerKey( // pragma: allowlist secret + permanentResources["acme_letsencrypt_private_key_sm_id"].(string), + permanentResources["acme_letsencrypt_private_key_sm_region"].(string), + permanentResources["acme_letsencrypt_private_key_secret_id"].(string), + ) + + // Set up a schematics test + options := testschematic.TestSchematicOptionsDefault(&testschematic.TestSchematicOptions{ + Testing: t, + TarIncludePatterns: []string{ + "*.tf", + fmt.Sprintf("%s/*.tf", solutionsTerraformDir), + fmt.Sprintf("%s/*.tf", fscloudExampleTerraformDir), + fmt.Sprintf("%s/*.tf", "modules/secrets"), + fmt.Sprintf("%s/*.tf", "modules/fscloud"), + }, + TemplateFolder: solutionsTerraformDir, + ResourceGroup: resourceGroup, + Prefix: "sm-da", + Tags: []string{"test-schematic"}, + DeleteWorkspaceOnFail: false, + WaitJobCompleteMinutes: 60, + }) + + options.TerraformVars = []testschematic.TestSchematicTerraformVar{ + {Name: "ibmcloud_api_key", Value: options.RequiredEnvironmentVars["TF_VAR_ibmcloud_api_key"], DataType: "string", Secure: true}, + {Name: "prefix", Value: options.Prefix, DataType: "string"}, + {Name: "region", Value: validRegions[rand.Intn(len(validRegions))], DataType: "string"}, + {Name: "resource_group_name", Value: options.Prefix, DataType: "string"}, + {Name: "service_plan", Value: "trial", DataType: "string"}, + {Name: "existing_kms_instance_crn", Value: permanentResources["hpcs_south_crn"], DataType: "string"}, + {Name: "iam_engine_enabled", Value: true, DataType: "bool"}, + {Name: "public_engine_enabled", Value: true, DataType: "bool"}, + {Name: "private_engine_enabled", Value: true, DataType: "bool"}, + {Name: "cis_id", Value: permanentResources["cisInstanceId"], DataType: "string"}, + {Name: "ca_name", Value: permanentResources["certificateAuthorityName"], DataType: "string"}, + {Name: "dns_provider_name", Value: permanentResources["dnsProviderName"], DataType: "string"}, + {Name: "acme_letsencrypt_private_key", Value: *acme_letsencrypt_private_key, DataType: "string"}, + } + + err := options.RunSchematicUpgradeTest() + if !options.UpgradeTestSkipped { + assert.Nil(t, err, "This should not have errored") + } +}