From 7e9bc9710f3f5cf9763b583493f839174b7021f3 Mon Sep 17 00:00:00 2001 From: Dominik Rosiek Date: Tue, 11 Jul 2023 11:32:08 +0200 Subject: [PATCH 1/2] chore(chart): update tailing sidecar operator to 0.8.0 Signed-off-by: Dominik Rosiek --- .changelog/3145.changed.txt | 1 + deploy/helm/sumologic/Chart.yaml | 2 +- docs/README.md | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 .changelog/3145.changed.txt diff --git a/.changelog/3145.changed.txt b/.changelog/3145.changed.txt new file mode 100644 index 0000000000..430e423a15 --- /dev/null +++ b/.changelog/3145.changed.txt @@ -0,0 +1 @@ +chore(chart): update tailing sidecar operator to 0.8.0 \ No newline at end of file diff --git a/deploy/helm/sumologic/Chart.yaml b/deploy/helm/sumologic/Chart.yaml index 4a08c1a478..7792312827 100644 --- a/deploy/helm/sumologic/Chart.yaml +++ b/deploy/helm/sumologic/Chart.yaml @@ -33,7 +33,7 @@ dependencies: repository: https://helm.influxdata.com/ condition: telegraf-operator.enabled - name: tailing-sidecar-operator - version: 0.7.0 + version: 0.8.0 repository: https://sumologic.github.io/tailing-sidecar condition: tailing-sidecar-operator.enabled - name: opentelemetry-operator diff --git a/docs/README.md b/docs/README.md index 30a652602e..71f2520b85 100644 --- a/docs/README.md +++ b/docs/README.md @@ -108,7 +108,7 @@ The following table displays the currently used software versions for our Helm c | kube-prometheus-stack/Prometheus Operator | 40.5.0 | | Falco | 2.4.2 | | Telegraf Operator | 1.3.10 | -| Tailing Sidecar Operator | 0.5.5 | +| Tailing Sidecar Operator | 0.8.0 | | Fluentd | 1.15.3 | | Fluent Bit | 2.1.6 | From 067c3f6f143914c9cbbd6c8065f2ea65a04b2b69 Mon Sep 17 00:00:00 2001 From: Dominik Rosiek Date: Wed, 12 Jul 2023 10:06:23 +0200 Subject: [PATCH 2/2] test(integration): add tailing sidecar test Signed-off-by: Dominik Rosiek --- tests/integration/features.go | 57 +++++++++++--- .../integration/helm_tailing_sidecar_test.go | 21 +++++ tests/integration/internal/constants.go | 4 + .../values/values_helm_tailing_sidecar.yaml | 10 +++ .../yamls/tailing-sidecar-test.yaml | 76 +++++++++++++++++++ 5 files changed, 156 insertions(+), 12 deletions(-) create mode 100644 tests/integration/helm_tailing_sidecar_test.go create mode 100644 tests/integration/values/values_helm_tailing_sidecar.yaml create mode 100644 tests/integration/yamls/tailing-sidecar-test.yaml diff --git a/tests/integration/features.go b/tests/integration/features.go index 7c2c2d8dc8..c1dd779f96 100644 --- a/tests/integration/features.go +++ b/tests/integration/features.go @@ -31,18 +31,19 @@ import ( type MetricsCollector string const ( - tickDuration = 3 * time.Second - waitDuration = 1 * time.Minute - expectedEventCount uint = 50 // number determined experimentally - logsGeneratorCount uint = 1000 - logRecords = 4 // number of log records in single loop, see: tests/integration/yamls/pod_multiline_long_lines.yaml - logLoops = 500 // number of loops in which logs are generated, see: tests/integration/yamls/pod_multiline_long_lines.yaml - multilineLogCount uint = logRecords * logLoops - tracesPerExporter uint = 5 // number of traces generated per exporter - spansPerTrace uint = 2 - Prometheus MetricsCollector = "prometheus" - Otelcol MetricsCollector = "otelcol" - Fluentd MetricsCollector = "fluentd" + tickDuration = 3 * time.Second + waitDuration = 1 * time.Minute + expectedEventCount uint = 50 // number determined experimentally + logsGeneratorCount uint = 1000 + logRecords = 4 // number of log records in single loop, see: tests/integration/yamls/pod_multiline_long_lines.yaml + logLoops = 500 // number of loops in which logs are generated, see: tests/integration/yamls/pod_multiline_long_lines.yaml + multilineLogCount uint = logRecords * logLoops + tracesPerExporter uint = 5 // number of traces generated per exporter + spansPerTrace uint = 2 + Prometheus MetricsCollector = "prometheus" + Otelcol MetricsCollector = "otelcol" + Fluentd MetricsCollector = "fluentd" + TailingSidecarCount uint = 150 // number of logs generated by tailing sidecar test (50 * 3), see: tests/inegration/yamls/tailing-sidecar-test.yaml ) func GetMetricsFeature(expectedMetrics []string, metricsCollector MetricsCollector) features.Feature { @@ -482,6 +483,25 @@ func GetTracesFeature() features.Feature { Feature() } +func GetTailingSidecarFeature() features.Feature { + return features.New("tailing sidecar test"). + Setup(stepfuncs.KubectlApplyFOpt(internal.TailingSidecarTest, internal.TailingSidecarTestNamespace)). + Assess("tailing sidecar test logs present", stepfuncs.WaitUntilExpectedLogsPresent( + TailingSidecarCount, + map[string]string{ + "namespace": internal.TailingSidecarTestNamespace, + "deployment": internal.TailingSidecarTestDeploymentName, + }, + internal.ReceiverMockNamespace, + internal.ReceiverMockServiceName, + internal.ReceiverMockServicePort, + waitDuration, + tickDuration, + )). + Teardown(stepfuncs.KubectlDeleteFOpt(internal.TailingSidecarTest, internal.TailingSidecarTestNamespace)). + Feature() +} + type featureCheck func(*features.FeatureBuilder) *features.FeatureBuilder func GetInstallFeature(installChecks []featureCheck) features.Feature { @@ -877,3 +897,16 @@ func CheckFluentdEventsInstall(builder *features.FeatureBuilder) *features.Featu return ctx }) } + +func CheckTailingSidecarOperatorInstall(builder *features.FeatureBuilder) *features.FeatureBuilder { + return builder. + Assess("tailing sidecar deployment is ready", + stepfuncs.WaitUntilDeploymentIsReady( + waitDuration, + tickDuration, + stepfuncs.WithNameF( + stepfuncs.ReleaseFormatter("%s-tailing-sidecar-operator"), + ), + ), + ) +} diff --git a/tests/integration/helm_tailing_sidecar_test.go b/tests/integration/helm_tailing_sidecar_test.go new file mode 100644 index 0000000000..8b53c1ee36 --- /dev/null +++ b/tests/integration/helm_tailing_sidecar_test.go @@ -0,0 +1,21 @@ +//go:build onlylatest +// +build onlylatest + +package integration + +import ( + "testing" +) + +func Test_Helm_Tailing_Sidecar(t *testing.T) { + installChecks := []featureCheck{ + CheckOtelcolMetadataLogsInstall, + CheckTailingSidecarOperatorInstall, + } + + featInstall := GetInstallFeature(installChecks) + + featTailingSidecarTest := GetTailingSidecarFeature() + + testenv.Test(t, featInstall, featTailingSidecarTest) +} diff --git a/tests/integration/internal/constants.go b/tests/integration/internal/constants.go index 02e6073d6a..6765332d5b 100644 --- a/tests/integration/internal/constants.go +++ b/tests/integration/internal/constants.go @@ -37,6 +37,10 @@ const ( MultilineLogsPodName = "multiline-logs-generator" MultilineLogsGenerator = "yamls/multiline-logs-generator.yaml" + TailingSidecarTestNamespace = "tailing-sidecar" + TailingSidecarTest = "yamls/tailing-sidecar-test.yaml" + TailingSidecarTestDeploymentName = "test-tailing-sidecar-operator" + // useful regular expressions for matching metadata PodDeploymentSuffixRegex = "-[a-z0-9]{9,10}-[a-z0-9]{4,5}" // the Pod suffix for Deployments PodDaemonSetSuffixRegex = "-[a-z0-9]{4,5}" diff --git a/tests/integration/values/values_helm_tailing_sidecar.yaml b/tests/integration/values/values_helm_tailing_sidecar.yaml new file mode 100644 index 0000000000..e8915e765f --- /dev/null +++ b/tests/integration/values/values_helm_tailing_sidecar.yaml @@ -0,0 +1,10 @@ +sumologic: + events: + enabled: false + metrics: + enabled: false + traces: + enabled: false + +tailing-sidecar-operator: + enabled: true diff --git a/tests/integration/yamls/tailing-sidecar-test.yaml b/tests/integration/yamls/tailing-sidecar-test.yaml new file mode 100644 index 0000000000..a440a5d9a4 --- /dev/null +++ b/tests/integration/yamls/tailing-sidecar-test.yaml @@ -0,0 +1,76 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: tailing-sidecar +--- +apiVersion: tailing-sidecar.sumologic.com/v1 +kind: TailingSidecarConfig +metadata: + name: test-tailing-sidecar-operator + namespace: tailing-sidecar +spec: + podSelector: + matchLabels: + test-tailing-sidecar: "true" + configs: + test-sidecar: + volumeMount: + name: varlogconfig + mountPath: /varconfig/log + path: /varconfig/log/example2.log + annotations: + sourceCategory: test-sidecar +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: test-tailing-sidecar-operator + namespace: tailing-sidecar + labels: + app: test-tailing-sidecar-operator +spec: + replicas: 1 + selector: + matchLabels: + tailing-sidecar: "true" + test-tailing-sidecar: "true" + app: test-tailing-sidecar-operator + template: + metadata: + name: test-tailing-sidecar-operator + namespace: tailing-sidecar + annotations: + tailing-sidecar: varlog:/var/log/example0.log;named-container:varlog:/var/log/example1.log + labels: + tailing-sidecar: "true" + test-tailing-sidecar: "true" + app: test-tailing-sidecar-operator + spec: + containers: + - name: count + image: bash + args: + - /usr/local/bin/bash + - -c + - > + i=0; for i in {1..50}; do + echo "example0: $i $(date)" >> /var/log/example0.log; + echo "example1: $i $(date)" >> /var/log/example1.log; + echo "example2: $i $(date)" >> /varconfig/log/example2.log; + sleep 1; + done; while true; do + sleep 1; + done; + volumeMounts: + - name: varlog + mountPath: /var/log + - name: varlogconfig + mountPath: /varconfig/log + volumes: + - name: varlog + emptyDir: {} + - name: varlogconfig + emptyDir: {} + securityContext: + runAsUser: 1000