Skip to content

Commit 2d635f9

Browse files
authored
Merge pull request #505 from hdefazio/cp/split-e2e-setup
[Cherry-pick] Split the e2e test cluster setup into a new script
2 parents 1202d97 + 607f06a commit 2d635f9

File tree

3 files changed

+185
-137
lines changed

3 files changed

+185
-137
lines changed

config/overlays/test/kustomization.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ resources:
55
- ../../crd/external
66
- ../../default
77
- minio
8-
- dsci.yaml
9-
- dsc.yaml
108

119
patches:
1210
- path: configmap/inferenceservice.yaml

test/scripts/openshift-ci/run-e2e-tests.sh

Lines changed: 11 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -18,150 +18,26 @@
1818
# like kustomize and the mc client are installed by the script if not available.
1919
# The oc CLI is assumed to be configured with the credentials of the
2020
# target cluster. The target cluster is assumed to be a clean cluster.
21+
set -o errexit
22+
set -o nounset
23+
set -o pipefail
2124

22-
set -eu
23-
24-
: "${SKLEARN_IMAGE:=kserve/sklearnserver:latest}"
25-
: "${KSERVE_CONTROLLER_IMAGE:=quay.io/opendatahub/kserve-controller:latest}"
26-
: "${KSERVE_AGENT_IMAGE:=quay.io/opendatahub/kserve-agent:latest}"
27-
: "${KSERVE_ROUTER_IMAGE:=quay.io/opendatahub/kserve-router:latest}"
28-
: "${STORAGE_INITIALIZER_IMAGE:=quay.io/opendatahub/kserve-storage-initializer:latest}"
29-
30-
echo "SKLEARN_IMAGE=$SKLEARN_IMAGE"
31-
echo "KSERVE_CONTROLLER_IMAGE=$KSERVE_CONTROLLER_IMAGE"
32-
echo "KSERVE_AGENT_IMAGE=$KSERVE_AGENT_IMAGE"
33-
echo "KSERVE_ROUTER_IMAGE=$KSERVE_ROUTER_IMAGE"
34-
echo "STORAGE_INITIALIZER_IMAGE=$STORAGE_INITIALIZER_IMAGE"
35-
36-
# Create directory for installing tooling
37-
# It is assumed that $HOME/.local/bin is in the $PATH
38-
mkdir -p $HOME/.local/bin
3925
MY_PATH=$(dirname "$0")
4026
PROJECT_ROOT=$MY_PATH/../../../
4127

42-
# If Kustomize is not installed, install it
43-
if ! command -v kustomize &>/dev/null; then
44-
echo "Installing Kustomize"
45-
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash -s -- 5.0.1 $HOME/.local/bin
46-
fi
47-
48-
# If minio CLI is not installed, install it
49-
if ! command -v mc &>/dev/null; then
50-
echo "Installing Minio CLI"
51-
curl https://dl.min.io/client/mc/release/linux-amd64/mc --create-dirs -o $HOME/.local/bin/mc
52-
chmod +x $HOME/.local/bin/mc
53-
fi
54-
55-
echo "Installing KServe Python SDK ..."
56-
pushd $PROJECT_ROOT >/dev/null
57-
./test/scripts/gh-actions/setup-poetry.sh
58-
./test/scripts/gh-actions/check-poetry-lockfile.sh
59-
popd
60-
pushd $PROJECT_ROOT/python/kserve >/dev/null
61-
poetry install --with=test --no-interaction
62-
popd
63-
64-
# Install KServe stack
65-
if [ "$1" != "raw" ]; then
66-
echo "Installing OSSM"
67-
$MY_PATH/deploy.ossm.sh
68-
echo "Installing Serverless"
69-
$MY_PATH/deploy.serverless.sh
70-
fi
71-
72-
echo "Installing KServe with Minio"
73-
kustomize build $PROJECT_ROOT/config/overlays/test |
74-
sed "s|kserve/storage-initializer:latest|${STORAGE_INITIALIZER_IMAGE}|" |
75-
sed "s|kserve/agent:latest|${KSERVE_AGENT_IMAGE}|" |
76-
sed "s|kserve/router:latest|${KSERVE_ROUTER_IMAGE}|" |
77-
sed "s|kserve/kserve-controller:latest|${KSERVE_CONTROLLER_IMAGE}|" |
78-
oc apply --server-side=true -f -
79-
80-
# Install DSC/DSCI for test. (sometimes there is timing issue when it is under the same kustomization so it is separated)
81-
oc create -f config/overlays/test/dsci.yaml
82-
oc create -f config/overlays/test/dsc.yaml
83-
84-
# Patch the inferenceservice-config ConfigMap, when running RawDeployment tests
85-
if [ "$1" == "raw" ]; then
86-
export OPENSHIFT_INGRESS_DOMAIN=$(oc get ingresses.config cluster -o jsonpath='{.spec.domain}')
87-
oc patch configmap inferenceservice-config -n kserve --patch-file <(cat config/overlays/test/configmap/inferenceservice-openshift-ci-raw.yaml | envsubst)
88-
oc delete pod -n kserve -l control-plane=kserve-controller-manager
89-
90-
oc patch DataScienceCluster test-dsc --type='json' -p='[{"op": "replace", "path": "/spec/components/kserve/defaultDeploymentMode", "value": "RawDeployment"}]'
91-
else
92-
export OPENSHIFT_INGRESS_DOMAIN=$(oc get ingresses.config cluster -o jsonpath='{.spec.domain}')
93-
oc patch configmap inferenceservice-config -n kserve --patch-file <(cat config/overlays/test/configmap/inferenceservice-openshift-ci-serverless.yaml | envsubst)
28+
SETUP_E2E=true
29+
if $SETUP_E2E; then
30+
echo "Installing on cluster"
31+
pushd $PROJECT_ROOT >/dev/null
32+
./test/scripts/openshift-ci/setup-e2e-tests.sh "$1"
33+
popd
9434
fi
9535

96-
# Wait until KServe starts
97-
oc wait --for=condition=ready pod -l control-plane=kserve-controller-manager -n kserve --timeout=300s
98-
99-
if [ "$1" != "raw" ]; then
100-
echo "Installing odh-model-controller"
101-
oc apply -k $PROJECT_ROOT/test/scripts/openshift-ci
102-
fi
103-
104-
echo "Add testing models to minio storage ..." # Reference: config/overlays/test/minio/minio-init-job.yaml
105-
oc expose service minio-service -n kserve && sleep 5
106-
MINIO_ROUTE=$(oc get routes -n kserve minio-service -o jsonpath="{.spec.host}")
107-
mc alias set storage http://$MINIO_ROUTE minio minio123
108-
109-
if ! mc ls storage/example-models >/dev/null 2>&1; then
110-
mc mb storage/example-models
111-
else
112-
echo "Bucket 'example-models' already exists."
113-
fi
114-
115-
if [[ $(mc ls storage/example-models/sklearn/model.joblib |wc -l) == "1" ]]; then
116-
echo "Test model exists"
117-
else
118-
echo "Copy test model"
119-
curl -L https://storage.googleapis.com/kfserving-examples/models/sklearn/1.0/model/model.joblib -o /tmp/sklearn-model.joblib
120-
mc cp /tmp/sklearn-model.joblib storage/example-models/sklearn/model.joblib
121-
fi
122-
123-
oc delete route -n kserve minio-service
124-
125-
echo "Prepare CI namespace and install ServingRuntimes"
126-
cat <<EOF | oc apply -f -
127-
apiVersion: v1
128-
kind: Namespace
129-
metadata:
130-
name: kserve-ci-e2e-test
131-
EOF
132-
133-
if [ "$1" != "raw" ]; then
134-
cat <<EOF | oc apply -f -
135-
apiVersion: maistra.io/v1
136-
kind: ServiceMeshMember
137-
metadata:
138-
name: default
139-
namespace: kserve-ci-e2e-test
140-
spec:
141-
controlPlaneRef:
142-
namespace: istio-system
143-
name: basic
144-
EOF
145-
fi
146-
147-
oc apply -f $PROJECT_ROOT/config/overlays/test/minio/minio-user-secret.yaml -n kserve-ci-e2e-test
148-
149-
kustomize build $PROJECT_ROOT/config/overlays/test/clusterresources |
150-
sed 's/ClusterServingRuntime/ServingRuntime/' |
151-
sed "s|kserve/sklearnserver:latest|${SKLEARN_IMAGE}|" |
152-
sed "s|kserve/storage-initializer:latest|${STORAGE_INITIALIZER_IMAGE}|" |
153-
oc apply -n kserve-ci-e2e-test -f -
154-
155-
# Add the enablePassthrough annotation to the ServingRuntimes, to let Knative to
156-
# generate passthrough routes. If RawDeployment test are being run, this annotation would have
157-
# no effect, because of missing Knative
158-
oc annotate servingruntimes -n kserve-ci-e2e-test --all serving.knative.openshift.io/enablePassthrough=true
159-
16036
echo "Run E2E tests: $1"
16137
pushd $PROJECT_ROOT >/dev/null
16238
# Note: The following images are set by openshift-ci. Uncomment if you are running on your own machine.
163-
# export CUSTOM_MODEL_GRPC_IMG_TAG=kserve/custom-model-grpc:latest
164-
# export IMAGE_TRANSFORMER_IMG_TAG=kserve/image-transformer:latest
39+
#export CUSTOM_MODEL_GRPC_IMG_TAG=kserve/custom-model-grpc:latest
40+
#export IMAGE_TRANSFORMER_IMG_TAG=kserve/image-transformer:latest
16541

16642
export GITHUB_SHA=$(git rev-parse HEAD)
16743
export CI_USE_ISVC_HOST="1"
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# This is a helper script to run E2E tests on the openshift-ci operator.
16+
# This script assumes to be run inside a container/machine that has
17+
# python pre-installed and the `oc` command available. Additional tooling,
18+
# like kustomize and the mc client are installed by the script if not available.
19+
# The oc CLI is assumed to be configured with the credentials of the
20+
# target cluster. The target cluster is assumed to be a clean cluster.
21+
set -o errexit
22+
set -o nounset
23+
set -o pipefail
24+
25+
: "${SKLEARN_IMAGE:=kserve/sklearnserver:latest}"
26+
: "${KSERVE_CONTROLLER_IMAGE:=quay.io/opendatahub/kserve-controller:latest}"
27+
: "${KSERVE_AGENT_IMAGE:=quay.io/opendatahub/kserve-agent:latest}"
28+
: "${KSERVE_ROUTER_IMAGE:=quay.io/opendatahub/kserve-router:latest}"
29+
: "${STORAGE_INITIALIZER_IMAGE:=quay.io/opendatahub/kserve-storage-initializer:latest}"
30+
31+
echo "SKLEARN_IMAGE=$SKLEARN_IMAGE"
32+
echo "KSERVE_CONTROLLER_IMAGE=$KSERVE_CONTROLLER_IMAGE"
33+
echo "KSERVE_AGENT_IMAGE=$KSERVE_AGENT_IMAGE"
34+
echo "KSERVE_ROUTER_IMAGE=$KSERVE_ROUTER_IMAGE"
35+
echo "STORAGE_INITIALIZER_IMAGE=$STORAGE_INITIALIZER_IMAGE"
36+
37+
# Create directory for installing tooling
38+
# It is assumed that $HOME/.local/bin is in the $PATH
39+
mkdir -p $HOME/.local/bin
40+
MY_PATH=$(dirname "$0")
41+
PROJECT_ROOT=$MY_PATH/../../../
42+
43+
# If Kustomize is not installed, install it
44+
if ! command -v kustomize &>/dev/null; then
45+
echo "Installing Kustomize"
46+
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash -s -- 5.0.1 $HOME/.local/bin
47+
fi
48+
49+
# If minio CLI is not installed, install it
50+
if ! command -v mc &>/dev/null; then
51+
echo "Installing Minio CLI"
52+
curl https://dl.min.io/client/mc/release/linux-amd64/mc --create-dirs -o $HOME/.local/bin/mc
53+
chmod +x $HOME/.local/bin/mc
54+
fi
55+
56+
echo "Installing KServe Python SDK ..."
57+
pushd $PROJECT_ROOT >/dev/null
58+
./test/scripts/gh-actions/setup-poetry.sh
59+
./test/scripts/gh-actions/check-poetry-lockfile.sh
60+
popd
61+
pushd $PROJECT_ROOT/python/kserve >/dev/null
62+
poetry install --with=test --no-interaction
63+
popd
64+
65+
# Install KServe stack
66+
if [ "$1" != "raw" ]; then
67+
echo "Installing OSSM"
68+
$MY_PATH/deploy.ossm.sh
69+
echo "Installing Serverless"
70+
$MY_PATH/deploy.serverless.sh
71+
fi
72+
73+
echo "Installing KServe with Minio"
74+
kustomize build $PROJECT_ROOT/config/overlays/test |
75+
sed "s|kserve/storage-initializer:latest|${STORAGE_INITIALIZER_IMAGE}|" |
76+
sed "s|kserve/agent:latest|${KSERVE_AGENT_IMAGE}|" |
77+
sed "s|kserve/router:latest|${KSERVE_ROUTER_IMAGE}|" |
78+
sed "s|kserve/kserve-controller:latest|${KSERVE_CONTROLLER_IMAGE}|" |
79+
oc apply --server-side=true -f -
80+
81+
# Install DSC/DSCI for test. (sometimes there is timing issue when it is under the same kustomization so it is separated)
82+
oc create -f config/overlays/test/dsci.yaml
83+
oc create -f config/overlays/test/dsc.yaml
84+
85+
# Patch the inferenceservice-config ConfigMap, when running RawDeployment tests
86+
if [ "$1" == "raw" ]; then
87+
export OPENSHIFT_INGRESS_DOMAIN=$(oc get ingresses.config cluster -o jsonpath='{.spec.domain}')
88+
oc patch configmap inferenceservice-config -n kserve --patch-file <(cat config/overlays/test/configmap/inferenceservice-openshift-ci-raw.yaml | envsubst)
89+
oc delete pod -n kserve -l control-plane=kserve-controller-manager
90+
91+
oc patch DataScienceCluster test-dsc --type='json' -p='[{"op": "replace", "path": "/spec/components/kserve/defaultDeploymentMode", "value": "RawDeployment"}]'
92+
else
93+
export OPENSHIFT_INGRESS_DOMAIN=$(oc get ingresses.config cluster -o jsonpath='{.spec.domain}')
94+
oc patch configmap inferenceservice-config -n kserve --patch-file <(cat config/overlays/test/configmap/inferenceservice-openshift-ci-serverless.yaml | envsubst)
95+
fi
96+
97+
# Wait until KServe starts
98+
oc wait --for=condition=ready pod -l control-plane=kserve-controller-manager -n kserve --timeout=300s
99+
100+
if [ "$1" != "raw" ]; then
101+
echo "Installing odh-model-controller"
102+
# authorino
103+
curl -sL https://raw.githubusercontent.com/Kuadrant/authorino-operator/main/utils/install.sh | sed "s|kubectl|oc|" |
104+
bash -s -- -v 0.16.0
105+
106+
# kserve-local-gateway
107+
curl https://raw.githubusercontent.com/opendatahub-io/opendatahub-operator/bde4b4e8478b5d03195e2777b9d550922e3cdcbc/components/kserve/resources/servicemesh/routing/istio-kserve-local-gateway.tmpl.yaml |
108+
sed "s/{{ .ControlPlane.Namespace }}/istio-system/g" |
109+
oc create -f -
110+
111+
curl https://raw.githubusercontent.com/opendatahub-io/opendatahub-operator/bde4b4e8478b5d03195e2777b9d550922e3cdcbc/components/kserve/resources/servicemesh/routing/kserve-local-gateway-svc.tmpl.yaml |
112+
sed "s/{{ .ControlPlane.Namespace }}/istio-system/g" |
113+
oc create -f -
114+
115+
oc apply -k $PROJECT_ROOT/test/scripts/openshift-ci
116+
fi
117+
118+
echo "Add testing models to minio storage ..." # Reference: config/overlays/test/minio/minio-init-job.yaml
119+
oc expose service minio-service -n kserve && sleep 5
120+
MINIO_ROUTE=$(oc get routes -n kserve minio-service -o jsonpath="{.spec.host}")
121+
mc alias set storage http://$MINIO_ROUTE minio minio123
122+
123+
if ! mc ls storage/example-models >/dev/null 2>&1; then
124+
mc mb storage/example-models
125+
else
126+
echo "Bucket 'example-models' already exists."
127+
fi
128+
129+
if [[ $(mc ls storage/example-models/sklearn/model.joblib |wc -l) == "1" ]]; then
130+
echo "Test model exists"
131+
else
132+
echo "Copy test model"
133+
curl -L https://storage.googleapis.com/kfserving-examples/models/sklearn/1.0/model/model.joblib -o /tmp/sklearn-model.joblib
134+
mc cp /tmp/sklearn-model.joblib storage/example-models/sklearn/model.joblib
135+
fi
136+
137+
oc delete route -n kserve minio-service
138+
139+
echo "Prepare CI namespace and install ServingRuntimes"
140+
cat <<EOF | oc apply -f -
141+
apiVersion: v1
142+
kind: Namespace
143+
metadata:
144+
name: kserve-ci-e2e-test
145+
EOF
146+
147+
if [ "$1" != "raw" ]; then
148+
cat <<EOF | oc apply -f -
149+
apiVersion: maistra.io/v1
150+
kind: ServiceMeshMember
151+
metadata:
152+
name: default
153+
namespace: kserve-ci-e2e-test
154+
spec:
155+
controlPlaneRef:
156+
namespace: istio-system
157+
name: basic
158+
EOF
159+
fi
160+
161+
oc apply -f $PROJECT_ROOT/config/overlays/test/minio/minio-user-secret.yaml -n kserve-ci-e2e-test
162+
163+
kustomize build $PROJECT_ROOT/config/overlays/test/clusterresources |
164+
sed 's/ClusterServingRuntime/ServingRuntime/' |
165+
sed "s|kserve/sklearnserver:latest|${SKLEARN_IMAGE}|" |
166+
sed "s|kserve/storage-initializer:latest|${STORAGE_INITIALIZER_IMAGE}|" |
167+
oc apply -n kserve-ci-e2e-test -f -
168+
169+
# Add the enablePassthrough annotation to the ServingRuntimes, to let Knative to
170+
# generate passthrough routes. If RawDeployment test are being run, this annotation would have
171+
# no effect, because of missing Knative
172+
oc annotate servingruntimes -n kserve-ci-e2e-test --all serving.knative.openshift.io/enablePassthrough=true
173+
174+
echo "Setup complete"

0 commit comments

Comments
 (0)