Skip to content

Commit

Permalink
Add aws tags to cluster (cloud-bulldozer#99)
Browse files Browse the repository at this point in the history
* start cluster name with pocm

Use pocm-<uudi> in cluster and service names instead of perf-<uuid>.
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.
  • Loading branch information
venkataanil authored Dec 7, 2022
1 parent b4b1b2e commit d209c1e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
8 changes: 6 additions & 2 deletions pkg/tests/handlers/clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)).
Expand All @@ -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 {
Expand Down
16 changes: 12 additions & 4 deletions pkg/tests/handlers/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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")
Expand All @@ -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).
Expand Down

0 comments on commit d209c1e

Please sign in to comment.