Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Add basic e2e tests for v1beta1 version #893

Merged
merged 35 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
70cbe38
rename NewLogPipeline to NewLogPipelinev1alpha1 in testkit
shorim Mar 14, 2024
558d2d0
Rename existing LogPipeline in testkit/k8s pkg to logPipelinev1alpha1
shorim Mar 14, 2024
4b43fde
create new logPipelinev1beta1 in testkit/k8s pkg
shorim Mar 14, 2024
d98a58f
rename mockBackend.HostSecretRef() to mockBackend.HostSecretRefv1alph…
shorim Mar 14, 2024
16dd085
consider v1alpha1 and v1beta1 for SecretKeyRef
shorim Mar 14, 2024
26efab7
add logs basic test for v1beta1 version
shorim Mar 14, 2024
e439edf
add telemetryv1beta1 alias in golangci
shorim Mar 14, 2024
3ebe5c0
add ignore duplication for linting
shorim Mar 14, 2024
4022b10
change location of nolint for duplication
shorim Mar 14, 2024
81b068d
add nolint for duplication also in logPipelineV1Alpha1 builder
shorim Mar 14, 2024
b1272fa
add telemetryv1beta1 to scheme in e2e test suite
shorim Mar 14, 2024
e09f496
rename logPipelinev1alpha1 to logPipelineV1Alpha1
shorim Mar 14, 2024
9ca2293
rename NewLogPipelinev1alpha1 to NewLogPipelineV1Alpha1
shorim Mar 14, 2024
e6a8f51
rename logPipelinev1beta1 to logPipelineV1Beta1
shorim Mar 14, 2024
899e32c
rename NewLogPipelinev1beta1 to NewLogPipelineV1Beta1
shorim Mar 14, 2024
eefec5a
rename SecretKeyRefv1alpha1 to SecretKeyRefV1Alpha1
shorim Mar 14, 2024
1005b75
rename SecretKeyRefv1beta1 to SecretKeyRefV1Beta1
shorim Mar 14, 2024
e511c1b
rename HostSecretRefv1alpha1 to HostSecretRefV1Alpha1
shorim Mar 14, 2024
bc1c0d7
rename HostSecretRefv1beta1 to HostSecretRefV1Beta1
shorim Mar 14, 2024
d00a963
setup label-filter in GitHub actions
shorim Mar 14, 2024
c4e7cf7
rename TracePipeline to tracePipelineV1Alpha1 in testkit
shorim Mar 14, 2024
ca90f39
rename NewTracePipeline to NewTracePipelineV1Alpha1
shorim Mar 14, 2024
3d2bdd1
add tracePipelineV1Beta1 in testkit
shorim Mar 14, 2024
d6e0c56
rename file of existing traces basic test
shorim Mar 14, 2024
f16cf6d
add new traces basic v1beta1 test
shorim Mar 14, 2024
a9ae8ae
ensure that basic tests run in different namespaces for different ver…
shorim Mar 14, 2024
c556367
add nolint for duplication in tracePipline builders
shorim Mar 14, 2024
c31fdbe
rename MetricPipeline to metricPipelineV1Alpha1
shorim Mar 14, 2024
758ff47
rename NewMetricPipeline to NewMetricPipelineV1Alpha1
shorim Mar 14, 2024
b3642f7
add metricPipelineV1Beta1 in testkit
shorim Mar 14, 2024
3ee7a48
rename file of existing metrics basic test
shorim Mar 14, 2024
06d8b3e
add new metrics basic v1beta1 test
shorim Mar 14, 2024
9f34c08
do not run v1beta1 tests as upgrade tests
shorim Mar 15, 2024
12d640c
Merge remote-tracking branch 'origin/main' into e2e_test_for_v1beta1_…
shorim Mar 15, 2024
3b94445
restore old mockBackendName and mockNs for v1alpha1 basic tests
shorim Mar 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/pr-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Run tests
run: bin/ginkgo run --tags e2e --label-filter="metrics" test/e2e
run: bin/ginkgo run --tags e2e --label-filter="metrics && !v1beta1" test/e2e

- name: Finalize test
uses: "./.github/template/finalize-test"
Expand Down Expand Up @@ -68,7 +68,7 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Run tests
run: bin/ginkgo run --tags e2e --label-filter="traces" test/e2e
run: bin/ginkgo run --tags e2e --label-filter="traces && !v1beta1" test/e2e

- name: Finalize Test
uses: "./.github/template/finalize-test"
Expand Down Expand Up @@ -109,7 +109,7 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Run tests
run: bin/ginkgo run --tags e2e --label-filter="logs" test/e2e
run: bin/ginkgo run --tags e2e --label-filter="logs && !v1beta1" test/e2e

- name: Finalize Test
uses: "./.github/template/finalize-test"
Expand Down Expand Up @@ -150,7 +150,7 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Run tests
run: bin/ginkgo run --tags e2e --label-filter="telemetry" test/e2e
run: bin/ginkgo run --tags e2e --label-filter="telemetry && !v1beta1" test/e2e

- name: Finalize Test
uses: "./.github/template/finalize-test"
Expand Down
2 changes: 2 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ linters-settings:
alias: operatorv1alpha1
- pkg: github.com/kyma-project/telemetry-manager/apis/telemetry/v1alpha1
alias: telemetryv1alpha1
- pkg: github.com/kyma-project/telemetry-manager/apis/telemetry/v1beta1
alias: telemetryv1beta1
- pkg: github.com/kyma-project/telemetry-manager/controllers/telemetry
alias: telemetrycontrollers
- pkg: github.com/kyma-project/telemetry-manager/internal/otelcollector/config/metric/agent
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/logs_annotation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ var _ = Describe("Logs Keep Annotations", Label("logs"), Ordered, func() {
objs = append(objs, mockLogProducer.K8sObject(kitk8s.WithLabel("app", "logging-annotation-test")))
telemetryExportURL = mockBackend.TelemetryExportURL(proxyClient)

logPipeline := kitk8s.NewLogPipeline(pipelineName).
WithSecretKeyRef(mockBackend.HostSecretRef()).
logPipeline := kitk8s.NewLogPipelineV1Alpha1(pipelineName).
WithSecretKeyRef(mockBackend.HostSecretRefV1Alpha1()).
WithHTTPOutput().
KeepAnnotations(true).
DropLabels(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import (
"github.com/kyma-project/telemetry-manager/test/testkit/verifiers"
)

var _ = Describe("Logs Basic", Label("logs"), Ordered, func() {
var _ = Describe("Logs Basic v1alpha1", Label("logs"), Ordered, func() {
const (
mockBackendName = "log-receiver"
mockNs = "log-http-output"
mockNs = "logs-basic-v1alpha1-test"
logProducerName = "log-producer-http-output" //#nosec G101 -- This is a false positive
pipelineName = "http-output-pipeline"
)
Expand All @@ -33,8 +33,8 @@ var _ = Describe("Logs Basic", Label("logs"), Ordered, func() {
objs = append(objs, mockLogProducer.K8sObject(kitk8s.WithLabel("app", "logging-test")))
telemetryExportURL = mockBackend.TelemetryExportURL(proxyClient)

logPipeline := kitk8s.NewLogPipeline(pipelineName).
WithSecretKeyRef(mockBackend.HostSecretRef()).
logPipeline := kitk8s.NewLogPipelineV1Alpha1(pipelineName).
WithSecretKeyRef(mockBackend.HostSecretRefV1Alpha1()).
WithHTTPOutput().
Persistent(isOperational())
objs = append(objs, logPipeline.K8sObject())
Expand Down
75 changes: 75 additions & 0 deletions test/e2e/logs_basic_v1beta1_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
//go:build e2e

package e2e

import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"

kitk8s "github.com/kyma-project/telemetry-manager/test/testkit/k8s"
"github.com/kyma-project/telemetry-manager/test/testkit/mocks/backend"
"github.com/kyma-project/telemetry-manager/test/testkit/mocks/loggen"
"github.com/kyma-project/telemetry-manager/test/testkit/verifiers"
)

var _ = Describe("Logs Basic v1beta1", Label("logs", "v1beta1"), Ordered, func() {
const (
mockBackendName = "log-receiver"
mockNs = "logs-basic-v1beta1-test"
logProducerName = "log-producer-http-output" //#nosec G101 -- This is a false positive
pipelineName = "http-output-pipeline"
)
var telemetryExportURL string

makeResources := func() []client.Object {
var objs []client.Object
objs = append(objs, kitk8s.NewNamespace(mockNs).K8sObject())

mockBackend := backend.New(mockBackendName, mockNs, backend.SignalTypeLogs)
mockLogProducer := loggen.New(logProducerName, mockNs)
objs = append(objs, mockBackend.K8sObjects()...)
objs = append(objs, mockLogProducer.K8sObject(kitk8s.WithLabel("app", "logging-test")))
telemetryExportURL = mockBackend.TelemetryExportURL(proxyClient)

logPipeline := kitk8s.NewLogPipelineV1Beta1(pipelineName).
WithSecretKeyRef(mockBackend.HostSecretRefV1Beta1()).
WithHTTPOutput()
objs = append(objs, logPipeline.K8sObject())

return objs
}

Context("Before deploying a logpipeline", func() {
It("Should have a healthy webhook", func() {
verifiers.WebhookShouldBeHealthy(ctx, k8sClient)
})
})

Context("When a logpipeline with HTTP output exists", Ordered, func() {
BeforeAll(func() {
k8sObjects := makeResources()
DeferCleanup(func() {
Expect(kitk8s.DeleteObjects(ctx, k8sClient, k8sObjects...)).Should(Succeed())
})
Expect(kitk8s.CreateObjects(ctx, k8sClient, k8sObjects...)).Should(Succeed())
})

It("Should have a running logpipeline", func() {
verifiers.LogPipelineShouldBeHealthy(ctx, k8sClient, pipelineName)
})

It("Should have a log backend running", func() {
verifiers.DeploymentShouldBeReady(ctx, k8sClient, types.NamespacedName{Namespace: mockNs, Name: mockBackendName})
})

It("Should have a log producer running", func() {
verifiers.DeploymentShouldBeReady(ctx, k8sClient, types.NamespacedName{Namespace: mockNs, Name: logProducerName})
})

It("Should have produced logs in the backend", func() {
verifiers.LogsShouldBeDelivered(proxyClient, logProducerName, telemetryExportURL)
})
})
})
2 changes: 1 addition & 1 deletion test/e2e/logs_custom_output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var _ = Describe("Logs Custom Output", Label("logs"), Ordered, func() {
objs = append(objs, mockLogProducer.K8sObject(kitk8s.WithLabel("app", "logging-test")))
telemetryExportURL = mockBackend.TelemetryExportURL(proxyClient)

logPipeline := kitk8s.NewLogPipeline(pipelineName).WithCustomOutput(mockBackend.ExternalService.Host())
logPipeline := kitk8s.NewLogPipelineV1Alpha1(pipelineName).WithCustomOutput(mockBackend.ExternalService.Host())
objs = append(objs, logPipeline.K8sObject())

return objs
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/logs_dedot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ var _ = Describe("Logs Dedot", Label("logs"), Ordered, func() {
objs = append(objs, mockLogProducer.K8sObject(kitk8s.WithLabel("dedot.label", "logging-dedot-value")))
telemetryExportURL = mockBackend.TelemetryExportURL(proxyClient)

logPipeline := kitk8s.NewLogPipeline(pipelineName).
WithSecretKeyRef(mockBackend.HostSecretRef()).
logPipeline := kitk8s.NewLogPipelineV1Alpha1(pipelineName).
WithSecretKeyRef(mockBackend.HostSecretRefV1Alpha1()).
WithHTTPOutput().
WithIncludeContainers([]string{logProducerName})
objs = append(objs, logPipeline.K8sObject())
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/logs_exclude_container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ var _ = Describe("Logs Exclude Container", Label("logs"), Ordered, func() {
objs = append(objs, mockLogProducer.K8sObject(kitk8s.WithLabel("app", "logging-exclude-container")))
telemetryExportURL = mockBackend.TelemetryExportURL(proxyClient)

logPipeline := kitk8s.NewLogPipeline(pipelineName).
WithSecretKeyRef(mockBackend.HostSecretRef()).
logPipeline := kitk8s.NewLogPipelineV1Alpha1(pipelineName).
WithSecretKeyRef(mockBackend.HostSecretRefV1Alpha1()).
WithHTTPOutput().
WithExcludeContainers([]string{logProducerName})
objs = append(objs, logPipeline.K8sObject())
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/logs_exclude_namespaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ var _ = Describe("Logs Exclude Namespace", Label("logs"), Ordered, func() {
objs = append(objs, mockLogProducer.K8sObject(kitk8s.WithLabel("app", "logging-exclude-namespace")))
telemetryExportURL = mockBackend.TelemetryExportURL(proxyClient)

logPipeline := kitk8s.NewLogPipeline(pipelineName).
WithSecretKeyRef(mockBackend.HostSecretRef()).
logPipeline := kitk8s.NewLogPipelineV1Alpha1(pipelineName).
WithSecretKeyRef(mockBackend.HostSecretRefV1Alpha1()).
WithHTTPOutput().
WithExcludeNamespaces([]string{kitkyma.SystemNamespaceName})
objs = append(objs, logPipeline.K8sObject())
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/logs_include_namespaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ var _ = Describe("Logs Include Namespaces", Label("logs"), Ordered, func() {
objs = append(objs, mockLogProducer.K8sObject(kitk8s.WithLabel("app", "logging-include-namespaces")))
telemetryExportURL = mockBackend.TelemetryExportURL(proxyClient)

logPipeline := kitk8s.NewLogPipeline(pipelineName).
WithSecretKeyRef(mockBackend.HostSecretRef()).
logPipeline := kitk8s.NewLogPipelineV1Alpha1(pipelineName).
WithSecretKeyRef(mockBackend.HostSecretRefV1Alpha1()).
WithHTTPOutput().
WithIncludeNamespaces([]string{kitkyma.SystemNamespaceName, mockNs})
objs = append(objs, logPipeline.K8sObject())
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/logs_label_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ var _ = Describe("Logs Drop Labels", Label("logs"), Ordered, func() {
objs = append(objs, mockLogProducer.K8sObject(kitk8s.WithLabel("app", "logging-label-test")))
telemetryExportURL = mockBackend.TelemetryExportURL(proxyClient)

logPipeline := kitk8s.NewLogPipeline(pipelineName).
WithSecretKeyRef(mockBackend.HostSecretRef()).
logPipeline := kitk8s.NewLogPipelineV1Alpha1(pipelineName).
WithSecretKeyRef(mockBackend.HostSecretRefV1Alpha1()).
WithHTTPOutput().
KeepAnnotations(false).
DropLabels(false)
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/logs_mtls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ var _ = Describe("Logs mTLS", Label("logs"), Ordered, func() {
objs = append(objs, mockLogProducer.K8sObject(kitk8s.WithLabel("app", "logging-mtls-test")))
telemetryExportURL = mockBackend.TelemetryExportURL(proxyClient)

pipeline := kitk8s.NewLogPipeline(pipelineName).
WithSecretKeyRef(mockBackend.HostSecretRef()).
pipeline := kitk8s.NewLogPipelineV1Alpha1(pipelineName).
WithSecretKeyRef(mockBackend.HostSecretRefV1Alpha1()).
WithHTTPOutput().
WithTLS(mockBackend.TLSCerts)

Expand Down
4 changes: 2 additions & 2 deletions test/e2e/logs_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ var _ = Describe("Logs Parser", Label("logs"), Ordered, func() {
objs = append(objs, mockLogProducer.K8sObject(kitk8s.WithLabel("app", "regex-parser-testing-service")))
telemetryExportURL = mockBackend.TelemetryExportURL(proxyClient)

logHTTPPipeline := kitk8s.NewLogPipeline(pipelineName).
WithSecretKeyRef(mockBackend.HostSecretRef()).
logHTTPPipeline := kitk8s.NewLogPipelineV1Alpha1(pipelineName).
WithSecretKeyRef(mockBackend.HostSecretRefV1Alpha1()).
WithHTTPOutput()

parser := `Format regex
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/logs_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ var _ = Describe("Logs Validating Webhook", Label("logs"), Ordered, func() {
})

It("Should reject a logpipeline with unknown custom filter", func() {
logPipeline := kitk8s.NewLogPipeline("unknown-custom-filter-pipeline").WithStdout().WithFilter("Name unknown")
logPipeline := kitk8s.NewLogPipelineV1Alpha1("unknown-custom-filter-pipeline").WithStdout().WithFilter("Name unknown")
Expect(kitk8s.CreateObjects(ctx, k8sClient, logPipeline.K8sObject())).ShouldNot(Succeed())
})

It("Should reject a logpipeline with denied custom filter", func() {
logPipeline := kitk8s.NewLogPipeline("denied-custom-filter-pipeline").WithStdout().WithFilter("Name kubernetes")
logPipeline := kitk8s.NewLogPipelineV1Alpha1("denied-custom-filter-pipeline").WithStdout().WithFilter("Name kubernetes")
Expect(kitk8s.CreateObjects(ctx, k8sClient, logPipeline.K8sObject())).ShouldNot(Succeed())
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import (
"github.com/kyma-project/telemetry-manager/test/testkit/verifiers"
)

var _ = Describe("Metrics Basic", Label("metrics"), func() {
var _ = Describe("Metrics Basic v1alpha1", Label("metrics"), func() {
const (
mockBackendName = "metric-receiver"
mockNs = "metric-mocks"
mockBackendName = "metrics-receiver"
mockNs = "metrics-basic-v1alpha1-test"
)

var (
Expand All @@ -44,8 +44,8 @@ var _ = Describe("Metrics Basic", Label("metrics"), func() {
objs = append(objs, mockBackend.K8sObjects()...)
telemetryExportURL = mockBackend.TelemetryExportURL(proxyClient)

metricPipeline := kitk8s.NewMetricPipeline(fmt.Sprintf("%s-pipeline", mockBackend.Name())).
WithOutputEndpointFromSecret(mockBackend.HostSecretRef()).
metricPipeline := kitk8s.NewMetricPipelineV1Alpha1(fmt.Sprintf("%s-pipeline", mockBackend.Name())).
WithOutputEndpointFromSecret(mockBackend.HostSecretRefV1Alpha1()).
Persistent(isOperational())
pipelineName = metricPipeline.Name()
objs = append(objs, metricPipeline.K8sObject())
Expand Down
Loading
Loading