@@ -9,8 +9,12 @@ import (
99 "os"
1010 "testing"
1111
12+ "github.com/IBM/go-sdk-core/v5/core"
1213 "github.com/stretchr/testify/assert"
14+ "github.com/stretchr/testify/require"
15+ "github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/cloudinfo"
1316 "github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/common"
17+ "github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/testaddons"
1418 "github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/testhelper"
1519 "github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/testschematic"
1620)
@@ -20,6 +24,7 @@ const resourceGroup = "geretain-test-resources"
2024
2125const fullyConfigurableTerraformDir = "solutions/fully-configurable"
2226const quickStartTerraformDir = "solutions/quickstart"
27+ const terraformVersion = "terraform_v1.10" // This should match the version in the ibm_catalog.json
2328
2429// Define a struct with fields that match the structure of the YAML data
2530const yamlLocation = "../common-dev-assets/common-go-assets/common-permanent-resources.yaml"
@@ -44,10 +49,11 @@ func TestMain(m *testing.M) {
4449
4550func setupOptions (t * testing.T , prefix string , dir string ) * testhelper.TestOptions {
4651 options := testhelper .TestOptionsDefaultWithVars (& testhelper.TestOptions {
47- Testing : t ,
48- TerraformDir : dir ,
49- Prefix : prefix ,
50- ResourceGroup : resourceGroup ,
52+ Testing : t ,
53+ TerraformDir : dir ,
54+ Prefix : prefix ,
55+ ResourceGroup : resourceGroup ,
56+ CheckApplyResultForUpgrade : true ,
5157 })
5258 return options
5359}
@@ -67,11 +73,13 @@ func setupQuickstartOptions(t *testing.T, prefix string) *testschematic.TestSche
6773 quickStartTerraformDir + "/*.tf" ,
6874 },
6975
70- TemplateFolder : quickStartTerraformDir ,
71- Tags : []string {"test-schematic" },
72- DeleteWorkspaceOnFail : false ,
73- WaitJobCompleteMinutes : 360 ,
74- Region : region ,
76+ TemplateFolder : quickStartTerraformDir ,
77+ Tags : []string {"test-schematic" },
78+ DeleteWorkspaceOnFail : false ,
79+ WaitJobCompleteMinutes : 360 ,
80+ Region : region ,
81+ TerraformVersion : terraformVersion ,
82+ CheckApplyResultForUpgrade : true ,
7583 })
7684 options .TerraformVars = []testschematic.TestSchematicTerraformVar {
7785 {Name : "ibmcloud_api_key" , Value : options .RequiredEnvironmentVars ["TF_VAR_ibmcloud_api_key" ], DataType : "string" , Secure : true },
@@ -133,3 +141,61 @@ func TestRunQuickstartUpgradeSchematics(t *testing.T) {
133141 assert .Nil (t , err , "This should not have errored" )
134142 }
135143}
144+
145+ /*******************************************************************
146+ * Addons test *
147+ ********************************************************************/
148+
149+ func TestAddonDefaultConfiguration (t * testing.T ) {
150+ t .Parallel ()
151+
152+ options := testaddons .TestAddonsOptionsDefault (& testaddons.TestAddonOptions {
153+ Testing : t ,
154+ Prefix : "ai-add" ,
155+ ResourceGroup : resourceGroup ,
156+ QuietMode : false , // Suppress logs except on failure
157+ })
158+
159+ options .AddonConfig = cloudinfo .NewAddonConfigTerraform (
160+ options .Prefix ,
161+ "deploy-arch-ibm-ocp-ai" ,
162+ "fully-configurable" ,
163+ map [string ]interface {}{
164+ "prefix" : options .Prefix ,
165+ },
166+ )
167+
168+ options .AddonConfig .Dependencies = []cloudinfo.AddonConfig {
169+ // use existing secrets manager instance to help prevent hitting trial instance limit in account
170+ {
171+ OfferingName : "deploy-arch-ibm-secrets-manager" ,
172+ OfferingFlavor : "fully-configurable" ,
173+ Inputs : map [string ]interface {}{
174+ "existing_secrets_manager_crn" : permanentResources ["privateOnlySecMgrCRN" ],
175+ "service_plan" : "__NULL__" , // no plan value needed when using existing SM
176+ "skip_secrets_manager_iam_auth_policy" : true , // since using an existing Secrets Manager instance, attempting to re-create auth policy can cause conflicts if the policy already exists
177+ "secret_groups" : []string {}, // passing empty array for secret groups as default value is creating general group and it will cause conflicts as we are using an existing SM
178+ },
179+ },
180+ // Disable target / route creation to prevent hitting quota in account
181+ {
182+ OfferingName : "deploy-arch-ibm-cloud-monitoring" ,
183+ OfferingFlavor : "fully-configurable" ,
184+ Inputs : map [string ]interface {}{
185+ "enable_metrics_routing_to_cloud_monitoring" : false ,
186+ },
187+ Enabled : core .BoolPtr (true ),
188+ },
189+ {
190+ OfferingName : "deploy-arch-ibm-activity-tracker" ,
191+ OfferingFlavor : "fully-configurable" ,
192+ Inputs : map [string ]interface {}{
193+ "enable_activity_tracker_event_routing_to_cloud_logs" : false ,
194+ },
195+ Enabled : core .BoolPtr (true ),
196+ },
197+ }
198+
199+ err := options .RunAddonTest ()
200+ require .NoError (t , err )
201+ }
0 commit comments