Skip to content

Commit bc4b46a

Browse files
astefanuttiopenshift-merge-robot
authored andcommitted
e2e: Add kind-e2e target to setup test KinD cluster
1 parent 81e8f81 commit bc4b46a

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,10 @@ test-unit: defaults manifests generate fmt vet envtest ## Run unit tests.
448448
test-e2e: defaults manifests generate fmt vet ## Run e2e tests.
449449
go test -timeout 30m -v ./test/e2e
450450

451+
.PHONY: kind-e2e
452+
setup-e2e: ## Set up e2e KinD cluster.
453+
test/e2e/kind.sh
454+
451455
.PHONY: setup-e2e
452456
setup-e2e: ## Set up e2e tests.
453457
KUBERAY_VERSION=$(KUBERAY_VERSION) test/e2e/setup.sh

README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,15 @@ The e2e tests can be executed locally by running the following commands:
2525

2626
```bash
2727
# Create a KinD cluster
28-
$ kind create cluster --image kindest/node:v1.25.8
28+
$ make kind-e2e
2929
# Install the CRDs
3030
$ make install
3131
```
3232

33+
[!NOTE]
34+
Some e2e tests cover the access to services via Ingresses, as end-users would do, which requires access to the Ingress controller load balancer by its IP.
35+
For it to work on macOS, this requires installing [docker-mac-net-connect](https://github.com/chipmk/docker-mac-net-connect).
36+
3337
2. Start the operator locally:
3438

3539
```bash

test/e2e/kind.sh

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
3+
# Copyright 2022 IBM, Red Hat
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -euo pipefail
18+
: "${INGRESS_NGINX_VERSION:=controller-v1.6.4}"
19+
20+
echo "Creating KinD cluster"
21+
cat <<EOF | kind create cluster --config=-
22+
kind: Cluster
23+
apiVersion: kind.x-k8s.io/v1alpha4
24+
nodes:
25+
- role: control-plane
26+
image: kindest/node:v1.25.3@sha256:f52781bc0d7a19fb6c405c2af83abfeb311f130707a0e219175677e366cc45d1
27+
kubeadmConfigPatches:
28+
- |
29+
kind: InitConfiguration
30+
nodeRegistration:
31+
kubeletExtraArgs:
32+
node-labels: "ingress-ready=true"
33+
EOF
34+
35+
echo "Deploying Ingress controller into KinD cluster"
36+
curl https://raw.githubusercontent.com/kubernetes/ingress-nginx/"${INGRESS_NGINX_VERSION}"/deploy/static/provider/kind/deploy.yaml | sed "s/--publish-status-address=localhost/--report-node-internal-ip-address\\n - --status-update-interval=10/g" | kubectl apply -f -
37+
kubectl annotate ingressclass nginx "ingressclass.kubernetes.io/is-default-class=true"
38+
kubectl -n ingress-nginx wait --timeout=300s --for=condition=Available deployments --all

0 commit comments

Comments
 (0)