Skip to content

Commit f7a3226

Browse files
astefanuttiopenshift-merge-robot
authored andcommitted
Initial e2e tests
1 parent 88cd476 commit f7a3226

16 files changed

+777
-4
lines changed

.github/workflows/e2e_tests.yaml

+180
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
name: e2e
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
- 'release-*'
8+
paths-ignore:
9+
- 'docs/**'
10+
- '**.adoc'
11+
- '**.md'
12+
- 'LICENSE'
13+
push:
14+
branches:
15+
- main
16+
- 'release-*'
17+
paths-ignore:
18+
- 'docs/**'
19+
- '**.adoc'
20+
- '**.md'
21+
- 'LICENSE'
22+
23+
concurrency:
24+
group: ${{ github.head_ref }}-${{ github.workflow }}
25+
cancel-in-progress: true
26+
27+
jobs:
28+
kubernetes:
29+
30+
runs-on: ubuntu-20.04
31+
32+
steps:
33+
- name: Cleanup
34+
run: |
35+
ls -lart
36+
echo "Initial status:"
37+
df -h
38+
39+
echo "Cleaning up resources:"
40+
sudo swapoff -a
41+
sudo rm -f /swapfile
42+
sudo apt clean
43+
sudo rm -rf /usr/share/dotnet
44+
sudo rm -rf /opt/ghc
45+
sudo rm -rf "/usr/local/share/boost"
46+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
47+
docker rmi $(docker image ls -aq)
48+
49+
echo "Final status:"
50+
df -h
51+
52+
- name: Checkout code
53+
uses: actions/checkout@v3
54+
with:
55+
submodules: recursive
56+
57+
- name: Init directories
58+
run: |
59+
TEMP_DIR="$(pwd)/tmp"
60+
mkdir -p "${TEMP_DIR}"
61+
echo "TEMP_DIR=${TEMP_DIR}" >> $GITHUB_ENV
62+
63+
mkdir -p "$(pwd)/bin"
64+
echo "$(pwd)/bin" >> $GITHUB_PATH
65+
66+
- name: Set Go
67+
uses: actions/setup-go@v3
68+
with:
69+
go-version: v1.18
70+
71+
- name: Container image registry
72+
run: |
73+
podman run -d -p 5000:5000 --name registry registry:2.8.1
74+
75+
export REGISTRY_ADDRESS=$(hostname -i):5000
76+
echo "REGISTRY_ADDRESS=${REGISTRY_ADDRESS}" >> $GITHUB_ENV
77+
echo "Container image registry started at ${REGISTRY_ADDRESS}"
78+
79+
KIND_CONFIG_FILE=${{ env.TEMP_DIR }}/kind.yaml
80+
echo "KIND_CONFIG_FILE=${KIND_CONFIG_FILE}" >> $GITHUB_ENV
81+
envsubst < ./test/e2e/kind.yaml > ${KIND_CONFIG_FILE}
82+
83+
sudo --preserve-env=REGISTRY_ADDRESS sh -c 'cat > /etc/containers/registries.conf.d/local.conf <<EOF
84+
[[registry]]
85+
prefix = "$REGISTRY_ADDRESS"
86+
insecure = true
87+
location = "$REGISTRY_ADDRESS"
88+
EOF'
89+
90+
- name: Setup KinD cluster
91+
uses: helm/[email protected]
92+
with:
93+
name: cluster
94+
version: v0.17.0
95+
config: ${{ env.KIND_CONFIG_FILE }}
96+
97+
- name: Print cluster info
98+
run: |
99+
echo "KinD cluster:"
100+
kubectl cluster-info
101+
kubectl describe nodes
102+
103+
- name: Deploy CodeFlare stack
104+
id: deploy
105+
run: |
106+
KUBERAY_VERSION=$(make get-kuberay-version)
107+
echo Deploying KubeRay ${KUBERAY_VERSION}
108+
kubectl create -k "github.com/ray-project/kuberay/ray-operator/config/default?ref=${KUBERAY_VERSION}&timeout=90s"
109+
110+
echo Deploying CodeFlare operator
111+
IMG="${REGISTRY_ADDRESS}"/codeflare-operator
112+
make image-push -e IMG="${IMG}"
113+
make deploy -e IMG="${IMG}"
114+
kubectl wait --timeout=120s --for=condition=Available=true deployment -n openshift-operators codeflare-operator-manager
115+
116+
echo Deploying MCAD controller
117+
kubectl create ns codeflare-system
118+
cat <<EOF | kubectl apply -n codeflare-system -f -
119+
apiVersion: codeflare.codeflare.dev/v1alpha1
120+
kind: MCAD
121+
metadata:
122+
name: mcad
123+
spec:
124+
controllerResources: {}
125+
EOF
126+
127+
cat <<EOF | kubectl apply -n codeflare-system -f -
128+
apiVersion: rbac.authorization.k8s.io/v1
129+
kind: ClusterRole
130+
metadata:
131+
name: mcad-controller-rayclusters
132+
rules:
133+
- apiGroups:
134+
- ray.io
135+
resources:
136+
- rayclusters
137+
- rayclusters/finalizers
138+
- rayclusters/status
139+
verbs:
140+
- get
141+
- list
142+
- watch
143+
- create
144+
- update
145+
- patch
146+
- delete
147+
EOF
148+
149+
cat <<EOF | kubectl apply -n codeflare-system -f -
150+
kind: ClusterRoleBinding
151+
apiVersion: rbac.authorization.k8s.io/v1
152+
metadata:
153+
name: mcad-controller-rayclusters
154+
subjects:
155+
- kind: ServiceAccount
156+
name: mcad-controller-mcad
157+
namespace: codeflare-system
158+
roleRef:
159+
apiGroup: rbac.authorization.k8s.io
160+
kind: ClusterRole
161+
name: mcad-controller-rayclusters
162+
EOF
163+
164+
kubectl wait --timeout=120s --for=condition=Available=true deployment -n codeflare-system mcad-controller-mcad
165+
166+
- name: Run e2e tests
167+
run: |
168+
make test-e2e
169+
170+
- name: Print CodeFlare operator logs
171+
if: always() && steps.deploy.outcome == 'success'
172+
run: |
173+
echo "Printing CodeFlare operator logs"
174+
kubectl logs -n openshift-operators --tail -1 -l app.kubernetes.io/name=codeflare-operator
175+
176+
- name: Print MCAD controller logs
177+
if: always() && steps.deploy.outcome == 'success'
178+
run: |
179+
echo "Printing MCAD controller logs"
180+
kubectl logs -n codeflare-system --tail -1 -l component=multi-cluster-application-dispatcher

.pre-commit-config.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,4 @@ repos:
2525
hooks:
2626
- id: go-fmt
2727
- id: golangci-lint
28-
- id: go-build
2928
- id: go-mod-tidy

Makefile

+14-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ MCAD_REF ?= release-${MCAD_VERSION}
2121
MCAD_REPO ?= github.com/project-codeflare/multi-cluster-app-dispatcher
2222
MCAD_CRD ?= ${MCAD_REPO}/config/crd?ref=${MCAD_REF}
2323

24+
# KUBERAY_VERSION defines the default version of the KubeRay operator
25+
KUBERAY_VERSION ?= v0.5.0
26+
2427
# OPERATORS_REPO_ORG points to GitHub repository organization where bundle PR is opened against
2528
# OPERATORS_REPO_FORK_ORG points to GitHub repository fork organization where bundle build is pushed to
2629
OPERATORS_REPO_ORG ?= redhat-openshift-ecosystem
@@ -199,7 +202,7 @@ image-build: test-unit ## Build container image with the manager.
199202
podman build -t ${IMG} .
200203

201204
.PHONY: image-push
202-
image-push: ## Push container image with the manager.
205+
image-push: image-build ## Push container image with the manager.
203206
podman push ${IMG}
204207

205208
##@ Deployment
@@ -383,5 +386,13 @@ catalog-push: ## Push a catalog image.
383386
$(MAKE) image-push IMG=$(CATALOG_IMG)
384387

385388
.PHONY: test-unit
386-
test-unit: defaults manifests generate fmt vet envtest ## Run tests.
387-
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./... -coverprofile cover.out
389+
test-unit: defaults manifests generate fmt vet envtest ## Run unit tests.
390+
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test $(go list ./... | grep -v /test/) -coverprofile cover.out
391+
392+
.PHONY: test-e2e
393+
test-e2e: defaults manifests generate fmt vet ## Run e2e tests.
394+
go test -timeout 30m -v ./test/e2e
395+
396+
.PHONY: get-kuberay-version
397+
get-kuberay-version:
398+
@echo $(KUBERAY_VERSION)

go.mod

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ require (
88
github.com/manifestival/manifestival v0.7.2
99
github.com/onsi/ginkgo/v2 v2.9.2
1010
github.com/onsi/gomega v1.27.6
11+
github.com/project-codeflare/multi-cluster-app-dispatcher v1.31.0
12+
github.com/ray-project/kuberay/ray-operator v0.0.0-20230614221720-085c29d40fa9
1113
go.uber.org/zap v1.24.0
1214
k8s.io/api v0.26.3
1315
k8s.io/apimachinery v0.26.3

go.sum

+4
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,8 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
428428
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
429429
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
430430
github.com/pquerna/cachecontrol v0.0.0-20171018203845-0dec1b30a021/go.mod h1:prYjPmNq4d1NPVmpShWobRqXY3q7Vp+80DqgxxUrUIA=
431+
github.com/project-codeflare/multi-cluster-app-dispatcher v1.31.0 h1:vq4fAuvlv4Zvnx0dA53WaYkTWG1BFxAkamxuzHfZO2M=
432+
github.com/project-codeflare/multi-cluster-app-dispatcher v1.31.0/go.mod h1:fmbU5LuV1Z2Sbu1FCEoVuw8qxDFcalXvkPyMfGZHHTc=
431433
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
432434
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
433435
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
@@ -459,6 +461,8 @@ github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1
459461
github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo=
460462
github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4=
461463
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
464+
github.com/ray-project/kuberay/ray-operator v0.0.0-20230614221720-085c29d40fa9 h1:qIThU9GGqEay/y78y4Y9e1FVfrdkH5MFnT0zEJ9yh0A=
465+
github.com/ray-project/kuberay/ray-operator v0.0.0-20230614221720-085c29d40fa9/go.mod h1:2auArgwD9dXXJz1oc7SqQ4U/rHdpwnrBwG98kr8OWXA=
462466
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
463467
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
464468
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=

test/e2e/kind.yaml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# ---------------------------------------------------------------------------
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. 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+
18+
kind: Cluster
19+
apiVersion: kind.x-k8s.io/v1alpha4
20+
nodes:
21+
- role: control-plane
22+
image: kindest/node:v1.25.3@sha256:f52781bc0d7a19fb6c405c2af83abfeb311f130707a0e219175677e366cc45d1
23+
kubeadmConfigPatches:
24+
- |
25+
kind: InitConfiguration
26+
nodeRegistration:
27+
kubeletExtraArgs:
28+
node-labels: "ingress-ready=true"
29+
containerdConfigPatches:
30+
- |-
31+
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."${REGISTRY_ADDRESS}"]
32+
endpoint = ["http://${REGISTRY_ADDRESS}"]

0 commit comments

Comments
 (0)