Skip to content

Commit cf793ea

Browse files
authored
Test built images in e2e (#31)
* Test built images in e2e * Review markups * Fix e2e by not pulling image if we loaded it
1 parent 540dd16 commit cf793ea

File tree

4 files changed

+52
-22
lines changed

4 files changed

+52
-22
lines changed

Makefile

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ IMAGE_NAMES = perf nginx ttfr tool
44
IMAGES_PATH = images
55
REGISTRY?=quay.io
66
ORGANISATION?=tigeradev
7+
VERSION?=v0.5.0
78
E2E_CLUSTER_NAME?=tb-e2e
89

910
.PHONY: all build test clean tool test-tool e2e-test clean-ttfr clean-e2e
@@ -13,16 +14,16 @@ all: build
1314
build: $(IMAGE_NAMES)
1415

1516
perf:
16-
docker build -t $(REGISTRY)/$(ORGANISATION)/tiger-bench-perf -f images/perf/Dockerfile .
17+
docker build -t $(REGISTRY)/$(ORGANISATION)/tiger-bench-perf:$(VERSION) -f images/perf/Dockerfile .
1718

1819
nginx:
19-
docker build -t $(REGISTRY)/$(ORGANISATION)/tiger-bench-nginx -f images/nginx/Dockerfile .
20+
docker build -t $(REGISTRY)/$(ORGANISATION)/tiger-bench-nginx:$(VERSION) -f images/nginx/Dockerfile .
2021

2122
ttfr:
22-
docker build -t $(REGISTRY)/$(ORGANISATION)/tiger-bench-ttfr -f images/ttfr/Dockerfile .
23+
docker build -t $(REGISTRY)/$(ORGANISATION)/tiger-bench-ttfr:$(VERSION) -f images/ttfr/Dockerfile .
2324

2425
tool:
25-
docker build -t $(REGISTRY)/$(ORGANISATION)/tiger-bench -f Dockerfile .
26+
docker build -t $(REGISTRY)/$(ORGANISATION)/tiger-bench:$(VERSION) -f Dockerfile .
2627

2728
test: $(addprefix test-,$(IMAGE_NAMES))
2829

@@ -41,21 +42,29 @@ test-ttfr:
4142
clean: clean-perf clean-nginx clean-ttfr clean-tool clean-e2e
4243

4344
clean-perf:
44-
docker rmi $(REGISTRY)/$(ORGANISATION)/tiger-bench-perf || true
45+
docker rmi $(REGISTRY)/$(ORGANISATION)/tiger-bench-perf:$(VERSION) || true
4546

4647
clean-nginx:
47-
docker rmi $(REGISTRY)/$(ORGANISATION)/tiger-bench-nginx || true
48+
docker rmi $(REGISTRY)/$(ORGANISATION)/tiger-bench-nginx:$(VERSION) || true
4849

4950
clean-ttfr:
50-
docker rmi $(REGISTRY)/$(ORGANISATION)/tiger-bench-ttfr || true
51+
docker rmi $(REGISTRY)/$(ORGANISATION)/tiger-bench-ttfr:$(VERSION) || true
5152

5253
clean-tool:
53-
docker rmi $(REGISTRY)/$(ORGANISATION)/tiger-bench || true
54+
docker rmi $(REGISTRY)/$(ORGANISATION)/tiger-bench:$(VERSION) || true
5455

5556
clean-e2e:
5657
kind delete cluster --name $(E2E_CLUSTER_NAME) || true
5758
@rm -f kubeconfig
5859

5960
e2e-test: build clean-e2e
60-
KIND_CLUSTER_NAME=$(E2E_CLUSTER_NAME) REGISTRY=$(REGISTRY) ORGANISATION=$(ORGANISATION) bash ./e2e-test.sh
61+
KIND_CLUSTER_NAME=$(E2E_CLUSTER_NAME) \
62+
REGISTRY=$(REGISTRY) \
63+
ORGANISATION=$(ORGANISATION) \
64+
VERSION=$(VERSION) \
65+
PERF_IMAGE=$(REGISTRY)/$(ORGANISATION)/tiger-bench-perf:$(VERSION) \
66+
WEBSERVER_IMAGE=$(REGISTRY)/$(ORGANISATION)/tiger-bench-nginx:$(VERSION) \
67+
TTFR_IMAGE=$(REGISTRY)/$(ORGANISATION)/tiger-bench-ttfr:$(VERSION) \
68+
TOOL_IMAGE=$(REGISTRY)/$(ORGANISATION)/tiger-bench:$(VERSION) \
69+
bash ./e2e-test.sh
6170
$(MAKE) clean-e2e

e2e-test.sh

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,16 @@ set -euox pipefail
77
KIND_CLUSTER_NAME="${KIND_CLUSTER_NAME:-tb-e2e}"
88
KUBECONFIG_PATH="${KUBECONFIG_PATH:-$(pwd)/kubeconfig}"
99
TEST_YAML="${TEST_YAML:-e2e-testconfig.yaml}"
10-
TOOL_IMAGE="${TOOL_IMAGE:-tiger-bench:v0.5.0}"
1110
CALICO_VERSION="${CALICO_VERSION:-v3.30.2}"
1211
REGISTRY="${REGISTRY:-quay.io}"
1312
ORGANISATION="${ORGANISATION:-tigeradev}"
13+
# VERSION can be set by the Makefile; default to v0.5.0 for local runs.
14+
VERSION="${VERSION:-v0.5.0}"
15+
# Default image names (Makefile will pass explicit image names including tags).
16+
TOOL_IMAGE="${TOOL_IMAGE:-$REGISTRY/$ORGANISATION/tiger-bench:${VERSION}}"
17+
PERF_IMAGE="${PERF_IMAGE:-$REGISTRY/$ORGANISATION/tiger-bench-perf:${VERSION}}"
18+
WEBSERVER_IMAGE="${WEBSERVER_IMAGE:-$REGISTRY/$ORGANISATION/tiger-bench-nginx:${VERSION}}"
19+
TTFR_IMAGE="${TTFR_IMAGE:-$REGISTRY/$ORGANISATION/tiger-bench-ttfr:${VERSION}}"
1420

1521
kind create cluster --kubeconfig "$KUBECONFIG_PATH" --config kind-config.yaml || true
1622

@@ -19,10 +25,18 @@ curl --retry 10 --retry-all-errors -sSL https://raw.githubusercontent.com/projec
1925
curl --retry 10 --retry-all-errors -sSL https://raw.githubusercontent.com/projectcalico/calico/$CALICO_VERSION/manifests/tigera-operator.yaml | kubectl --kubeconfig "$KUBECONFIG_PATH" apply --server-side --force-conflicts -f -
2026
curl --retry 10 --retry-all-errors -sSL https://raw.githubusercontent.com/projectcalico/calico/$CALICO_VERSION/manifests/custom-resources.yaml | kubectl --kubeconfig "$KUBECONFIG_PATH" apply --server-side --force-conflicts -f -
2127

22-
# Load test images into KinD nodes
23-
for img in tiger-bench-perf tiger-bench-nginx tiger-bench-ttfr; do
24-
docker image inspect "$REGISTRY/$ORGANISATION/$img:v0.5.0" >/dev/null 2>&1 || { echo "Image $img not found"; exit 1; }
25-
kind load docker-image "$REGISTRY/$ORGANISATION/$img:v0.5.0" --name "$KIND_CLUSTER_NAME"
28+
# Load test images into KinD nodes. The Makefile must pass the explicit
29+
# image names that were built; be strict and fail if an image is missing so
30+
# the test is explicit about what it's validating.
31+
images=("$WEBSERVER_IMAGE" "$PERF_IMAGE" "$TTFR_IMAGE")
32+
for img in "${images[@]}"; do
33+
if docker image inspect "$img" >/dev/null 2>&1; then
34+
kind load docker-image "$img" --name "$KIND_CLUSTER_NAME"
35+
else
36+
echo "Required image not found locally: $img"
37+
echo "Build the images via 'make build' or set the image variables when running this script."
38+
exit 1
39+
fi
2640
done
2741

2842
# Wait for nodes to be ready
@@ -37,14 +51,21 @@ kubectl --kubeconfig "$KUBECONFIG_PATH" wait --for=condition=Available tigerasta
3751

3852
# Run tiger-bench container with kubeconfig and test yaml
3953
# Assumes testconfig.yaml is present in the repo root
54+
# Require the exact tool image be present locally (Makefile must pass it).
55+
if ! docker image inspect "$TOOL_IMAGE" >/dev/null 2>&1; then
56+
echo "Tool image not found locally: $TOOL_IMAGE"
57+
echo "Build the tool image via 'make tool' or pass TOOL_IMAGE explicitly."
58+
exit 1
59+
fi
60+
4061
docker run --rm --net=host \
4162
-v "${PWD}":/results \
4263
-v "$KUBECONFIG_PATH:/kubeconfig:ro" \
43-
-v "$(pwd)/$TEST_YAML:/testconfig.yaml:ro" \
44-
-e WEBSERVER_IMAGE="$REGISTRY/$ORGANISATION/tiger-bench-nginx:v0.5.0" \
45-
-e PERF_IMAGE="$REGISTRY/$ORGANISATION/tiger-bench-perf:v0.5.0" \
46-
-e TTFR_IMAGE="$REGISTRY/$ORGANISATION/tiger-bench-ttfr:v0.5.0" \
47-
"$REGISTRY/$ORGANISATION/$TOOL_IMAGE"
64+
-v "${PWD}/$TEST_YAML:/testconfig.yaml:ro" \
65+
-e WEBSERVER_IMAGE="$WEBSERVER_IMAGE" \
66+
-e PERF_IMAGE="$PERF_IMAGE" \
67+
-e TTFR_IMAGE="$TTFR_IMAGE" \
68+
"$TOOL_IMAGE"
4869

4970
# Validate the results file
5071
go run validate_results.go

pkg/dnsperf/dnsperf.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ func makeDNSPerfPod(nodename string, namespace string, podname string, image str
564564
Drop: []corev1.Capability{"ALL"},
565565
},
566566
},
567-
ImagePullPolicy: corev1.PullAlways,
567+
ImagePullPolicy: corev1.PullIfNotPresent,
568568
},
569569
},
570570
NodeName: nodename,
@@ -663,7 +663,7 @@ func makeDeployment(namespace string, depname string, replicas int32, hostnetwor
663663
Protocol: corev1.ProtocolTCP,
664664
},
665665
},
666-
ImagePullPolicy: corev1.PullAlways,
666+
ImagePullPolicy: corev1.PullIfNotPresent,
667667
},
668668
},
669669
HostNetwork: hostnetwork,

pkg/iperf/iperf.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ func makePod(nodename string, namespace string, podname string, hostnetwork bool
352352
Drop: []corev1.Capability{"ALL"},
353353
},
354354
},
355-
ImagePullPolicy: corev1.PullAlways,
355+
ImagePullPolicy: corev1.PullIfNotPresent,
356356
Ports: []corev1.ContainerPort{
357357
{
358358
Name: "test-port",

0 commit comments

Comments
 (0)