From 5022d5c5700f6546325507e239c1600ced3431ee Mon Sep 17 00:00:00 2001 From: Antoine Toulme Date: Thu, 5 Oct 2023 10:59:08 -0700 Subject: [PATCH] wip --- .github/workflows/e2e.yaml | 5 ----- e2e_tests/e2e_test.go | 24 +++++++++++++++++++++++- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index a7e15b5829..c07fc58c1b 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -45,11 +45,6 @@ jobs: - name: Fix kubelet TLS server certificates run: | kubectl get csr -o=jsonpath='{range.items[?(@.spec.signerName=="kubernetes.io/kubelet-serving")]}{.metadata.name}{" "}{end}' | xargs kubectl certificate approve - - name: Download artifact - uses: actions/download-artifact@v3 - with: - name: nodejs_test - path: /tmp - name: Build Node.js docker image run: | cd e2e_tests/testdata/nodejs diff --git a/e2e_tests/e2e_test.go b/e2e_tests/e2e_test.go index c9f58f1aa2..3c36c32035 100644 --- a/e2e_tests/e2e_test.go +++ b/e2e_tests/e2e_test.go @@ -40,7 +40,10 @@ const testKubeConfig = "/tmp/kube-config-splunk-otel-collector-chart-e2e-testing // TestTracesReception tests the chart with a real k8s cluster. // Run the following command prior to running the test locally: // -// kind create cluster --kubeconfig=/tmp/kube-config-splunk-otel-collector-chart-e2e-testing +// kind create cluster --kubeconfig=/tmp/kube-config-splunk-otel-collector-chart-e2e-testing +// cd e2e_tests/testdata/nodejs +// docker build -t nodejs_test:latest . +// kind load docker-image nodejs_test:latest --name kind func TestTracesReception(t *testing.T) { // cannot patch "sock-splunk-otel-collector" with kind Instrumentation: Internal error occurred: failed calling webhook "minstrumentation.kb.io": failed to call webhook: Post "https://sock-operator-webhook.default.svc:443/mutate-opentelemetry-io-v1alpha1-instrumentation?timeout=10s": dial tcp 10.96.245.118:443: connect: connection refused t.Skip("Issue with deploying the operator on kind, skipping") @@ -263,6 +266,25 @@ func waitForMetrics(t *testing.T, entriesNum int, mc *consumertest.MetricsSink) "failed to receive %d entries, received %d metrics in %d minutes", entriesNum, len(mc.AllMetrics()), timeoutMinutes) } + +func waitForLogs(t *testing.T, entriesNum int, lc *consumertest.LogsSink) { + f := otlpreceiver.NewFactory() + cfg := f.CreateDefaultConfig().(*otlpreceiver.Config) + + rcvr, err := f.CreateLogsReceiver(context.Background(), receivertest.NewNopCreateSettings(), cfg, lc) + require.NoError(t, rcvr.Start(context.Background(), componenttest.NewNopHost())) + require.NoError(t, err, "failed creating logs receiver") + defer func() { + assert.NoError(t, rcvr.Shutdown(context.Background())) + }() + + timeoutMinutes := 3 + require.Eventuallyf(t, func() bool { + return len(lc.AllLogs()) > entriesNum + }, time.Duration(timeoutMinutes)*time.Minute, 1*time.Second, + "failed to receive %d entries, received %d logs in %d minutes", entriesNum, + len(lc.AllLogs()), timeoutMinutes) +} func hostEndpoint(t *testing.T) string { if runtime.GOOS == "darwin" { return "host.docker.internal"