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

feat: add e2e tests for tailing-sidecar-otel #625

Merged
merged 2 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
54 changes: 45 additions & 9 deletions .github/workflows/pull_requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,26 @@ jobs:
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: '1.20'
go-version: '1.21'
cache-dependency-path: |
.otelcol-builder.yaml
.goreleaser.yaml
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Install opentelemetry-collector-builder
working-directory: ./sidecar/otelcol
run: make install-builder
- uses: imranismail/setup-kustomize@v2
- name: Install kuttl
run: |
curl -Lo /usr/local/bin/kubectl-kuttl https://github.com/kudobuilder/kuttl/releases/download/v${{ env.KUTTL_VERSION }}/kubectl-kuttl_${{ env.KUTTL_VERSION }}_linux_x86_64
chmod +x /usr/local/bin/kubectl-kuttl
- name: Run Helm e2e tests
run: make e2e-helm
- name: Run Helm e2e tests for Fluent Bit in tailing sidecar
run: make e2e-helm TAILING_SIDECAR=fluentbit
- name: Run Helm e2e tests for otelcol in tailing sidecar
run: make e2e-helm TAILING_SIDECAR=otelcol

test-helm-chart-with-cert-manager:
name: Test Helm chart with cert-manager
Expand All @@ -115,14 +127,26 @@ jobs:
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: '1.20'
go-version: '1.21'
cache-dependency-path: |
sidecar/otelcol/.otelcol-builder.yaml
sidecar/otelcol/.goreleaser.yaml
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Install opentelemetry-collector-builder
working-directory: ./sidecar/otelcol
run: make install-builder
- uses: imranismail/setup-kustomize@v2
- name: Install kuttl
run: |
curl -Lo /usr/local/bin/kubectl-kuttl https://github.com/kudobuilder/kuttl/releases/download/v${{ env.KUTTL_VERSION }}/kubectl-kuttl_${{ env.KUTTL_VERSION }}_linux_x86_64
chmod +x /usr/local/bin/kubectl-kuttl
- name: Run e2e tests
run: make e2e-helm-certmanager
- name: Run Helm e2e tests for Fluent Bit in tailing sidecar
run: make e2e-helm-certmanager TAILING_SIDECAR=fluentbit
- name: Run Helm e2e tests for otelcol in tailing sidecar
run: make e2e-helm-certmanager TAILING_SIDECAR=otelcol

test-helm-chart-with-custom-configuration:
name: Test Helm chart with custom configuration
Expand All @@ -133,11 +157,23 @@ jobs:
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: '1.20'
go-version: '1.21'
cache-dependency-path: |
sidecar/otelcol/.otelcol-builder.yaml
sidecar/otelcol/.goreleaser.yaml
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Install opentelemetry-collector-builder
working-directory: ./sidecar/otelcol
run: make install-builder
- uses: imranismail/setup-kustomize@v2
- name: Install kuttl
run: |
curl -Lo /usr/local/bin/kubectl-kuttl https://github.com/kudobuilder/kuttl/releases/download/v${{ env.KUTTL_VERSION }}/kubectl-kuttl_${{ env.KUTTL_VERSION }}_linux_x86_64
chmod +x /usr/local/bin/kubectl-kuttl
- name: Run e2e tests
run: make e2e-helm-custom-configuration
- name: Run Helm e2e tests for Fluent Bit in tailing sidecar
run: make e2e-helm-custom-configuration TAILING_SIDECAR=fluentbit
- name: Run Helm e2e tests for otelcol in tailing sidecar
run: make e2e-helm-custom-configuration TAILING_SIDECAR=otelcol
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ NAMESPACE ?= tailing-sidecar-system
RELEASE ?= tailing-sidecar
HELM_CHART ?= helm/tailing-sidecar-operator
KUTTL_CONFIG ?= kuttl-test.yaml
TAILING_SIDECAR ?= fluentbit

all: markdownlint yamllint

Expand All @@ -26,7 +27,7 @@ login-ecr:
e2e: IMG="registry.localhost:5000/sumologic/tailing-sidecar-operator:test"
e2e: TAILING_SIDECAR_IMG = "registry.localhost:5000/sumologic/tailing-sidecar:test"
e2e:
$(MAKE) -C ./sidecar/fluentbit build TAG=$(TAILING_SIDECAR_IMG)
$(MAKE) -C ./sidecar/$(TAILING_SIDECAR) build-test-image TAG=$(TAILING_SIDECAR_IMG)
$(MAKE) -C ./operator docker-build IMG=$(IMG) TAILING_SIDECAR_IMG=$(TAILING_SIDECAR_IMG)
kubectl-kuttl test --config $(KUTTL_CONFIG)

Expand All @@ -39,7 +40,7 @@ e2e-helm-certmanager: KUTTL_CONFIG = kuttl-test-helm-certmanager.yaml
e2e-helm-certmanager: e2e

.PHONY: e2e-helm-custom-configuration
e2e-helm-custom-configuration: KUTTL_CONFIG = kuttl-test-helm-custom-configuration.yaml
e2e-helm-custom-configuration: KUTTL_CONFIG = kuttl-test-helm-$(TAILING_SIDECAR)-custom-configuration.yaml
e2e-helm-custom-configuration: e2e

# We sleep for 10 seconds here because webhooks can mysteriously be unavailable even though the readiness check passes
Expand Down
53 changes: 53 additions & 0 deletions helm/tests/values.withOtelcolCustomConfiguration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
operator:
image:
repository: registry.localhost:5000/sumologic/tailing-sidecar-operator
tag: test

sidecar:
image:
repository: registry.localhost:5000/sumologic/tailing-sidecar
tag: test

resources:
limits:
cpu: "0"
memory: "0"
requests:
cpu: "0"
memory: "0"

config:
content:
mountPath: /etc/otel/
config.yaml: |
receivers:
filelog:
include:
- ${PATH_TO_TAIL}
start_at: beginning
storage: file_storage

exporters:
file:
path: /dev/stdout
encoding: text_encoding

extensions:
text_encoding:
file_storage:
directory: /var/lib/otc

service:
extensions:
- text_encoding
- file_storage
telemetry:
metrics:
level: none
logs:
output_paths:
- /var/log/otelcol.log
pipelines:
logs:
exporters: [file]
receivers: [filelog]
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ kindContainers:
- registry.localhost:5000/sumologic/tailing-sidecar-operator:test
- registry.localhost:5000/sumologic/tailing-sidecar:test
commands:
- command: helm upgrade --install test-release ./helm/tailing-sidecar-operator -f ./helm/tests/values.withCustomConfiguration.yaml -n tailing-sidecar-system --create-namespace
- command: helm upgrade --install test-release ./helm/tailing-sidecar-operator -f ./helm/tests/values.withFluentBitCustomConfiguration.yaml -n tailing-sidecar-system --create-namespace
- command: make e2e-wait-until-operator-ready
16 changes: 16 additions & 0 deletions kuttl-test-helm-otelcol-custom-configuration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: kuttl.dev/v1beta1
kind: TestSuite
artifactsDir: ./tests/_build/artifacts/
testDirs:
- ./tests/sidecar/
- ./tests/operator/
timeout: 150
parallel: 4
startKIND: true
kindNodeCache: true
kindContainers:
- registry.localhost:5000/sumologic/tailing-sidecar-operator:test
- registry.localhost:5000/sumologic/tailing-sidecar:test
commands:
- command: helm upgrade --install test-release ./helm/tailing-sidecar-operator -f ./helm/tests/values.withOtelcolCustomConfiguration.yaml -n tailing-sidecar-system --create-namespace
- command: make e2e-wait-until-operator-ready
2 changes: 2 additions & 0 deletions sidecar/fluentbit/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ all: build push
build:
docker build --tag $(TAG) --file Dockerfile .

build-test-image: build

run: build
docker run --rm -it \
-v $(DIR_TO_TAIL):/tmp/host \
Expand Down
7 changes: 6 additions & 1 deletion sidecar/otelcol/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ GO ?= go

OS ?= $(shell uname -s | tr A-Z a-z)
ARCH ?= $(shell uname -m | sed s/aarch64/arm64/ | sed s/x86_64/amd64/)
LOCALBIN ?= ./bin
LOCALBIN ?= $(shell pwd)/bin

GORELEASER ?= $(LOCALBIN)/goreleaser

Expand Down Expand Up @@ -71,6 +71,11 @@ release-dev: ensure-correct-builder-version install-goreleaser
release: ensure-correct-builder-version install-goreleaser
@$(GORELEASER) release --clean

.PHONY: build-test-image
build-test-image: GHCR_IMAGE = ghcr.io/sumologic/tailing-sidecar-otel
build-test-image: build
docker tag $(GHCR_IMAGE):main-$(ARCH) $(TAG)

.PHONY: generate-sources
generate-sources:
$(BUILDER) \
Expand Down
Loading