generated from kyma-project/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 23
/
metrics_secret_rotation_test.go
82 lines (69 loc) · 3.11 KB
/
metrics_secret_rotation_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//go:build e2e
package e2e
import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
appsv1 "k8s.io/api/apps/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
operatorv1alpha1 "github.com/kyma-project/telemetry-manager/apis/operator/v1alpha1"
"github.com/kyma-project/telemetry-manager/internal/conditions"
"github.com/kyma-project/telemetry-manager/internal/testutils"
"github.com/kyma-project/telemetry-manager/test/testkit/assert"
kitk8s "github.com/kyma-project/telemetry-manager/test/testkit/k8s"
kitkyma "github.com/kyma-project/telemetry-manager/test/testkit/kyma"
"github.com/kyma-project/telemetry-manager/test/testkit/periodic"
"github.com/kyma-project/telemetry-manager/test/testkit/suite"
)
var _ = Describe(suite.ID(), Label(suite.LabelMetrics), Ordered, func() {
Context("When a metricpipeline with missing secret reference exists", Ordered, func() {
var pipelineName = suite.ID()
endpointKey := "metrics-endpoint"
secret := kitk8s.NewOpaqueSecret("metrics-missing", kitkyma.DefaultNamespaceName, kitk8s.WithStringData(endpointKey, "http://localhost:4317"))
metricPipeline := testutils.NewMetricPipelineBuilder().
WithName(pipelineName).
WithOTLPOutput(testutils.OTLPEndpointFromSecret(secret.Name(), secret.Namespace(), endpointKey)).
Build()
BeforeAll(func() {
Expect(kitk8s.CreateObjects(ctx, k8sClient, &metricPipeline)).Should(Succeed())
DeferCleanup(func() {
Expect(kitk8s.DeleteObjects(ctx, k8sClient, &metricPipeline, secret.K8sObject())).Should(Succeed())
})
})
It("Should set ConfigurationGenerated condition to False", func() {
assert.MetricPipelineHasCondition(ctx, k8sClient, pipelineName, metav1.Condition{
Type: conditions.TypeConfigurationGenerated,
Status: metav1.ConditionFalse,
Reason: conditions.ReasonReferencedSecretMissing,
})
})
It("Should set TelemetryFlowHealthy condition to False", func() {
assert.MetricPipelineHasCondition(ctx, k8sClient, pipelineName, metav1.Condition{
Type: conditions.TypeFlowHealthy,
Status: metav1.ConditionFalse,
Reason: conditions.ReasonSelfMonConfigNotGenerated,
})
})
It("Should set MetricComponentsHealthy condition to False in Telemetry", func() {
assert.TelemetryHasState(ctx, k8sClient, operatorv1alpha1.StateWarning)
assert.TelemetryHasCondition(ctx, k8sClient, metav1.Condition{
Type: conditions.TypeMetricComponentsHealthy,
Status: metav1.ConditionFalse,
Reason: conditions.ReasonReferencedSecretMissing,
})
})
It("Should not have metric gateway deployment", func() {
Eventually(func(g Gomega) bool {
var deployment appsv1.Deployment
err := k8sClient.Get(ctx, kitkyma.MetricGatewayName, &deployment)
return apierrors.IsNotFound(err)
}, periodic.EventuallyTimeout, periodic.DefaultInterval).Should(BeTrue(), "Deployment still exists")
})
It("Should have running metricpipeline", func() {
By("Creating missing secret", func() {
Expect(kitk8s.CreateObjects(ctx, k8sClient, secret.K8sObject())).Should(Succeed())
})
assert.MetricPipelineHealthy(ctx, k8sClient, pipelineName)
})
})
})