Skip to content

Commit 440ec44

Browse files
authored
feat: removed support for 3.9 and 3.12 and added support for 4.0 (#393)
1 parent 6504e58 commit 440ec44

File tree

4 files changed

+59
-15
lines changed

4 files changed

+59
-15
lines changed

ibm_catalog.json

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -190,17 +190,13 @@
190190
"key": "rabbitmq_version",
191191
"required": true,
192192
"options": [
193-
{
194-
"displayname": "3.9",
195-
"value": "3.9"
196-
},
197-
{
198-
"displayname": "3.12",
199-
"value": "3.12"
200-
},
201193
{
202194
"displayname": "3.13",
203195
"value": "3.13"
196+
},
197+
{
198+
"displayname": "4.0",
199+
"value": "4.0"
204200
}
205201
]
206202
},

tests/other_test.go

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,58 @@
22
package test
33

44
import (
5+
"crypto/rand"
6+
"encoding/base64"
57
"fmt"
8+
"log"
69
"testing"
710

811
"github.com/stretchr/testify/assert"
912
"github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/testhelper"
1013
)
1114

15+
func TestRunCompleteExample(t *testing.T) {
16+
t.Parallel()
17+
18+
// Generate a 15 char long random string for the admin_pass
19+
randomBytes := make([]byte, 13)
20+
_, err := rand.Read(randomBytes)
21+
if err != nil {
22+
log.Fatal(err)
23+
}
24+
// add character prefix to avoid generated password beginning with special char and must have a number
25+
randomPass := "A1" + base64.URLEncoding.EncodeToString(randomBytes)[:13]
26+
27+
options := testhelper.TestOptionsDefaultWithVars(&testhelper.TestOptions{
28+
Testing: t,
29+
TerraformDir: completeExampleTerraformDir,
30+
Prefix: "rabbitmq-upg",
31+
BestRegionYAMLPath: regionSelectionPath,
32+
ResourceGroup: resourceGroup,
33+
TerraformVars: map[string]interface{}{
34+
"rabbitmq_version": earliestVersion, // Always lock to the lowest supported RabbitMQ version
35+
"users": []map[string]interface{}{
36+
{
37+
"name": "testuser",
38+
"password": randomPass, // pragma: allowlist secret
39+
"type": "database",
40+
},
41+
},
42+
"admin_pass": randomPass,
43+
},
44+
CloudInfoService: sharedInfoSvc,
45+
})
46+
47+
output, err := options.RunTestConsistency()
48+
assert.Nil(t, err, "This should not have errored")
49+
assert.NotNil(t, output, "Expected some output")
50+
51+
outputs := options.LastTestTerraformOutputs
52+
expectedOutputs := []string{"port", "hostname"}
53+
_, outputErr := testhelper.ValidateTerraformOutputs(outputs, expectedOutputs...)
54+
assert.NoErrorf(t, outputErr, "Some outputs not found or nil")
55+
}
56+
1257
func testPlanICDVersions(t *testing.T, version string) {
1358
t.Parallel()
1459

@@ -45,7 +90,8 @@ func TestRunRestoredDBExample(t *testing.T) {
4590
ResourceGroup: resourceGroup,
4691
Region: fmt.Sprint(permanentResources["rabbitmqRegion"]),
4792
TerraformVars: map[string]interface{}{
48-
"rabbitmq_db_crn": permanentResources["rabbitmqCrn"],
93+
"rabbitmq_db_crn": permanentResources["rabbitmqCrn"],
94+
"rabbitmq_version": permanentResources["rabbitmqVersion"],
4995
},
5096
CloudInfoService: sharedInfoSvc,
5197
})

tests/pr_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ import (
2525
)
2626

2727
const standardSolutionTerraformDir = "solutions/standard"
28+
const completeExampleTerraformDir = "examples/complete"
2829
const fscloudExampleTerraformDir = "examples/fscloud"
29-
const latestVersion = "3.13"
30+
const earliestVersion = "3.13"
31+
const latestVersion = "4.0"
3032

3133
// Use existing resource group
3234
const resourceGroup = "geretain-test-rabbitmq"
@@ -112,7 +114,7 @@ func TestRunStandardSolutionSchematics(t *testing.T) {
112114
{Name: "existing_backup_kms_key_crn", Value: permanentResources["hpcs_south_root_key_crn"], DataType: "string"},
113115
{Name: "kms_endpoint_type", Value: "private", DataType: "string"},
114116
{Name: "resource_group_name", Value: options.Prefix, DataType: "string"},
115-
{Name: "rabbitmq_version", Value: "3.13", DataType: "string"}, // Always lock this test into the latest supported RabbitMQ version
117+
{Name: "rabbitmq_version", Value: latestVersion, DataType: "string"}, // Always lock this test into the latest supported RabbitMQ version
116118
{Name: "service_credential_names", Value: string(serviceCredentialNamesJSON), DataType: "map(string)"},
117119
{Name: "existing_secrets_manager_instance_crn", Value: permanentResources["secretsManagerCRN"], DataType: "string"},
118120
{Name: "service_credential_secrets", Value: serviceCredentialSecrets, DataType: "list(object)"},
@@ -164,7 +166,7 @@ func TestPlanValidation(t *testing.T) {
164166
options.TerraformOptions.Vars = map[string]any{
165167
"prefix": options.Prefix,
166168
"region": "us-south",
167-
"rabbitmq_version": "3.13",
169+
"rabbitmq_version": earliestVersion,
168170
"provider_visibility": "public",
169171
"resource_group_name": options.Prefix,
170172
}

variables.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ variable "rabbitmq_version" {
2020
validation {
2121
condition = anytrue([
2222
var.rabbitmq_version == null,
23-
var.rabbitmq_version == "3.12",
24-
var.rabbitmq_version == "3.13"
23+
var.rabbitmq_version == "3.13",
24+
var.rabbitmq_version == "4.0",
2525
])
26-
error_message = "Version must be 3.12 or 3.13. If no value passed, the current ICD preferred version is used."
26+
error_message = "Version must be 3.13 or 4.0. If no value passed, the current ICD preferred version is used."
2727
}
2828
}
2929

0 commit comments

Comments
 (0)