generated from kyma-project/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 23
/
metrics_endpoint_path_validation_test.go
69 lines (54 loc) · 2.86 KB
/
metrics_endpoint_path_validation_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
//go:build e2e
package e2e
import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/kyma-project/telemetry-manager/internal/testutils"
kitk8s "github.com/kyma-project/telemetry-manager/test/testkit/k8s"
"github.com/kyma-project/telemetry-manager/test/testkit/suite"
)
var _ = Describe(suite.ID(), Label(suite.LabelMetrics), Ordered, func() {
metricPipelineDefaultGRPCWithPath := testutils.NewMetricPipelineBuilder().
WithName("metricpipeline-default-reject-with-path").
WithOTLPOutput(testutils.OTLPEndpoint("mock-endpoint:4817"), testutils.OTLPEndpointPath("/v1/mock/metrics")).
Build()
metricPipelineWithGRPCAndPath := testutils.NewMetricPipelineBuilder().
WithName("metricpipeline-reject-with-grpc-and-path").
WithOTLPOutput(testutils.OTLPEndpoint("mock-endpoint:4817"), testutils.OTLPEndpointPath("/v1/mock/metrics"), testutils.OTLPProtocol("grpc")).
Build()
metricPipelineWithGRPCAndWithoutPath := testutils.NewMetricPipelineBuilder().
WithName("metricpipeline-accept-with-grpc-and-no-path").
WithOTLPOutput(testutils.OTLPEndpoint("mock-endpoint:4817"), testutils.OTLPProtocol("grpc")).
Build()
metricPipelineWithHTTPAndPath := testutils.NewMetricPipelineBuilder().
WithName("metricpipeline-accept-with-http-and-path").
WithOTLPOutput(testutils.OTLPEndpoint("mock-endpoint:4817"), testutils.OTLPEndpointPath("/v1/mock/metrics"), testutils.OTLPProtocol("http")).
Build()
metricPipelineWithHTTPAndWithoutPath := testutils.NewMetricPipelineBuilder().
WithName("metricpipeline-accept-with-http-and-no-path").
WithOTLPOutput(testutils.OTLPEndpoint("mock-endpoint:4817"), testutils.OTLPProtocol("http")).
Build()
Context("When a MetricPipeline sets endpoint path", Ordered, func() {
BeforeAll(func() {
DeferCleanup(func() {
Expect(kitk8s.DeleteObjects(ctx, k8sClient,
&metricPipelineWithGRPCAndWithoutPath, &metricPipelineWithHTTPAndPath, &metricPipelineWithHTTPAndWithoutPath)).Should(Succeed())
})
})
It("Should reject a MetricPipeline with path and default protocol", func() {
Expect(kitk8s.CreateObjects(ctx, k8sClient, &metricPipelineDefaultGRPCWithPath)).ShouldNot(Succeed())
})
It("Should reject a MetricPipeline with path and gRPC protocol", func() {
Expect(kitk8s.CreateObjects(ctx, k8sClient, &metricPipelineWithGRPCAndPath)).ShouldNot(Succeed())
})
It("Should accept a MetricPipeline with no path and gRPC protocol", func() {
Expect(kitk8s.CreateObjects(ctx, k8sClient, &metricPipelineWithGRPCAndWithoutPath)).Should(Succeed())
})
It("Should accept a MetricPipeline with no path and HTTP protocol", func() {
Expect(kitk8s.CreateObjects(ctx, k8sClient, &metricPipelineWithHTTPAndWithoutPath)).Should(Succeed())
})
It("Should accept a MetricPipeline with path and HTTP protocol", func() {
Expect(kitk8s.CreateObjects(ctx, k8sClient, &metricPipelineWithHTTPAndPath)).Should(Succeed())
})
})
})