Skip to content

Commit

Permalink
e2e: Add kind-e2e target to setup test KinD cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
astefanutti authored and openshift-merge-robot committed Aug 8, 2023
1 parent 81e8f81 commit bc4b46a
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,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
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 38 additions & 0 deletions test/e2e/kind.sh
Original file line number Diff line number Diff line change
@@ -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 <<EOF | kind create cluster --config=-
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
image: kindest/node:v1.25.3@sha256:f52781bc0d7a19fb6c405c2af83abfeb311f130707a0e219175677e366cc45d1
kubeadmConfigPatches:
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
EOF

echo "Deploying Ingress controller into KinD cluster"
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 -
kubectl annotate ingressclass nginx "ingressclass.kubernetes.io/is-default-class=true"
kubectl -n ingress-nginx wait --timeout=300s --for=condition=Available deployments --all

0 comments on commit bc4b46a

Please sign in to comment.