Skip to content

Commit 9eabd95

Browse files
committed
test: Factorize e2e tests setup
1 parent 2045c7a commit 9eabd95

File tree

3 files changed

+78
-56
lines changed

3 files changed

+78
-56
lines changed

.github/workflows/e2e_tests.yaml

+2-53
Original file line numberDiff line numberDiff line change
@@ -108,65 +108,14 @@ jobs:
108108
- name: Deploy CodeFlare stack
109109
id: deploy
110110
run: |
111-
KUBERAY_VERSION=$(make get-kuberay-version)
112-
echo Deploying KubeRay ${KUBERAY_VERSION}
113-
kubectl create -k "github.com/ray-project/kuberay/ray-operator/config/default?ref=${KUBERAY_VERSION}&timeout=90s"
114-
115111
echo Deploying CodeFlare operator
116112
IMG="${REGISTRY_ADDRESS}"/codeflare-operator
117113
make image-push -e IMG="${IMG}"
118114
make deploy -e IMG="${IMG}"
119115
kubectl wait --timeout=120s --for=condition=Available=true deployment -n openshift-operators codeflare-operator-manager
120116
121-
echo Deploying MCAD controller
122-
kubectl create ns codeflare-system
123-
cat <<EOF | kubectl apply -n codeflare-system -f -
124-
apiVersion: codeflare.codeflare.dev/v1alpha1
125-
kind: MCAD
126-
metadata:
127-
name: mcad
128-
spec:
129-
controllerResources: {}
130-
EOF
131-
132-
cat <<EOF | kubectl apply -n codeflare-system -f -
133-
apiVersion: rbac.authorization.k8s.io/v1
134-
kind: ClusterRole
135-
metadata:
136-
name: mcad-controller-rayclusters
137-
rules:
138-
- apiGroups:
139-
- ray.io
140-
resources:
141-
- rayclusters
142-
- rayclusters/finalizers
143-
- rayclusters/status
144-
verbs:
145-
- get
146-
- list
147-
- watch
148-
- create
149-
- update
150-
- patch
151-
- delete
152-
EOF
153-
154-
cat <<EOF | kubectl apply -n codeflare-system -f -
155-
kind: ClusterRoleBinding
156-
apiVersion: rbac.authorization.k8s.io/v1
157-
metadata:
158-
name: mcad-controller-rayclusters
159-
subjects:
160-
- kind: ServiceAccount
161-
name: mcad-controller-mcad
162-
namespace: codeflare-system
163-
roleRef:
164-
apiGroup: rbac.authorization.k8s.io
165-
kind: ClusterRole
166-
name: mcad-controller-rayclusters
167-
EOF
168-
169-
kubectl wait --timeout=120s --for=condition=Available=true deployment -n codeflare-system mcad-controller-mcad
117+
echo Setting up CodeFlare stack
118+
make setup-e2e
170119
171120
- name: Run e2e tests
172121
run: |

Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,6 @@ test-unit: defaults manifests generate fmt vet envtest ## Run unit tests.
422422
test-e2e: defaults manifests generate fmt vet ## Run e2e tests.
423423
go test -timeout 30m -v ./test/e2e
424424

425-
.PHONY: get-kuberay-version
426-
get-kuberay-version:
427-
@echo $(KUBERAY_VERSION)
425+
.PHONY: setup-e2e
426+
setup-e2e: ## Set up e2e tests.
427+
KUBERAY_VERSION=$(KUBERAY_VERSION) test/e2e/setup.sh

test/e2e/setup.sh

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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+
: "${KUBERAY_VERSION}"
19+
20+
echo Deploying KubeRay "${KUBERAY_VERSION}"
21+
kubectl apply --server-side -k "github.com/ray-project/kuberay/ray-operator/config/default?ref=${KUBERAY_VERSION}&timeout=90s"
22+
23+
kubectl create ns codeflare-system --dry-run=client -o yaml | kubectl apply -f -
24+
25+
echo Deploying MCAD controller
26+
cat <<EOF | kubectl apply -n codeflare-system -f -
27+
apiVersion: codeflare.codeflare.dev/v1alpha1
28+
kind: MCAD
29+
metadata:
30+
name: mcad
31+
spec:
32+
controllerResources: {}
33+
EOF
34+
35+
cat <<EOF | kubectl apply -n codeflare-system -f -
36+
apiVersion: rbac.authorization.k8s.io/v1
37+
kind: ClusterRole
38+
metadata:
39+
name: mcad-controller-rayclusters
40+
rules:
41+
- apiGroups:
42+
- ray.io
43+
resources:
44+
- rayclusters
45+
- rayclusters/finalizers
46+
- rayclusters/status
47+
verbs:
48+
- get
49+
- list
50+
- watch
51+
- create
52+
- update
53+
- patch
54+
- delete
55+
EOF
56+
57+
cat <<EOF | kubectl apply -n codeflare-system -f -
58+
kind: ClusterRoleBinding
59+
apiVersion: rbac.authorization.k8s.io/v1
60+
metadata:
61+
name: mcad-controller-rayclusters
62+
subjects:
63+
- kind: ServiceAccount
64+
name: mcad-controller-mcad
65+
namespace: codeflare-system
66+
roleRef:
67+
apiGroup: rbac.authorization.k8s.io
68+
kind: ClusterRole
69+
name: mcad-controller-rayclusters
70+
EOF
71+
72+
echo "Waiting for the MCAD deployment to become ready..."
73+
kubectl wait --timeout=120s --for=condition=Available=true deployment -n codeflare-system mcad-controller-mcad

0 commit comments

Comments
 (0)