diff --git a/ibm_catalog.json b/ibm_catalog.json index 7d96afe..b825340 100644 --- a/ibm_catalog.json +++ b/ibm_catalog.json @@ -190,17 +190,13 @@ "key": "rabbitmq_version", "required": true, "options": [ - { - "displayname": "3.9", - "value": "3.9" - }, - { - "displayname": "3.12", - "value": "3.12" - }, { "displayname": "3.13", "value": "3.13" + }, + { + "displayname": "4.0", + "value": "4.0" } ] }, diff --git a/tests/other_test.go b/tests/other_test.go index e2c9e89..778c111 100644 --- a/tests/other_test.go +++ b/tests/other_test.go @@ -2,13 +2,58 @@ package test import ( + "crypto/rand" + "encoding/base64" "fmt" + "log" "testing" "github.com/stretchr/testify/assert" "github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/testhelper" ) +func TestRunCompleteExample(t *testing.T) { + t.Parallel() + + // Generate a 15 char long random string for the admin_pass + randomBytes := make([]byte, 13) + _, err := rand.Read(randomBytes) + if err != nil { + log.Fatal(err) + } + // add character prefix to avoid generated password beginning with special char and must have a number + randomPass := "A1" + base64.URLEncoding.EncodeToString(randomBytes)[:13] + + options := testhelper.TestOptionsDefaultWithVars(&testhelper.TestOptions{ + Testing: t, + TerraformDir: completeExampleTerraformDir, + Prefix: "rabbitmq-upg", + BestRegionYAMLPath: regionSelectionPath, + ResourceGroup: resourceGroup, + TerraformVars: map[string]interface{}{ + "rabbitmq_version": earliestVersion, // Always lock to the lowest supported RabbitMQ version + "users": []map[string]interface{}{ + { + "name": "testuser", + "password": randomPass, // pragma: allowlist secret + "type": "database", + }, + }, + "admin_pass": randomPass, + }, + CloudInfoService: sharedInfoSvc, + }) + + output, err := options.RunTestConsistency() + assert.Nil(t, err, "This should not have errored") + assert.NotNil(t, output, "Expected some output") + + outputs := options.LastTestTerraformOutputs + expectedOutputs := []string{"port", "hostname"} + _, outputErr := testhelper.ValidateTerraformOutputs(outputs, expectedOutputs...) + assert.NoErrorf(t, outputErr, "Some outputs not found or nil") +} + func testPlanICDVersions(t *testing.T, version string) { t.Parallel() @@ -45,7 +90,8 @@ func TestRunRestoredDBExample(t *testing.T) { ResourceGroup: resourceGroup, Region: fmt.Sprint(permanentResources["rabbitmqRegion"]), TerraformVars: map[string]interface{}{ - "rabbitmq_db_crn": permanentResources["rabbitmqCrn"], + "rabbitmq_db_crn": permanentResources["rabbitmqCrn"], + "rabbitmq_version": permanentResources["rabbitmqVersion"], }, CloudInfoService: sharedInfoSvc, }) diff --git a/tests/pr_test.go b/tests/pr_test.go index cb3c361..b3a1b3a 100644 --- a/tests/pr_test.go +++ b/tests/pr_test.go @@ -25,8 +25,10 @@ import ( ) const standardSolutionTerraformDir = "solutions/standard" +const completeExampleTerraformDir = "examples/complete" const fscloudExampleTerraformDir = "examples/fscloud" -const latestVersion = "3.13" +const earliestVersion = "3.13" +const latestVersion = "4.0" // Use existing resource group const resourceGroup = "geretain-test-rabbitmq" @@ -112,7 +114,7 @@ func TestRunStandardSolutionSchematics(t *testing.T) { {Name: "existing_backup_kms_key_crn", Value: permanentResources["hpcs_south_root_key_crn"], DataType: "string"}, {Name: "kms_endpoint_type", Value: "private", DataType: "string"}, {Name: "resource_group_name", Value: options.Prefix, DataType: "string"}, - {Name: "rabbitmq_version", Value: "3.13", DataType: "string"}, // Always lock this test into the latest supported RabbitMQ version + {Name: "rabbitmq_version", Value: latestVersion, DataType: "string"}, // Always lock this test into the latest supported RabbitMQ version {Name: "service_credential_names", Value: string(serviceCredentialNamesJSON), DataType: "map(string)"}, {Name: "existing_secrets_manager_instance_crn", Value: permanentResources["secretsManagerCRN"], DataType: "string"}, {Name: "service_credential_secrets", Value: serviceCredentialSecrets, DataType: "list(object)"}, @@ -164,7 +166,7 @@ func TestPlanValidation(t *testing.T) { options.TerraformOptions.Vars = map[string]any{ "prefix": options.Prefix, "region": "us-south", - "rabbitmq_version": "3.13", + "rabbitmq_version": earliestVersion, "provider_visibility": "public", "resource_group_name": options.Prefix, } diff --git a/variables.tf b/variables.tf index 26e14b4..86e1d62 100644 --- a/variables.tf +++ b/variables.tf @@ -20,10 +20,10 @@ variable "rabbitmq_version" { validation { condition = anytrue([ var.rabbitmq_version == null, - var.rabbitmq_version == "3.12", - var.rabbitmq_version == "3.13" + var.rabbitmq_version == "3.13", + var.rabbitmq_version == "4.0", ]) - error_message = "Version must be 3.12 or 3.13. If no value passed, the current ICD preferred version is used." + error_message = "Version must be 3.13 or 4.0. If no value passed, the current ICD preferred version is used." } }