@@ -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