diff --git a/.github/actions/kind/action.yml b/.github/actions/kind/action.yml index 268c48a51..59dcafef7 100644 --- a/.github/actions/kind/action.yml +++ b/.github/actions/kind/action.yml @@ -47,3 +47,12 @@ runs: echo "KinD cluster:" kubectl cluster-info kubectl describe nodes + + - name: Install Ingress controller + shell: bash + run: | + VERSION=controller-v1.6.4 + echo "Deploying Ingress controller into KinD cluster" + curl https://raw.githubusercontent.com/kubernetes/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 - + kubectl annotate ingressclass nginx "ingressclass.kubernetes.io/is-default-class=true" + kubectl -n ingress-nginx wait --timeout=300s --for=condition=Available deployments --all diff --git a/Makefile b/Makefile index c6115a28e..d47bb2130 100644 --- a/Makefile +++ b/Makefile @@ -447,6 +447,10 @@ test-unit: defaults manifests generate fmt vet envtest ## Run unit tests. test-e2e: defaults manifests generate fmt vet ## Run e2e tests. go test -timeout 30m -v ./test/e2e +.PHONY: kind-e2e +setup-e2e: ## Set up e2e KinD cluster. + test/e2e/kind.sh + .PHONY: setup-e2e setup-e2e: ## Set up e2e tests. KUBERAY_VERSION=$(KUBERAY_VERSION) test/e2e/setup.sh diff --git a/README.md b/README.md index e5f25443e..014af62f1 100644 --- a/README.md +++ b/README.md @@ -25,11 +25,15 @@ The e2e tests can be executed locally by running the following commands: ```bash # Create a KinD cluster - $ kind create cluster --image kindest/node:v1.25.8 + $ make kind-e2e # Install the CRDs $ make install ``` + [!NOTE] + 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. + For it to work on macOS, this requires installing [docker-mac-net-connect](https://github.com/chipmk/docker-mac-net-connect). + 2. Start the operator locally: ```bash diff --git a/test/e2e/kind.sh b/test/e2e/kind.sh new file mode 100755 index 000000000..5b39a164e --- /dev/null +++ b/test/e2e/kind.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# Copyright 2022 IBM, Red Hat +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -euo pipefail +: "${INGRESS_NGINX_VERSION:=controller-v1.6.4}" + +echo "Creating KinD cluster" +cat <