@@ -216,7 +216,7 @@ func TestAgentsSolutionInSchematics(t *testing.T) {
216216 }
217217}
218218
219- func TestRunExistingResourcesInstances (t * testing.T ) {
219+ func TestRunExistingResourcesInstancesSchematics (t * testing.T ) {
220220 t .Parallel ()
221221
222222 // ------------------------------------------------------------------------------------
@@ -244,100 +244,107 @@ func TestRunExistingResourcesInstances(t *testing.T) {
244244 "region" : region ,
245245 "resource_tags" : tags ,
246246 },
247- // Set Upgrade to true to ensure latest version of providers and modules are used by terratest.
248- // This is the same as setting the -upgrade=true flag with terraform.
249247 Upgrade : true ,
250248 })
251249
252250 terraform .WorkspaceSelectOrNew (t , existingTerraformOptions , prefix )
253251 _ , existErr := terraform .InitAndApplyE (t , existingTerraformOptions )
252+
253+ cloud_logs_existing_en_instances := []map [string ]interface {}{
254+ {
255+ "instance_crn" : terraform .Output (t , existingTerraformOptions , "en_crn_2" ),
256+ "integration_name" : "en-2" ,
257+ },
258+ }
259+
260+ cloud_logs_policies := []map [string ]interface {}{
261+ {
262+ "logs_policy_name" : "test-policy" ,
263+ "logs_policy_priority" : "type_low" ,
264+ "log_rules" : []map [string ]interface {}{
265+ {
266+ "severities" : []string {"info" },
267+ },
268+ },
269+ },
270+ }
271+
254272 if existErr != nil {
255273 assert .True (t , existErr == nil , "Init and Apply of temp existing resource failed" )
256274 } else {
257-
258- // ------------------------------------------------------------------------------------
259- // Deploy Observability instances DA passing in existing COS instance, and bucket details
260- // ------------------------------------------------------------------------------------
261-
262- options := testhelper .TestOptionsDefault (& testhelper.TestOptions {
263- Testing : t ,
264- TerraformDir : solutionInstanceDADir ,
265- // Do not hard fail the test if the implicit destroy steps fail to allow a full destroy of resource to occur
266- ImplicitRequired : false ,
267- Region : region ,
268- TerraformVars : map [string ]interface {}{
269- "prefix" : prefix ,
270- "cos_region" : region ,
271- "resource_group_name" : terraform .Output (t , existingTerraformOptions , "resource_group_name" ),
272- "use_existing_resource_group" : true ,
273- "existing_at_cos_target_bucket_name" : terraform .Output (t , existingTerraformOptions , "bucket_name_at" ),
274- "existing_at_cos_target_bucket_endpoint" : terraform .Output (t , existingTerraformOptions , "bucket_endpoint_at" ),
275- "existing_cos_instance_crn" : terraform .Output (t , existingTerraformOptions , "cos_crn" ),
276- "existing_cloud_logs_data_bucket_crn" : terraform .Output (t , existingTerraformOptions , "data_bucket_crn" ),
277- "existing_cloud_logs_data_bucket_endpoint" : terraform .Output (t , existingTerraformOptions , "data_bucket_endpoint" ),
278- "existing_cloud_logs_metrics_bucket_crn" : terraform .Output (t , existingTerraformOptions , "metrics_bucket_crn" ),
279- "existing_cloud_logs_metrics_bucket_endpoint" : terraform .Output (t , existingTerraformOptions , "metrics_bucket_endpoint" ),
280- "existing_en_instance_crn" : terraform .Output (t , existingTerraformOptions , "en_crn_1" ),
281- "cloud_logs_existing_en_instances" : []map [string ]interface {}{
282- {
283- "instance_crn" : terraform .Output (t , existingTerraformOptions , "en_crn_2" ),
284- "integration_name" : "en-2" ,
285- },
286- },
287- "management_endpoint_type_for_bucket" : "public" ,
288- "provider_visibility" : "public" ,
289- "enable_platform_metrics" : "false" ,
290- "enable_platform_logs" : "false" ,
291- "cloud_logs_policies" : []map [string ]interface {}{
292- {
293- "logs_policy_name" : "test-policy" ,
294- "logs_policy_priority" : "type_low" ,
295- "log_rules" : []map [string ]interface {}{
296- {
297- "severities" : []string {"info" },
298- },
299- },
300- },
301- },
275+ options := testschematic .TestSchematicOptionsDefault (& testschematic.TestSchematicOptions {
276+ Testing : t ,
277+ Prefix : "obs-ins-ext" ,
278+ TarIncludePatterns : []string {
279+ solutionInstanceDADir + "/*.*" ,
302280 },
281+ ResourceGroup : terraform .Output (t , existingTerraformOptions , "resource_group_name" ),
282+ TemplateFolder : solutionInstanceDADir ,
283+ Tags : []string {"test-schematic" },
284+ DeleteWorkspaceOnFail : false ,
285+ WaitJobCompleteMinutes : 60 ,
286+ Region : region ,
303287 })
304288
305- output , err := options .RunTestConsistency ()
289+ options .TerraformVars = []testschematic.TestSchematicTerraformVar {
290+ {Name : "ibmcloud_api_key" , Value : options .RequiredEnvironmentVars ["TF_VAR_ibmcloud_api_key" ], DataType : "string" , Secure : true },
291+ {Name : "cos_region" , Value : region , DataType : "string" },
292+ {Name : "resource_group_name" , Value : terraform .Output (t , existingTerraformOptions , "resource_group_name" ), DataType : "string" },
293+ {Name : "use_existing_resource_group" , Value : true , DataType : "bool" },
294+ {Name : "existing_cloud_logs_data_bucket_crn" , Value : terraform .Output (t , existingTerraformOptions , "data_bucket_crn" ), DataType : "string" },
295+ {Name : "existing_at_cos_target_bucket_name" , Value : terraform .Output (t , existingTerraformOptions , "bucket_name_at" ), DataType : "string" },
296+ {Name : "existing_at_cos_target_bucket_endpoint" , Value : terraform .Output (t , existingTerraformOptions , "bucket_endpoint_at" ), DataType : "string" },
297+ {Name : "existing_cloud_logs_data_bucket_endpoint" , Value : terraform .Output (t , existingTerraformOptions , "data_bucket_endpoint" ), DataType : "string" },
298+ {Name : "existing_cloud_logs_metrics_bucket_crn" , Value : terraform .Output (t , existingTerraformOptions , "metrics_bucket_crn" ), DataType : "string" },
299+ {Name : "existing_cloud_logs_metrics_bucket_endpoint" , Value : terraform .Output (t , existingTerraformOptions , "metrics_bucket_endpoint" ), DataType : "string" },
300+ {Name : "existing_en_instance_crn" , Value : terraform .Output (t , existingTerraformOptions , "en_crn_1" ), DataType : "string" },
301+ {Name : "prefix" , Value : options .Prefix , DataType : "string" },
302+ {Name : "management_endpoint_type_for_bucket" , Value : "private" , DataType : "string" },
303+ {Name : "provider_visibility" , Value : "public" , DataType : "string" },
304+ {Name : "enable_platform_metrics" , Value : false , DataType : "bool" },
305+ {Name : "enable_platform_logs" , Value : false , DataType : "bool" },
306+ {Name : "cloud_logs_existing_en_instances" , Value : cloud_logs_existing_en_instances , DataType : "list(object)" },
307+ {Name : "cloud_logs_policies" , Value : cloud_logs_policies , DataType : "list(object)" },
308+ {Name : "existing_cos_instance_crn" , Value : terraform .Output (t , existingTerraformOptions , "cos_crn" ), DataType : "string" },
309+ }
310+
311+ err := options .RunSchematicTest ()
306312 assert .Nil (t , err , "This should not have errored" )
307- assert .NotNil (t , output , "Expected some output" )
308313
309- // ------------------------------------------------------------------------------------
310- // Deploy Observability instance DA passing in existing COS instance (not bucket), and KMS key
311- // ------------------------------------------------------------------------------------
312-
313- options2 := testhelper .TestOptionsDefault (& testhelper.TestOptions {
314- Testing : t ,
315- TerraformDir : solutionInstanceDADir ,
316- // Do not hard fail the test if the implicit destroy steps fail to allow a full destroy of resource to occur
317- ImplicitRequired : false ,
318- TerraformVars : map [string ]interface {}{
319- "prefix" : prefix ,
320- "cos_region" : region ,
321- "resource_group_name" : terraform .Output (t , existingTerraformOptions , "resource_group_name" ),
322- "use_existing_resource_group" : true ,
323- "existing_kms_instance_crn" : permanentResources ["hpcs_south_crn" ],
324- "existing_cos_kms_key_crn" : permanentResources ["hpcs_south_root_key_crn" ],
325- "kms_endpoint_type" : "public" ,
326- "provider_visibility" : "public" ,
327- "existing_cos_instance_crn" : terraform .Output (t , existingTerraformOptions , "cos_crn" ),
328- "management_endpoint_type_for_bucket" : "public" ,
329- "enable_platform_metrics" : "false" ,
330- "enable_platform_logs" : "false" ,
314+ options2 := testschematic .TestSchematicOptionsDefault (& testschematic.TestSchematicOptions {
315+ Testing : t ,
316+ Prefix : "obs-ext" ,
317+ TarIncludePatterns : []string {
318+ solutionInstanceDADir + "/*.*" ,
331319 },
320+ ResourceGroup : terraform .Output (t , existingTerraformOptions , "resource_group_name" ),
321+ TemplateFolder : solutionInstanceDADir ,
322+ Tags : []string {"test-schematic" },
323+ DeleteWorkspaceOnFail : false ,
324+ WaitJobCompleteMinutes : 60 ,
325+ Region : region ,
332326 })
333327
334- output2 , err := options2 .RunTestConsistency ()
328+ options2 .TerraformVars = []testschematic.TestSchematicTerraformVar {
329+ {Name : "ibmcloud_api_key" , Value : options2 .RequiredEnvironmentVars ["TF_VAR_ibmcloud_api_key" ], DataType : "string" , Secure : true },
330+ {Name : "cos_region" , Value : region , DataType : "string" },
331+ {Name : "prefix" , Value : options2 .Prefix , DataType : "string" },
332+ {Name : "resource_group_name" , Value : terraform .Output (t , existingTerraformOptions , "resource_group_name" ), DataType : "string" },
333+ {Name : "use_existing_resource_group" , Value : true , DataType : "bool" },
334+ {Name : "kms_endpoint_type" , Value : "private" , DataType : "string" },
335+ {Name : "existing_cos_instance_crn" , Value : terraform .Output (t , existingTerraformOptions , "cos_crn" ), DataType : "string" },
336+ {Name : "management_endpoint_type_for_bucket" , Value : "private" , DataType : "string" },
337+ {Name : "enable_platform_metrics" , Value : false , DataType : "bool" },
338+ {Name : "enable_platform_logs" , Value : false , DataType : "bool" },
339+ {Name : "existing_kms_instance_crn" , Value : permanentResources ["hpcs_south_crn" ], DataType : "string" },
340+ {Name : "existing_cos_kms_key_crn" , Value : permanentResources ["hpcs_south_root_key_crn" ], DataType : "string" },
341+ }
342+
343+ err = options2 .RunSchematicTest ()
335344 assert .Nil (t , err , "This should not have errored" )
336- assert .NotNil (t , output2 , "Expected some output" )
337345
338346 }
339347
340- // Check if "DO_NOT_DESTROY_ON_FAILURE" is set
341348 envVal , _ := os .LookupEnv ("DO_NOT_DESTROY_ON_FAILURE" )
342349 // Destroy the temporary existing resources if required
343350 if t .Failed () && strings .ToLower (envVal ) == "true" {
0 commit comments