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 4, 2024
1 parent 6d67fde commit 2792ba3
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
39 changes: 39 additions & 0 deletions e2e/telemetry/files/int-rest-consumer-addon.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# ---------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ---------------------------------------------------------------------------

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-addon").Execute()).To(Succeed())
g.Eventually(IntegrationPodPhase(t, ctx, ns, "rest-producer-addon"), 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-addon"), 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 2792ba3

Please sign in to comment.