Skip to content

Commit a783c13

Browse files
Fix make test-e2e-local to run on mac and linux
1 parent c580bca commit a783c13

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

test/e2e/local.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,16 @@ if [ -z "${SKIP_KIND_CLEANUP:-}" ]; then
2323
trap delete_cluster EXIT
2424
fi
2525

26+
# Wait a moment for the cluster control plane to be fully initialized
27+
echo "Ensuring cluster is fully initialized..."
28+
sleep 5
29+
30+
# Export kubeconfig for the cluster
2631
kind export kubeconfig --kubeconfig $tmp_root/kubeconfig --name $KIND_CLUSTER
2732
export KUBECONFIG=$tmp_root/kubeconfig
2833

34+
# Verify we can communicate with the cluster
35+
kubectl cluster-info
36+
echo "Cluster is ready for testing"
37+
2938
test_cluster -v -ginkgo.v

test/e2e/setup.sh

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ function create_cluster {
3838
kind_config=$(dirname "$0")/kind-config-${version_prefix}.yaml
3939
fi
4040
echo "Creating cluster..."
41-
kind create cluster -v 4 --name $KIND_CLUSTER --retain --wait=1m --config ${kind_config} --image=kindest/node:$1
41+
kind create cluster -v 4 --name $KIND_CLUSTER --retain --wait=5m --config ${kind_config} --image=kindest/node:$1
42+
43+
echo "Waiting for cluster to be fully ready..."
44+
kubectl wait --for=condition=Ready nodes --all --timeout=5m
4245
fi
4346
}
4447

@@ -58,11 +61,27 @@ function delete_cluster {
5861
function test_cluster {
5962
local flags="$@"
6063

61-
docker pull memcached:1.6.26-alpine3.19
62-
kind load docker-image --name $KIND_CLUSTER memcached:1.6.26-alpine3.19
64+
# Detect the platform architecture for the kind cluster
65+
# Kind clusters now run natively on the host architecture (arm64 on Apple Silicon, amd64 on x86)
66+
local kind_platform="linux/amd64"
67+
if [[ "$OSTYPE" == "darwin"* ]] && [[ "$(uname -m)" == "arm64" ]]; then
68+
kind_platform="linux/arm64"
69+
elif [[ "$(uname -m)" == "aarch64" ]]; then
70+
kind_platform="linux/arm64"
71+
fi
72+
73+
# Pull images for the correct platform
74+
docker pull --platform ${kind_platform} memcached:1.6.26-alpine3.19
75+
docker pull --platform ${kind_platform} busybox:1.36.1
6376

64-
docker pull busybox:1.36.1
65-
kind load docker-image --name $KIND_CLUSTER busybox:1.36.1
77+
# Load images directly with ctr to avoid kind's --all-platforms issue
78+
# kind load docker-image uses --all-platforms internally which breaks with multi-platform manifests
79+
docker save memcached:1.6.26-alpine3.19 | docker exec -i $KIND_CLUSTER-control-plane ctr --namespace=k8s.io images import /dev/stdin
80+
81+
# Busybox has Docker save issues on some platforms, pull directly as fallback
82+
if ! docker save busybox:1.36.1 2>/dev/null | docker exec -i $KIND_CLUSTER-control-plane ctr --namespace=k8s.io images import /dev/stdin 2>/dev/null; then
83+
docker exec $KIND_CLUSTER-control-plane ctr --namespace=k8s.io images pull --platform ${kind_platform} docker.io/library/busybox:1.36.1 >/dev/null 2>&1
84+
fi
6685

6786
go test $(dirname "$0")/deployimage $flags -timeout 30m
6887
go test $(dirname "$0")/v4 $flags -timeout 30m

0 commit comments

Comments
 (0)