From d209c1e3c8934f54cd50c9abf2defc816845b12d Mon Sep 17 00:00:00 2001 From: venkataanil Date: Wed, 7 Dec 2022 23:52:09 +0530 Subject: [PATCH] Add aws tags to cluster (#99) * start cluster name with pocm Use pocm- in cluster and service names instead of perf-. This allows us to identify and remove any stale resources generated by ocm-api-load. * Add aws tags to cluster Add aws tags to clusters created by create-cluster, create-services and patch-services tests. --- pkg/tests/handlers/clusters.go | 8 ++++++-- pkg/tests/handlers/services.go | 16 ++++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/pkg/tests/handlers/clusters.go b/pkg/tests/handlers/clusters.go index f3119f8..587b68c 100644 --- a/pkg/tests/handlers/clusters.go +++ b/pkg/tests/handlers/clusters.go @@ -55,8 +55,11 @@ func generateCreateClusterTargeter(ctx context.Context, ID, method, url string, fakeClusterProps := map[string]string{ "fake_cluster": "true", } + awsTags := map[string]string{ + "User": "pocm-perf", + } body, err := v1.NewCluster(). - Name(fmt.Sprintf("perf-%s-%d", id, idx)). + Name(fmt.Sprintf("pocm-%s-%d", id, idx)). Properties(fakeClusterProps). MultiAZ(true). Region(v1.NewCloudRegion().ID(ccsRegion)). @@ -65,7 +68,8 @@ func generateCreateClusterTargeter(ctx context.Context, ID, method, url string, v1.NewAWS(). AccessKeyID(ccsAccessKey). SecretAccessKey(ccsSecretKey). - AccountID(ccsAccountID), + AccountID(ccsAccountID). + Tags(awsTags), ). Build() if err != nil { diff --git a/pkg/tests/handlers/services.go b/pkg/tests/handlers/services.go index bcce057..27c7b63 100644 --- a/pkg/tests/handlers/services.go +++ b/pkg/tests/handlers/services.go @@ -60,17 +60,21 @@ func generateCreateServiceTargeter(ctx context.Context, ID, method, url string, "rosa_creator_arn": arn, "fake_cluster": "true", } + awsTags := map[string]string{ + "User": "pocm-perf", + } body, err := v1.NewManagedService(). Service("ocm-addon-test-operator"). Parameters(v1.NewServiceParameter().ID("has-external-resources").Value("false")). Cluster(v1.NewCluster(). - Name(fmt.Sprintf("perf-%s-%d", id, idx)). + Name(fmt.Sprintf("pocm-%s-%d", id, idx)). AWS( v1.NewAWS(). AccessKeyID(ccsAccessKey). SecretAccessKey(ccsSecretKey). - AccountID(ccsAccountID), + AccountID(ccsAccountID). + Tags(awsTags), ). Nodes(v1.NewClusterNodes().AvailabilityZones(fmt.Sprintf("%sa", ccsRegion))). Properties(creatorProps). @@ -123,6 +127,9 @@ func TestPatchService(ctx context.Context, options *types.TestOptions) error { "rosa_creator_arn": arn, "fake_cluster": "true", } + awsTags := map[string]string{ + "User": "pocm-perf", + } // Register multiple mock Services and store their IDs options.Logger.Info(ctx, "Registering 2 Services to use for patch requests test") @@ -132,12 +139,13 @@ func TestPatchService(ctx context.Context, options *types.TestOptions) error { Service("ocm-addon-test-operator"). Parameters(v1.NewServiceParameter().ID("has-external-resources").Value("false")). Cluster(v1.NewCluster(). - Name(fmt.Sprintf("perf-%s-%d", id, i)). + Name(fmt.Sprintf("pocm-%s-%d", id, i)). AWS( v1.NewAWS(). AccessKeyID(ccsAccessKey). SecretAccessKey(ccsSecretKey). - AccountID(ccsAccountID), + AccountID(ccsAccountID). + Tags(awsTags), ). Nodes(v1.NewClusterNodes().AvailabilityZones(fmt.Sprintf("%sa", ccsRegion))). Properties(creatorProps).