Skip to content

Commit

Permalink
e2e(telemetry): Add e2e test with explicit addon configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
gansheer committed Sep 3, 2024
1 parent 8f9b49d commit ab94a48
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
22 changes: 22 additions & 0 deletions e2e/telemetry/files/int-rest-consumer-addon.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
kind: Integration
apiVersion: camel.apache.org/v1
metadata:
name: rest-consumer-addon
spec:
flows:
- rest:
get:
- path: /customers/{name}
to: direct:start
- from:
steps:
- log:
message: get ${header.name}
- setBody:
simple: ${header.name} Doe
uri: direct:start
traits:
addons:
telemetry:
enabled: true
endpoint: http://opentelemetrycollector.otlp:4317
30 changes: 30 additions & 0 deletions e2e/telemetry/telemetry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,33 @@ func TestTelemetryTrait(t *testing.T) {
g.Eventually(TailedLogs(t, ctx, pod.Namespace, pod.Name, 100), TestTimeoutLong).Should(ContainSubstring(fmt.Sprintf("http.url: Str(http://%s/customers/%s)", serviceName, name)))
})
}

func TestTelemetryAddon(t *testing.T) {
WithNewTestNamespace(t, func(ctx context.Context, g *WithT, ns string) {
// Check service is available
g.Eventually(ServicesByType(t, ctx, "otlp", corev1.ServiceTypeClusterIP), TestTimeoutLong).ShouldNot(BeEmpty())

// Create integration and activate traces by telemetry trait
ExpectExecSucceed(t, g, Kubectl("apply", "-f", "files/int-rest-consumer-addon.yaml", "-n", ns))
g.Eventually(IntegrationPodPhase(t, ctx, ns, "rest-consumer-addon"), TestTimeoutLong).Should(Equal(corev1.PodRunning))

name := "Alice"
serviceName := fmt.Sprintf("rest-consumer-addon.%s", ns)
g.Expect(KamelRun(t, ctx, ns, "files/rest-producer.yaml",
"-p", fmt.Sprintf("serviceName=%s", serviceName),
"-p", "name="+name,
"--name", "rest-producer").Execute()).To(Succeed())
g.Eventually(IntegrationPodPhase(t, ctx, ns, "rest-producer"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
g.Eventually(IntegrationLogs(t, ctx, ns, "rest-consumer-addon"), TestTimeoutLong).Should(ContainSubstring(fmt.Sprintf("get %s", name)))
g.Eventually(IntegrationLogs(t, ctx, ns, "rest-producer"), TestTimeoutLong).Should(ContainSubstring(fmt.Sprintf("%s Doe", name)))

// Find opentelemetry collector pod : the exporter is configured to log traces with detailed verbosity.
pod, err := Pod(t, ctx, "otlp", "opentelemetrycollector")()
g.Expect(err).To(BeNil())
g.Expect(pod).NotTo(BeNil())

// Ensured logs in opentelemetry collector pod are present
g.Eventually(TailedLogs(t, ctx, pod.Namespace, pod.Name, 100), TestTimeoutLong).Should(ContainSubstring(fmt.Sprintf("http.target: Str(/customers/%s)", name)))
g.Eventually(TailedLogs(t, ctx, pod.Namespace, pod.Name, 100), TestTimeoutLong).Should(ContainSubstring(fmt.Sprintf("http.url: Str(http://%s/customers/%s)", serviceName, name)))
})
}

0 comments on commit ab94a48

Please sign in to comment.