Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"testing"
"time"

"github.com/onsi/gomega"
"github.com/stretchr/testify/assert"
"k8s.io/client-go/kubernetes"

Expand Down Expand Up @@ -176,71 +177,11 @@ spec:
- sh
- -c
- "exec tail -f /dev/null"`

zipkinTemplate = `
apiVersion: v1
kind: Namespace
metadata:
creationTimestamp: null
name: zipkin
spec: {}

---
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: zipkin
name: zipkin
namespace: zipkin
spec:
replicas: 1
selector:
matchLabels:
app: zipkin
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: zipkin
spec:
containers:
- image: openzipkin/zipkin
name: zipkin
env:
- name: "JAVA_OPTS"
value: "-Xmx500M"
resources:
limits:
memory: "700M"
requests:
memory: "500M"
---
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
app: zipkin
name: zipkin
namespace: zipkin
spec:
ports:
- port: 9411
protocol: TCP
targetPort: 9411
selector:
app: zipkin
type: ClusterIP
status:
loadBalancer: {}
`
)

func TestTraceGeneration(t *testing.T) {
// setup
gomega.RegisterTestingT(t)
t.Log("--- setting up ---")
// Create kubernetes resources
kc := GetKubernetesClient(t)
Expand All @@ -250,20 +191,14 @@ func TestTraceGeneration(t *testing.T) {
assert.True(t, WaitForDeploymentReplicaReadyCount(t, kc, deploymentName, testNamespace, minReplicaCount, 6, 10),
"replica count should be %d after 1 minutes", minReplicaCount)

assert.True(t, WaitForDeploymentReplicaReadyCount(t, kc, "zipkin", "zipkin", 1, 12, 10),
"zipkin replica count should be %d after 1 minutes", 1)

time.Sleep(5 * time.Second)

// Send a test request to the interceptor
sendLoad(t, kc, data)

// setting sleep for 15 sec so traces are sent over
time.Sleep(15 * time.Second)

// Fetch metrics and validate them
traces = fetchAndParseZipkinTraces(t, fmt.Sprintf("curl %s", otelCollectorZipKinURL))
assert.GreaterOrEqual(t, len(traces), 1)
gomega.Eventually(func() int {
traces = fetchAndParseZipkinTraces(t, fmt.Sprintf("curl %s", otelCollectorZipKinURL))
return len(traces)
}, 5*time.Minute, 5*time.Second).Should(gomega.BeNumerically(">", 0), "there should be at least 1 trace")

traceStatus := getTracesStatus(traces)
assert.EqualValues(t, "200", traceStatus)
Expand Down Expand Up @@ -321,7 +256,6 @@ func getTemplateData() (templateData, []Template) {
MinReplicas: minReplicaCount,
MaxReplicas: maxReplicaCount,
}, []Template{
{Name: "zipkinTemplate", Config: zipkinTemplate},
{Name: "deploymentTemplate", Config: deploymentTemplate},
{Name: "serviceNameTemplate", Config: serviceTemplate},
{Name: "clientTemplate", Config: clientTemplate},
Expand Down
2 changes: 1 addition & 1 deletion tests/run-all.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func executeTest(ctx context.Context, file string, timeout string, tries int) Te
for i := 1; i <= tries; i++ {
fmt.Printf("Executing %s, try '%d'\n", file, i)
cmd := exec.CommandContext(ctx, "go", "test", "-v", "-tags", "e2e", "-timeout", timeout, file)
stdout, err := cmd.Output()
stdout, err := cmd.CombinedOutput()
logFile := fmt.Sprintf("%s.%d.log", file, i)
fileError := os.WriteFile(logFile, stdout, 0644)
if fileError != nil {
Expand Down
70 changes: 69 additions & 1 deletion tests/utils/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,58 @@ spec:
allowedRoutes:
namespaces:
from: All
`
zipkinTemplate = `---
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: zipkin
name: zipkin
namespace: zipkin
spec:
replicas: 1
selector:
matchLabels:
app: zipkin
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: zipkin
spec:
containers:
- image: openzipkin/zipkin
name: zipkin
env:
- name: "JAVA_OPTS"
value: "-Xmx500M"
resources:
limits:
memory: "700M"
requests:
memory: "5M"
---
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
app: zipkin
name: zipkin
namespace: zipkin
spec:
ports:
- port: 9411
protocol: TCP
targetPort: 9411
selector:
app: zipkin
type: ClusterIP
status:
loadBalancer: {}
`
)

Expand Down Expand Up @@ -186,7 +238,7 @@ func TestSetupEnvoyGateway(t *testing.T) {
_, err := ExecuteCommand("helm version")
require.NoErrorf(t, err, "helm is not installed - %s", err)

_, err = ExecuteCommand(fmt.Sprintf("helm install %s oci://docker.io/envoyproxy/gateway-helm --version v1.0.2 -n %s --create-namespace", EnvoyReleaseName, EnvoyNamespace))
_, err = ExecuteCommand(fmt.Sprintf("helm install %s oci://docker.io/envoyproxy/gateway-helm --version v1.2.0 -n %s --create-namespace", EnvoyReleaseName, EnvoyNamespace))
require.NoErrorf(t, err, "cannot install envoy gateway - %s", err)

assert.True(t, WaitForDeploymentReplicaReadyCount(t, KubeClient, "envoy-gateway", "envoy-gateway-system", 1, 30, 6))
Expand Down Expand Up @@ -249,6 +301,22 @@ func TestSetupOpentelemetryComponents(t *testing.T) {
require.NoErrorf(t, err, "cannot update opentelemetry ports - %s", err)
}

func TestDeployZipkin(t *testing.T) {
KubeClient = GetKubernetesClient(t)
CreateNamespace(t, KubeClient, "zipkin")

zipkinTemplateFileName := "otlpServicePatch.yml"
defer os.Remove(zipkinTemplateFileName)
err := os.WriteFile(zipkinTemplateFileName, []byte(zipkinTemplate), 0755)
assert.NoErrorf(t, err, "cannot create otlp config file - %s", err)

_, err = ExecuteCommand(fmt.Sprintf("kubectl apply -f %s -n %s", zipkinTemplateFileName, "zipkin"))
require.NoErrorf(t, err, "cannot deploy zipkin - %s", err)

assert.True(t, WaitForDeploymentReplicaReadyCount(t, KubeClient, "zipkin", "zipkin", 1, 6, 5),
"replica count should be 1 after 3 minutes")
}

func TestSetupTLSConfiguration(t *testing.T) {
out, err := ExecuteCommandWithDir("make test-certs", "../..")
require.NoErrorf(t, err, "error generating test certs - %s", err)
Expand Down
Loading