Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions ibm_catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
},
Expand Down
50 changes: 49 additions & 1 deletion tests/other_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,60 @@
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 TestRunCompleteUpgradeExample(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upgrade test will never run in tests/other_test.go so its pointless in adding it. If we have a DA upgrade test, we don't need an example one too. Just make sure there is a standard test for the example (in pr_test.go or other_test.go)

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.RunTestUpgrade()
if !options.UpgradeTestSkipped {
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()

Expand Down Expand Up @@ -45,7 +92,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,
})
Expand Down
8 changes: 5 additions & 3 deletions tests/pr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)"},
Expand Down Expand Up @@ -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,
}
Expand Down
6 changes: 3 additions & 3 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
}

Expand Down