|
15 | 15 | # limitations under the License. |
16 | 16 |
|
17 | 17 | set -euo pipefail |
| 18 | +source hack/lib.sh |
18 | 19 |
|
19 | | -# build the image(s) |
20 | | -export IMAGE_TAG=local |
| 20 | +# build the agent, we will start it many times during the tests |
| 21 | +echodate "Building the api-syncagent…" |
| 22 | +make build |
21 | 23 |
|
22 | | -echo "Building container images…" |
23 | | -# ARCHITECTURES=amd64 DRY_RUN=yes ./hack/ci/build-image.sh |
| 24 | +# get kube envtest binaries |
| 25 | +echodate "Setting up Kube binaries…" |
| 26 | +make _tools/setup-envtest |
| 27 | +export KUBEBUILDER_ASSETS="$(_tools/setup-envtest use 1.31.0 --bin-dir _tools -p path)" |
| 28 | +KUBEBUILDER_ASSETS="$(realpath "$KUBEBUILDER_ASSETS")" |
24 | 29 |
|
25 | | -# start docker so we can run kind |
26 | | -# start-docker.sh |
| 30 | +# start a shared kcp process |
| 31 | +make _tools/kcp |
27 | 32 |
|
28 | | -# create a local kind cluster |
29 | | -KIND_CLUSTER_NAME=e2e |
| 33 | +KCP_ROOT_DIRECTORY=.kcp.e2e |
| 34 | +KCP_LOGFILE=kcp.e2e.log |
30 | 35 |
|
31 | | -# echo "Preloading the kindest/node image…" |
32 | | -# docker load --input /kindest.tar |
| 36 | +echodate "Starting kcp…" |
| 37 | +rm -rf "$KCP_ROOT_DIRECTORY" "$KCP_LOGFILE" |
| 38 | +_tools/kcp start \ |
| 39 | + --root-directory "$KCP_ROOT_DIRECTORY" 1>"$KCP_LOGFILE" 2>&1 & |
33 | 40 |
|
34 | | -export KUBECONFIG=$(mktemp) |
35 | | -export KUBECONFIG=e2e.kubeconfig |
36 | | -echo "Creating kind cluster $KIND_CLUSTER_NAME…" |
37 | | -kind create cluster --name "$KIND_CLUSTER_NAME" |
38 | | -chmod 600 "$KUBECONFIG" |
| 41 | +stop_kcp() { |
| 42 | + echodate "Stopping kcp processes…" |
| 43 | + pkill -e kcp |
| 44 | +} |
| 45 | +append_trap stop_kcp EXIT |
39 | 46 |
|
40 | | -# load the agent image into the kind cluster |
41 | | -image="ghcr.io/kcp-dev/api-syncagent:$IMAGE_TAG" |
42 | | -archive=agent.tar |
| 47 | +# Wait for kcp to be ready; this env name is also hardcoded in the Go tests. |
| 48 | +export KCP_KUBECONFIG="$KCP_ROOT_DIRECTORY/admin.kubeconfig" |
43 | 49 |
|
44 | | -echo "Loading api-syncagent image into kind…" |
45 | | -buildah manifest push --all "$image" "oci-archive:$archive:$image" |
46 | | -kind load image-archive "$archive" --name "$KIND_CLUSTER_NAME" |
47 | | - |
48 | | -# deploy cert-manager |
49 | | -echo "Installing cert-manager…" |
50 | | - |
51 | | -helm repo add jetstack https://charts.jetstack.io |
52 | | -helm repo update |
53 | | - |
54 | | -kubectl apply --filename https://github.com/cert-manager/cert-manager/releases/download/v1.17.0/cert-manager.crds.yaml |
55 | | -helm install \ |
56 | | - --wait \ |
57 | | - --namespace cert-manager \ |
58 | | - --create-namespace \ |
59 | | - --version v1.17.0 \ |
60 | | - cert-manager jetstack/cert-manager |
61 | | - |
62 | | -# deploy a kcp which will live for the entire runtime of the e2e tests and be shared among all subtests |
63 | | -echo "Installing kcp into kind…" |
64 | | - |
65 | | -helm repo add kcp https://kcp-dev.github.io/helm-charts |
66 | | -helm repo update |
67 | | - |
68 | | -helm install \ |
69 | | - --wait \ |
70 | | - --namespace kcp \ |
71 | | - --create-namespace \ |
72 | | - --values hack/ci/testdata/kcp-kind-values.yaml \ |
73 | | - kcp-e2e kcp/kcp |
| 50 | +if ! retry_linear 3 20 kubectl --kubeconfig "$KCP_KUBECONFIG" get logicalcluster; then |
| 51 | + echodate "kcp never became ready." |
| 52 | + exit 1 |
| 53 | +fi |
74 | 54 |
|
75 | 55 | # time to run the tests |
76 | | -echo "Running e2e tests…" |
| 56 | +echodate "Running e2e tests…" |
77 | 57 | (set -x; go test -tags e2e -timeout 2h -v ./test/e2e/...) |
78 | 58 |
|
79 | | -echo "Done. :-)" |
| 59 | +echodate "Done. :-)" |
0 commit comments