@@ -3,20 +3,21 @@ package test
33
44import (
55 "fmt"
6+ "log"
67 "os"
78 "strings"
89 "testing"
910
1011 "math/rand/v2"
1112
12- "github.com/IBM/go-sdk-core/core"
1313 "github.com/gruntwork-io/terratest/modules/files"
1414 "github.com/gruntwork-io/terratest/modules/logger"
1515 "github.com/gruntwork-io/terratest/modules/random"
1616 "github.com/gruntwork-io/terratest/modules/terraform"
1717 "github.com/stretchr/testify/assert"
1818 "github.com/stretchr/testify/require"
1919 "github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/cloudinfo"
20+ "github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/common"
2021 "github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/testaddons"
2122 "github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/testhelper"
2223 "github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/testschematic"
@@ -26,7 +27,11 @@ const resourceGroup = "geretain-test-observability-agents"
2627const fullyConfigurableSolutionDir = "solutions/fully-configurable"
2728const fullyConfigurableSolutionKubeconfigDir = "solutions/fully-configurable/kubeconfig"
2829const terraformDirLogsAgentIKS = "examples/logs-agent-iks"
30+ const terraformVersion = "terraform_v1.10" // This should match the version in the ibm_catalog.json
31+ // Define a struct with fields that match the structure of the YAML data
32+ const yamlLocation = "../common-dev-assets/common-go-assets/common-permanent-resources.yaml"
2933
34+ var permanentResources map [string ]interface {}
3035var IgnoreUpdates = []string {
3136 "module.logs_agent.helm_release.logs_agent" ,
3237}
@@ -47,6 +52,12 @@ var validRegions = []string{
4752func TestMain (m * testing.M ) {
4853 sharedInfoSvc , _ = cloudinfo .NewCloudInfoServiceFromEnv ("TF_VAR_ibmcloud_api_key" , cloudinfo.CloudInfoServiceOptions {})
4954
55+ var err error
56+ permanentResources , err = common .LoadMapFromYaml (yamlLocation )
57+ if err != nil {
58+ log .Fatal (err )
59+ }
60+
5061 os .Exit (m .Run ())
5162}
5263
@@ -60,7 +71,8 @@ func setupOptions(t *testing.T, prefix string, terraformDir string) *testhelper.
6071 IgnoreUpdates : testhelper.Exemptions { // Ignore for consistency check
6172 List : IgnoreUpdates ,
6273 },
63- CloudInfoService : sharedInfoSvc ,
74+ CloudInfoService : sharedInfoSvc ,
75+ CheckApplyResultForUpgrade : true ,
6476 })
6577
6678 return options
@@ -123,6 +135,7 @@ func TestFullyConfigurableSolution(t *testing.T) {
123135 DeleteWorkspaceOnFail : false ,
124136 WaitJobCompleteMinutes : 60 ,
125137 Region : region ,
138+ TerraformVersion : terraformVersion ,
126139 })
127140
128141 options .TerraformVars = []testschematic.TestSchematicTerraformVar {
@@ -208,6 +221,8 @@ func TestFullyConfigurableUpgradeSolution(t *testing.T) {
208221 IgnoreUpdates : testhelper.Exemptions { // Ignore for consistency check
209222 List : IgnoreUpdates ,
210223 },
224+ TerraformVersion : terraformVersion ,
225+ CheckApplyResultForUpgrade : true ,
211226 })
212227
213228 options .TerraformVars = []testschematic.TestSchematicTerraformVar {
@@ -257,12 +272,6 @@ func TestRunAgentVpcKubernetes(t *testing.T) {
257272
258273func TestAgentDefaultConfiguration (t * testing.T ) {
259274
260- /*
261- Skipping this test because auto-approve is not working as expected in projects
262- Config gets stuck in approved state and doesn't move to deployment
263- https://github.ibm.com/epx/projects/issues/4814
264- */
265- t .Skip ("Skipping because of projects issue" )
266275 t .Parallel ()
267276
268277 options := testaddons .TestAddonsOptionsDefault (& testaddons.TestAddonOptions {
@@ -276,28 +285,40 @@ func TestAgentDefaultConfiguration(t *testing.T) {
276285 "deploy-arch-ibm-logs-agent" ,
277286 "fully-configurable" ,
278287 map [string ]interface {}{
279- "region" : "eu-de" ,
280- "prefix" : options .Prefix ,
281- "secrets_manager_service_plan" : "trial" ,
288+ "region" : "eu-de" ,
289+ "prefix" : options .Prefix ,
282290 },
283291 )
284292
285- /*
286- Event notifications is manually disabled in this test because event notifications DA creates kms keys and during undeploy the order of key protect and event notifications
287- is not considered by projects as EN is not a direct dependency of VSI DA. So undeploy fails, because
288- key protect instance can't be deleted because of active keys created by EN. Hence for now, we don't want to deploy
289- EN.
290-
291- Issue has been created for projects team. https://github.ibm.com/epx/projects/issues/4750
292- Once that is fixed, we can remove the logic to disable EN
293- */
294293 options .AddonConfig .Dependencies = []cloudinfo.AddonConfig {
294+ // use existing secrets manager instance to help prevent hitting trial instance limit in account
295295 {
296- OfferingName : "deploy-arch-ibm-event-notifications " ,
296+ OfferingName : "deploy-arch-ibm-secrets-manager " ,
297297 OfferingFlavor : "fully-configurable" ,
298- Enabled : core .BoolPtr (false ), // explicitly disabled
298+ Inputs : map [string ]interface {}{
299+ "existing_secrets_manager_crn" : permanentResources ["privateOnlySecMgrCRN" ],
300+ "service_plan" : "__NULL__" , // no plan value needed when using existing SM
301+ "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
302+ "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
303+ },
304+ },
305+ // // Disable target / route creation to help prevent hitting quota in account
306+ {
307+ OfferingName : "deploy-arch-ibm-cloud-monitoring" ,
308+ OfferingFlavor : "fully-configurable" ,
309+ Inputs : map [string ]interface {}{
310+ "enable_metrics_routing_to_cloud_monitoring" : false ,
311+ },
312+ },
313+ {
314+ OfferingName : "deploy-arch-ibm-activity-tracker" ,
315+ OfferingFlavor : "fully-configurable" ,
316+ Inputs : map [string ]interface {}{
317+ "enable_activity_tracker_event_routing_to_cloud_logs" : false ,
318+ },
299319 },
300320 }
321+
301322 err := options .RunAddonTest ()
302323 require .NoError (t , err )
303324}
0 commit comments