Skip to content

Commit

Permalink
Use subtest labels for cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSpiritXIII committed Sep 25, 2023
1 parent 76fccb2 commit ba88d81
Show file tree
Hide file tree
Showing 6 changed files with 350 additions and 160 deletions.
19 changes: 14 additions & 5 deletions e2e/alertmanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ route:
receiver: "foobar"
`
secret := &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{Name: operator.AlertmanagerPublicSecretName},
ObjectMeta: metav1.ObjectMeta{
Name: operator.AlertmanagerPublicSecretName,
Labels: tctx.getSubTestLabels(),
},
Data: map[string][]byte{
operator.AlertmanagerPublicSecretKey: []byte(alertmanagerConfig),
},
Expand All @@ -67,7 +70,10 @@ route:
},
}
secret := &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{Name: "my-secret-name"},
ObjectMeta: metav1.ObjectMeta{
Name: "my-secret-name",
Labels: tctx.getSubTestLabels(),
},
Data: map[string][]byte{
"my-secret-key": []byte(alertmanagerConfig),
},
Expand All @@ -80,15 +86,17 @@ func testCreateAlertmanagerSecrets(ctx context.Context, t *OperatorContext, cert
secrets := []*corev1.Secret{
{
ObjectMeta: metav1.ObjectMeta{
Name: "alertmanager-authorization",
Name: "alertmanager-authorization",
Labels: t.getSubTestLabels(),
},
Data: map[string][]byte{
"token": []byte("auth-bearer-password"),
},
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "alertmanager-tls",
Name: "alertmanager-tls",
Labels: t.getSubTestLabels(),
},
Data: map[string][]byte{
"cert": cert,
Expand All @@ -108,7 +116,8 @@ func testAlertmanagerDeployed(spec *monitoringv1.ManagedAlertmanagerSpec) func(c
return func(ctx context.Context, t *OperatorContext) {
opCfg := &monitoringv1.OperatorConfig{
ObjectMeta: metav1.ObjectMeta{
Name: operator.NameOperatorConfig,
Name: operator.NameOperatorConfig,
Labels: t.getSubTestLabels(),
},
Collection: monitoringv1.CollectionSpec{
ExternalLabels: map[string]string{
Expand Down
10 changes: 6 additions & 4 deletions e2e/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ func testCollectorDeployed(ctx context.Context, t *OperatorContext) {
// Create initial OperatorConfig to trigger deployment of resources.
opCfg := &monitoringv1.OperatorConfig{
ObjectMeta: metav1.ObjectMeta{
Name: operator.NameOperatorConfig,
Name: operator.NameOperatorConfig,
Labels: t.getSubTestLabels(),
},
Collection: monitoringv1.CollectionSpec{
ExternalLabels: map[string]string{
Expand Down Expand Up @@ -165,7 +166,8 @@ func testCollectorSelfPodMonitoring(ctx context.Context, t *OperatorContext) {
// should show up in Cloud Monitoring shortly after.
podmon := &monitoringv1.PodMonitoring{
ObjectMeta: metav1.ObjectMeta{
Name: "collector-podmon",
Name: "collector-podmon",
Labels: t.getSubTestLabels(),
},
Spec: monitoringv1.PodMonitoringSpec{
Selector: metav1.LabelSelector{
Expand Down Expand Up @@ -232,8 +234,8 @@ func testCollectorSelfClusterPodMonitoring(ctx context.Context, t *OperatorConte
// should show up in Cloud Monitoring shortly after.
podmon := &monitoringv1.ClusterPodMonitoring{
ObjectMeta: metav1.ObjectMeta{
Name: "collector-cmon",
OwnerReferences: t.ownerReferences,
Name: "collector-cmon",
Labels: t.getSubTestLabels(),
},
Spec: monitoringv1.ClusterPodMonitoringSpec{
Selector: metav1.LabelSelector{
Expand Down
Loading

0 comments on commit ba88d81

Please sign in to comment.