Skip to content

Commit

Permalink
test: Factorize e2e tests setup
Browse files Browse the repository at this point in the history
  • Loading branch information
astefanutti authored and openshift-merge-robot committed Jul 5, 2023
1 parent 9d53656 commit 99b8e7c
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 56 deletions.
55 changes: 2 additions & 53 deletions .github/workflows/e2e_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,65 +108,14 @@ jobs:
- name: Deploy CodeFlare stack
id: deploy
run: |
KUBERAY_VERSION=$(make get-kuberay-version)
echo Deploying KubeRay ${KUBERAY_VERSION}
kubectl create -k "github.com/ray-project/kuberay/ray-operator/config/default?ref=${KUBERAY_VERSION}&timeout=90s"
echo Deploying CodeFlare operator
IMG="${REGISTRY_ADDRESS}"/codeflare-operator
make image-push -e IMG="${IMG}"
make deploy -e IMG="${IMG}"
kubectl wait --timeout=120s --for=condition=Available=true deployment -n openshift-operators codeflare-operator-manager
echo Deploying MCAD controller
kubectl create ns codeflare-system
cat <<EOF | kubectl apply -n codeflare-system -f -
apiVersion: codeflare.codeflare.dev/v1alpha1
kind: MCAD
metadata:
name: mcad
spec:
controllerResources: {}
EOF
cat <<EOF | kubectl apply -n codeflare-system -f -
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: mcad-controller-rayclusters
rules:
- apiGroups:
- ray.io
resources:
- rayclusters
- rayclusters/finalizers
- rayclusters/status
verbs:
- get
- list
- watch
- create
- update
- patch
- delete
EOF
cat <<EOF | kubectl apply -n codeflare-system -f -
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: mcad-controller-rayclusters
subjects:
- kind: ServiceAccount
name: mcad-controller-mcad
namespace: codeflare-system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: mcad-controller-rayclusters
EOF
kubectl wait --timeout=120s --for=condition=Available=true deployment -n codeflare-system mcad-controller-mcad
echo Setting up CodeFlare stack
make setup-e2e
- name: Run e2e tests
run: |
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,6 @@ 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: get-kuberay-version
get-kuberay-version:
@echo $(KUBERAY_VERSION)
.PHONY: setup-e2e
setup-e2e: ## Set up e2e tests.
KUBERAY_VERSION=$(KUBERAY_VERSION) test/e2e/setup.sh
73 changes: 73 additions & 0 deletions test/e2e/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/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
: "${KUBERAY_VERSION}"

echo Deploying KubeRay "${KUBERAY_VERSION}"
kubectl apply --server-side -k "github.com/ray-project/kuberay/ray-operator/config/default?ref=${KUBERAY_VERSION}&timeout=90s"

kubectl create ns codeflare-system --dry-run=client -o yaml | kubectl apply -f -

echo Deploying MCAD controller
cat <<EOF | kubectl apply -n codeflare-system -f -
apiVersion: codeflare.codeflare.dev/v1alpha1
kind: MCAD
metadata:
name: mcad
spec:
controllerResources: {}
EOF

cat <<EOF | kubectl apply -n codeflare-system -f -
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: mcad-controller-rayclusters
rules:
- apiGroups:
- ray.io
resources:
- rayclusters
- rayclusters/finalizers
- rayclusters/status
verbs:
- get
- list
- watch
- create
- update
- patch
- delete
EOF

cat <<EOF | kubectl apply -n codeflare-system -f -
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: mcad-controller-rayclusters
subjects:
- kind: ServiceAccount
name: mcad-controller-mcad
namespace: codeflare-system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: mcad-controller-rayclusters
EOF

echo "Waiting for the MCAD deployment to become ready..."
kubectl wait --timeout=120s --for=condition=Available=true deployment -n codeflare-system mcad-controller-mcad

0 comments on commit 99b8e7c

Please sign in to comment.