Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions ibm_catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,11 @@
"version_input": "prefix",
"reference_version": true
},
{
"dependency_input": "existing_kms_instance_crn",
"version_input": "existing_kms_instance_crn",
"reference_version": true
},
{
"dependency_input": "region",
"version_input": "region",
Expand Down
4 changes: 2 additions & 2 deletions tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ go 1.23.0
toolchain go1.24.4

require (
github.com/IBM/go-sdk-core/v5 v5.20.1
github.com/gruntwork-io/terratest v0.50.0
github.com/stretchr/testify v1.10.0
github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper v1.55.2
github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper v1.55.5
)

require (
dario.cat/mergo v1.0.0 // indirect
github.com/IBM-Cloud/bluemix-go v0.0.0-20240719075425-078fcb3a55be // indirect
github.com/IBM-Cloud/power-go-client v1.11.0 // indirect
github.com/IBM/cloud-databases-go-sdk v0.8.0 // indirect
github.com/IBM/go-sdk-core/v5 v5.20.1 // indirect
github.com/IBM/platform-services-go-sdk v0.83.2 // indirect
github.com/IBM/project-go-sdk v0.3.6 // indirect
github.com/IBM/schematics-go-sdk v0.4.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper v1.55.2 h1:glzdzCX2gbltCJd6Ii4GCU/xYJVLUXFs+FvJp42YheE=
github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper v1.55.2/go.mod h1:VqiPX6tW9J87xrrrSP7NE9C5jZNmv+wRoRHDfgBYSSY=
github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper v1.55.5 h1:sfTtDP0BK/VfTxWRo/Nc+w9i1hux8P+b9pTqqgC8I3A=
github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper v1.55.5/go.mod h1:VqiPX6tW9J87xrrrSP7NE9C5jZNmv+wRoRHDfgBYSSY=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/tmccombs/hcl2json v0.6.4 h1:/FWnzS9JCuyZ4MNwrG4vMrFrzRgsWEOVi+1AyYUVLGw=
github.com/tmccombs/hcl2json v0.6.4/go.mod h1:+ppKlIW3H5nsAsZddXPy2iMyvld3SHxyjswOZhavRDk=
Expand Down
290 changes: 290 additions & 0 deletions tests/pr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ import (
"strings"
"testing"

"github.com/IBM/go-sdk-core/v5/core"
"github.com/gruntwork-io/terratest/modules/files"
"github.com/gruntwork-io/terratest/modules/logger"
"github.com/gruntwork-io/terratest/modules/random"
"github.com/gruntwork-io/terratest/modules/terraform"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/cloudinfo"
"github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/common"
"github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/testaddons"
"github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/testhelper"
"github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/testschematic"
)
Expand Down Expand Up @@ -482,3 +485,290 @@ func TestRunExistingResourcesInstances(t *testing.T) {
logger.Log(t, "END: Destroy (existing resources)")
}
}

// TestRunFullyConfigurableAddonTests runs addon tests for the fully-configurable flavor using matrix approach
func TestRunFullyConfigurableAddonTests(t *testing.T) {
testCases := []testaddons.AddonTestCase{
{
Name: "EN-Default-Configuration",
Prefix: "endeft",
},
{
Name: "EN-With-Resource-Group-Only",
Prefix: "enrgol",
Dependencies: []cloudinfo.AddonConfig{
{
OfferingName: "deploy-arch-ibm-account-infra-base",
OfferingFlavor: "resource-group-only",
Enabled: core.BoolPtr(true),
},
},
SkipInfrastructureDeployment: true,
},
{
Name: "EN-With-Resource-Group-And-Account-Settings",
Prefix: "enrgas",
Dependencies: []cloudinfo.AddonConfig{
{
OfferingName: "deploy-arch-ibm-account-infra-base",
OfferingFlavor: "resource-groups-with-account-settings",
Enabled: core.BoolPtr(true),
},
},
SkipInfrastructureDeployment: true,
},
{
Name: "EN-With-KMS-Disabled",
Copy link
Contributor

@ocofaigh ocofaigh Jul 10, 2025

Choose a reason for hiding this comment

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

This test should not be passing. The current Observability monolith requires KMS. So if you remove KMS, the Observability DA has a required input thats shows like this:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this test case, we explicitly pass the key line 531, as we expect the user to do this in that flow. Or do you think we should raise the key up to the top level and never have them go to the lower level configurations?

Copy link
Contributor

@ocofaigh ocofaigh Jul 11, 2025

Choose a reason for hiding this comment

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

I don't think consumer should ever have to go to the lower level configurations to fill in a required value. Only if they want to override a value. The problem here is that KMS is required for current Observability DA. And until we add a "Full configurable" variation - I think we have to mark KMS as required in Observability DA

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually this is set at the top level which I think is the correct usage

Prefix: "ennokm",
Dependencies: []cloudinfo.AddonConfig{
{
OfferingName: "deploy-arch-ibm-kms",
OfferingFlavor: "fully-configurable",
Enabled: core.BoolPtr(false),
},
},
Inputs: map[string]interface{}{
"existing_kms_instance_crn": permanentResources["kp_us_south_root_key_crn"],
},
SkipInfrastructureDeployment: true,
},
{
Name: "EN-With-COS-Disabled",
Prefix: "ennocs",
Dependencies: []cloudinfo.AddonConfig{
{
OfferingName: "deploy-arch-ibm-cos",
OfferingFlavor: "instance",
Enabled: core.BoolPtr(false),
},
},
SkipInfrastructureDeployment: true,
},
{
Name: "EN-With-Observability-Disabled",
Prefix: "ennoob",
Dependencies: []cloudinfo.AddonConfig{
{
OfferingName: "deploy-arch-ibm-observability",
OfferingFlavor: "instances",
Enabled: core.BoolPtr(false),
},
},
SkipInfrastructureDeployment: true,
},
{
Name: "EN-With-KMS-And-COS-Disabled",
Prefix: "enkmcno",
Dependencies: []cloudinfo.AddonConfig{
{
OfferingName: "deploy-arch-ibm-kms",
OfferingFlavor: "fully-configurable",
Enabled: core.BoolPtr(false),
},
{
OfferingName: "deploy-arch-ibm-cos",
OfferingFlavor: "instance",
Enabled: core.BoolPtr(false),
},
},
Inputs: map[string]interface{}{
"existing_kms_instance_crn": permanentResources["kp_us_south_root_key_crn"],
},
SkipInfrastructureDeployment: true,
},
{
Name: "EN-With-KMS-And-Observability-Disabled",
Prefix: "enkmobno",
Dependencies: []cloudinfo.AddonConfig{
{
OfferingName: "deploy-arch-ibm-kms",
OfferingFlavor: "fully-configurable",
Enabled: core.BoolPtr(false),
},
{
OfferingName: "deploy-arch-ibm-observability",
OfferingFlavor: "instances",
Enabled: core.BoolPtr(false),
},
},
Inputs: map[string]interface{}{
"existing_kms_instance_crn": permanentResources["kp_us_south_root_key_crn"],
},
SkipInfrastructureDeployment: true,
},
{
Name: "EN-With-COS-And-Observability-Disabled",
Prefix: "encobno",
Dependencies: []cloudinfo.AddonConfig{
{
OfferingName: "deploy-arch-ibm-cos",
OfferingFlavor: "instance",
Enabled: core.BoolPtr(false),
},
{
OfferingName: "deploy-arch-ibm-observability",
OfferingFlavor: "instances",
Enabled: core.BoolPtr(false),
},
},
SkipInfrastructureDeployment: true,
},
{
Name: "EN-With-All-Optional-Services-Disabled",
Prefix: "enallno",
Dependencies: []cloudinfo.AddonConfig{
{
OfferingName: "deploy-arch-ibm-kms",
OfferingFlavor: "fully-configurable",
Enabled: core.BoolPtr(false),
},
{
OfferingName: "deploy-arch-ibm-cos",
OfferingFlavor: "instance",
Enabled: core.BoolPtr(false),
},
{
OfferingName: "deploy-arch-ibm-observability",
OfferingFlavor: "instances",
Enabled: core.BoolPtr(false),
},
},
Inputs: map[string]interface{}{
"existing_kms_instance_crn": permanentResources["kp_us_south_root_key_crn"],
},
SkipInfrastructureDeployment: true,
},
{
Name: "EN-With-KMS-Enabled-COS-Observability-Disabled",
Prefix: "enkmsy",
Dependencies: []cloudinfo.AddonConfig{
{
OfferingName: "deploy-arch-ibm-cos",
OfferingFlavor: "instance",
Enabled: core.BoolPtr(false),
},
{
OfferingName: "deploy-arch-ibm-observability",
OfferingFlavor: "instances",
Enabled: core.BoolPtr(false),
},
},
SkipInfrastructureDeployment: true,
},
{
Name: "EN-With-COS-Enabled-KMS-Observability-Disabled",
Prefix: "encosy",
Dependencies: []cloudinfo.AddonConfig{
{
OfferingName: "deploy-arch-ibm-kms",
OfferingFlavor: "fully-configurable",
Enabled: core.BoolPtr(false),
},
{
OfferingName: "deploy-arch-ibm-observability",
OfferingFlavor: "instances",
Enabled: core.BoolPtr(false),
},
},
Inputs: map[string]interface{}{
"existing_kms_instance_crn": permanentResources["kp_us_south_root_key_crn"],
},
SkipInfrastructureDeployment: true,
},
{
Name: "EN-With-Observability-Enabled-KMS-COS-Disabled",
Prefix: "enobsy",
Dependencies: []cloudinfo.AddonConfig{
{
OfferingName: "deploy-arch-ibm-kms",
OfferingFlavor: "fully-configurable",
Enabled: core.BoolPtr(false),
},
{
OfferingName: "deploy-arch-ibm-cos",
OfferingFlavor: "instance",
Enabled: core.BoolPtr(false),
},
},
Inputs: map[string]interface{}{
"existing_kms_instance_crn": permanentResources["kp_us_south_root_key_crn"],
},
SkipInfrastructureDeployment: true,
},
{
Name: "EN-With-KMS-And-COS-Enabled-Observability-Disabled",
Prefix: "enkmcsy",
Dependencies: []cloudinfo.AddonConfig{
{
OfferingName: "deploy-arch-ibm-observability",
OfferingFlavor: "instances",
Enabled: core.BoolPtr(false),
},
},
SkipInfrastructureDeployment: true,
},
{
Name: "EN-With-KMS-And-Observability-Enabled-COS-Disabled",
Prefix: "enkmobsy",
Dependencies: []cloudinfo.AddonConfig{
{
OfferingName: "deploy-arch-ibm-cos",
OfferingFlavor: "instance",
Enabled: core.BoolPtr(false),
},
},
SkipInfrastructureDeployment: true,
},
{
Name: "EN-With-COS-And-Observability-Enabled-KMS-Disabled",
Prefix: "encobsy",
Dependencies: []cloudinfo.AddonConfig{
{
OfferingName: "deploy-arch-ibm-kms",
OfferingFlavor: "fully-configurable",
Enabled: core.BoolPtr(false),
},
},
Inputs: map[string]interface{}{
"existing_kms_instance_crn": permanentResources["kp_us_south_root_key_crn"],
},
SkipInfrastructureDeployment: true,
},
{
Name: "EN-With-All-Optional-Services-Enabled",
Prefix: "enallyes",
SkipInfrastructureDeployment: true,
},
}

// Define common options that apply to all test cases
baseOptions := testaddons.TestAddonsOptionsDefault(&testaddons.TestAddonOptions{
Testing: t,
Prefix: "en-matrix", // Test cases will override with their own prefixes
ResourceGroup: resourceGroup,
SkipLocalChangeCheck: true, // Skip local change check for addon tests
})

matrix := testaddons.AddonTestMatrix{
TestCases: testCases,
BaseOptions: baseOptions,
BaseSetupFunc: func(baseOptions *testaddons.TestAddonOptions, testCase testaddons.AddonTestCase) *testaddons.TestAddonOptions {
// The framework automatically handles prefix assignment from testCase.Prefix
return baseOptions
},
AddonConfigFunc: func(options *testaddons.TestAddonOptions, testCase testaddons.AddonTestCase) cloudinfo.AddonConfig {
return cloudinfo.NewAddonConfigTerraform(
options.Prefix,
"deploy-arch-ibm-event-notifications",
"fully-configurable",
map[string]interface{}{
"prefix": options.Prefix,
"region": validRegions[rand.Intn(len(validRegions))],
"enable_platform_metrics": "false", // Disable platform metrics for addon tests
},
)
},
}

baseOptions.RunAddonTestMatrix(matrix)
}