Skip to content

Commit e3d2d6b

Browse files
fix: add support to DA for existing KMS instance CRN as a dependency input (#496)
1 parent ea4bcb5 commit e3d2d6b

File tree

4 files changed

+299
-4
lines changed

4 files changed

+299
-4
lines changed

ibm_catalog.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,11 @@
650650
"version_input": "prefix",
651651
"reference_version": true
652652
},
653+
{
654+
"dependency_input": "existing_kms_instance_crn",
655+
"version_input": "existing_kms_instance_crn",
656+
"reference_version": true
657+
},
653658
{
654659
"dependency_input": "region",
655660
"version_input": "region",

tests/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ go 1.23.0
55
toolchain go1.24.4
66

77
require (
8+
github.com/IBM/go-sdk-core/v5 v5.20.1
89
github.com/gruntwork-io/terratest v0.50.0
910
github.com/stretchr/testify v1.10.0
10-
github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper v1.55.2
11+
github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper v1.55.5
1112
)
1213

1314
require (
1415
dario.cat/mergo v1.0.0 // indirect
1516
github.com/IBM-Cloud/bluemix-go v0.0.0-20240719075425-078fcb3a55be // indirect
1617
github.com/IBM-Cloud/power-go-client v1.11.0 // indirect
1718
github.com/IBM/cloud-databases-go-sdk v0.8.0 // indirect
18-
github.com/IBM/go-sdk-core/v5 v5.20.1 // indirect
1919
github.com/IBM/platform-services-go-sdk v0.83.2 // indirect
2020
github.com/IBM/project-go-sdk v0.3.6 // indirect
2121
github.com/IBM/schematics-go-sdk v0.4.0 // indirect

tests/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
295295
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
296296
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
297297
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
298-
github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper v1.55.2 h1:glzdzCX2gbltCJd6Ii4GCU/xYJVLUXFs+FvJp42YheE=
299-
github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper v1.55.2/go.mod h1:VqiPX6tW9J87xrrrSP7NE9C5jZNmv+wRoRHDfgBYSSY=
298+
github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper v1.55.5 h1:sfTtDP0BK/VfTxWRo/Nc+w9i1hux8P+b9pTqqgC8I3A=
299+
github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper v1.55.5/go.mod h1:VqiPX6tW9J87xrrrSP7NE9C5jZNmv+wRoRHDfgBYSSY=
300300
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
301301
github.com/tmccombs/hcl2json v0.6.4 h1:/FWnzS9JCuyZ4MNwrG4vMrFrzRgsWEOVi+1AyYUVLGw=
302302
github.com/tmccombs/hcl2json v0.6.4/go.mod h1:+ppKlIW3H5nsAsZddXPy2iMyvld3SHxyjswOZhavRDk=

tests/pr_test.go

Lines changed: 290 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@ import (
1010
"strings"
1111
"testing"
1212

13+
"github.com/IBM/go-sdk-core/v5/core"
1314
"github.com/gruntwork-io/terratest/modules/files"
1415
"github.com/gruntwork-io/terratest/modules/logger"
1516
"github.com/gruntwork-io/terratest/modules/random"
1617
"github.com/gruntwork-io/terratest/modules/terraform"
1718

1819
"github.com/stretchr/testify/assert"
1920
"github.com/stretchr/testify/require"
21+
"github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/cloudinfo"
2022
"github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/common"
23+
"github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/testaddons"
2124
"github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/testhelper"
2225
"github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/testschematic"
2326
)
@@ -482,3 +485,290 @@ func TestRunExistingResourcesInstances(t *testing.T) {
482485
logger.Log(t, "END: Destroy (existing resources)")
483486
}
484487
}
488+
489+
// TestRunFullyConfigurableAddonTests runs addon tests for the fully-configurable flavor using matrix approach
490+
func TestRunFullyConfigurableAddonTests(t *testing.T) {
491+
testCases := []testaddons.AddonTestCase{
492+
{
493+
Name: "EN-Default-Configuration",
494+
Prefix: "endeft",
495+
},
496+
{
497+
Name: "EN-With-Resource-Group-Only",
498+
Prefix: "enrgol",
499+
Dependencies: []cloudinfo.AddonConfig{
500+
{
501+
OfferingName: "deploy-arch-ibm-account-infra-base",
502+
OfferingFlavor: "resource-group-only",
503+
Enabled: core.BoolPtr(true),
504+
},
505+
},
506+
SkipInfrastructureDeployment: true,
507+
},
508+
{
509+
Name: "EN-With-Resource-Group-And-Account-Settings",
510+
Prefix: "enrgas",
511+
Dependencies: []cloudinfo.AddonConfig{
512+
{
513+
OfferingName: "deploy-arch-ibm-account-infra-base",
514+
OfferingFlavor: "resource-groups-with-account-settings",
515+
Enabled: core.BoolPtr(true),
516+
},
517+
},
518+
SkipInfrastructureDeployment: true,
519+
},
520+
{
521+
Name: "EN-With-KMS-Disabled",
522+
Prefix: "ennokm",
523+
Dependencies: []cloudinfo.AddonConfig{
524+
{
525+
OfferingName: "deploy-arch-ibm-kms",
526+
OfferingFlavor: "fully-configurable",
527+
Enabled: core.BoolPtr(false),
528+
},
529+
},
530+
Inputs: map[string]interface{}{
531+
"existing_kms_instance_crn": permanentResources["kp_us_south_root_key_crn"],
532+
},
533+
SkipInfrastructureDeployment: true,
534+
},
535+
{
536+
Name: "EN-With-COS-Disabled",
537+
Prefix: "ennocs",
538+
Dependencies: []cloudinfo.AddonConfig{
539+
{
540+
OfferingName: "deploy-arch-ibm-cos",
541+
OfferingFlavor: "instance",
542+
Enabled: core.BoolPtr(false),
543+
},
544+
},
545+
SkipInfrastructureDeployment: true,
546+
},
547+
{
548+
Name: "EN-With-Observability-Disabled",
549+
Prefix: "ennoob",
550+
Dependencies: []cloudinfo.AddonConfig{
551+
{
552+
OfferingName: "deploy-arch-ibm-observability",
553+
OfferingFlavor: "instances",
554+
Enabled: core.BoolPtr(false),
555+
},
556+
},
557+
SkipInfrastructureDeployment: true,
558+
},
559+
{
560+
Name: "EN-With-KMS-And-COS-Disabled",
561+
Prefix: "enkmcno",
562+
Dependencies: []cloudinfo.AddonConfig{
563+
{
564+
OfferingName: "deploy-arch-ibm-kms",
565+
OfferingFlavor: "fully-configurable",
566+
Enabled: core.BoolPtr(false),
567+
},
568+
{
569+
OfferingName: "deploy-arch-ibm-cos",
570+
OfferingFlavor: "instance",
571+
Enabled: core.BoolPtr(false),
572+
},
573+
},
574+
Inputs: map[string]interface{}{
575+
"existing_kms_instance_crn": permanentResources["kp_us_south_root_key_crn"],
576+
},
577+
SkipInfrastructureDeployment: true,
578+
},
579+
{
580+
Name: "EN-With-KMS-And-Observability-Disabled",
581+
Prefix: "enkmobno",
582+
Dependencies: []cloudinfo.AddonConfig{
583+
{
584+
OfferingName: "deploy-arch-ibm-kms",
585+
OfferingFlavor: "fully-configurable",
586+
Enabled: core.BoolPtr(false),
587+
},
588+
{
589+
OfferingName: "deploy-arch-ibm-observability",
590+
OfferingFlavor: "instances",
591+
Enabled: core.BoolPtr(false),
592+
},
593+
},
594+
Inputs: map[string]interface{}{
595+
"existing_kms_instance_crn": permanentResources["kp_us_south_root_key_crn"],
596+
},
597+
SkipInfrastructureDeployment: true,
598+
},
599+
{
600+
Name: "EN-With-COS-And-Observability-Disabled",
601+
Prefix: "encobno",
602+
Dependencies: []cloudinfo.AddonConfig{
603+
{
604+
OfferingName: "deploy-arch-ibm-cos",
605+
OfferingFlavor: "instance",
606+
Enabled: core.BoolPtr(false),
607+
},
608+
{
609+
OfferingName: "deploy-arch-ibm-observability",
610+
OfferingFlavor: "instances",
611+
Enabled: core.BoolPtr(false),
612+
},
613+
},
614+
SkipInfrastructureDeployment: true,
615+
},
616+
{
617+
Name: "EN-With-All-Optional-Services-Disabled",
618+
Prefix: "enallno",
619+
Dependencies: []cloudinfo.AddonConfig{
620+
{
621+
OfferingName: "deploy-arch-ibm-kms",
622+
OfferingFlavor: "fully-configurable",
623+
Enabled: core.BoolPtr(false),
624+
},
625+
{
626+
OfferingName: "deploy-arch-ibm-cos",
627+
OfferingFlavor: "instance",
628+
Enabled: core.BoolPtr(false),
629+
},
630+
{
631+
OfferingName: "deploy-arch-ibm-observability",
632+
OfferingFlavor: "instances",
633+
Enabled: core.BoolPtr(false),
634+
},
635+
},
636+
Inputs: map[string]interface{}{
637+
"existing_kms_instance_crn": permanentResources["kp_us_south_root_key_crn"],
638+
},
639+
SkipInfrastructureDeployment: true,
640+
},
641+
{
642+
Name: "EN-With-KMS-Enabled-COS-Observability-Disabled",
643+
Prefix: "enkmsy",
644+
Dependencies: []cloudinfo.AddonConfig{
645+
{
646+
OfferingName: "deploy-arch-ibm-cos",
647+
OfferingFlavor: "instance",
648+
Enabled: core.BoolPtr(false),
649+
},
650+
{
651+
OfferingName: "deploy-arch-ibm-observability",
652+
OfferingFlavor: "instances",
653+
Enabled: core.BoolPtr(false),
654+
},
655+
},
656+
SkipInfrastructureDeployment: true,
657+
},
658+
{
659+
Name: "EN-With-COS-Enabled-KMS-Observability-Disabled",
660+
Prefix: "encosy",
661+
Dependencies: []cloudinfo.AddonConfig{
662+
{
663+
OfferingName: "deploy-arch-ibm-kms",
664+
OfferingFlavor: "fully-configurable",
665+
Enabled: core.BoolPtr(false),
666+
},
667+
{
668+
OfferingName: "deploy-arch-ibm-observability",
669+
OfferingFlavor: "instances",
670+
Enabled: core.BoolPtr(false),
671+
},
672+
},
673+
Inputs: map[string]interface{}{
674+
"existing_kms_instance_crn": permanentResources["kp_us_south_root_key_crn"],
675+
},
676+
SkipInfrastructureDeployment: true,
677+
},
678+
{
679+
Name: "EN-With-Observability-Enabled-KMS-COS-Disabled",
680+
Prefix: "enobsy",
681+
Dependencies: []cloudinfo.AddonConfig{
682+
{
683+
OfferingName: "deploy-arch-ibm-kms",
684+
OfferingFlavor: "fully-configurable",
685+
Enabled: core.BoolPtr(false),
686+
},
687+
{
688+
OfferingName: "deploy-arch-ibm-cos",
689+
OfferingFlavor: "instance",
690+
Enabled: core.BoolPtr(false),
691+
},
692+
},
693+
Inputs: map[string]interface{}{
694+
"existing_kms_instance_crn": permanentResources["kp_us_south_root_key_crn"],
695+
},
696+
SkipInfrastructureDeployment: true,
697+
},
698+
{
699+
Name: "EN-With-KMS-And-COS-Enabled-Observability-Disabled",
700+
Prefix: "enkmcsy",
701+
Dependencies: []cloudinfo.AddonConfig{
702+
{
703+
OfferingName: "deploy-arch-ibm-observability",
704+
OfferingFlavor: "instances",
705+
Enabled: core.BoolPtr(false),
706+
},
707+
},
708+
SkipInfrastructureDeployment: true,
709+
},
710+
{
711+
Name: "EN-With-KMS-And-Observability-Enabled-COS-Disabled",
712+
Prefix: "enkmobsy",
713+
Dependencies: []cloudinfo.AddonConfig{
714+
{
715+
OfferingName: "deploy-arch-ibm-cos",
716+
OfferingFlavor: "instance",
717+
Enabled: core.BoolPtr(false),
718+
},
719+
},
720+
SkipInfrastructureDeployment: true,
721+
},
722+
{
723+
Name: "EN-With-COS-And-Observability-Enabled-KMS-Disabled",
724+
Prefix: "encobsy",
725+
Dependencies: []cloudinfo.AddonConfig{
726+
{
727+
OfferingName: "deploy-arch-ibm-kms",
728+
OfferingFlavor: "fully-configurable",
729+
Enabled: core.BoolPtr(false),
730+
},
731+
},
732+
Inputs: map[string]interface{}{
733+
"existing_kms_instance_crn": permanentResources["kp_us_south_root_key_crn"],
734+
},
735+
SkipInfrastructureDeployment: true,
736+
},
737+
{
738+
Name: "EN-With-All-Optional-Services-Enabled",
739+
Prefix: "enallyes",
740+
SkipInfrastructureDeployment: true,
741+
},
742+
}
743+
744+
// Define common options that apply to all test cases
745+
baseOptions := testaddons.TestAddonsOptionsDefault(&testaddons.TestAddonOptions{
746+
Testing: t,
747+
Prefix: "en-matrix", // Test cases will override with their own prefixes
748+
ResourceGroup: resourceGroup,
749+
SkipLocalChangeCheck: true, // Skip local change check for addon tests
750+
})
751+
752+
matrix := testaddons.AddonTestMatrix{
753+
TestCases: testCases,
754+
BaseOptions: baseOptions,
755+
BaseSetupFunc: func(baseOptions *testaddons.TestAddonOptions, testCase testaddons.AddonTestCase) *testaddons.TestAddonOptions {
756+
// The framework automatically handles prefix assignment from testCase.Prefix
757+
return baseOptions
758+
},
759+
AddonConfigFunc: func(options *testaddons.TestAddonOptions, testCase testaddons.AddonTestCase) cloudinfo.AddonConfig {
760+
return cloudinfo.NewAddonConfigTerraform(
761+
options.Prefix,
762+
"deploy-arch-ibm-event-notifications",
763+
"fully-configurable",
764+
map[string]interface{}{
765+
"prefix": options.Prefix,
766+
"region": validRegions[rand.Intn(len(validRegions))],
767+
"enable_platform_metrics": "false", // Disable platform metrics for addon tests
768+
},
769+
)
770+
},
771+
}
772+
773+
baseOptions.RunAddonTestMatrix(matrix)
774+
}

0 commit comments

Comments
 (0)