@@ -19,20 +19,7 @@ readonly ROOT_DIR=$(dirname $0)/..
1919source " $( go run knative.dev/hack/cmd/script library.sh) "
2020source " $( go run knative.dev/hack/cmd/script e2e-tests.sh) "
2121
22- readonly KN_DEFAULT_TEST_IMAGE=" gcr.io/knative-samples/helloworld-go"
23- readonly SERVING_NAMESPACE=" knative-serving"
24- readonly SERVING_INGRESS_NAMESPACE=" knative-serving-ingress"
25- readonly EVENTING_NAMESPACE=" knative-eventing"
2622readonly E2E_TIMEOUT=" 60m"
27- readonly OLM_NAMESPACE=" openshift-marketplace"
28-
29- # if you want to setup the nightly serving/eventing, set `release-next` OR
30- # set release branch name for example: release-v0.19.1
31- readonly SERVING_BRANCH=" release-next"
32- readonly EVENTING_BRANCH=" release-next"
33-
34- # The value should be updated once S-O release branch is cut
35- readonly SERVERLESS_BRANCH=" serverless-1.33"
3623
3724# Determine if we're running locally or in CI.
3825if [ -n " $OPENSHIFT_BUILD_NAMESPACE " ]; then
5744
5845env
5946
60- # Loops until duration (car) is exceeded or command (cdr) returns non-zero
61- timeout () {
62- SECONDS=0; TIMEOUT=$1 ; shift
63- while eval $* ; do
64- sleep 5
65- [[ $SECONDS -gt $TIMEOUT ]] && echo " ERROR: Timed out" && return 1
66- done
67- return 0
68- }
69-
7047build_knative_client () {
7148 failed=0
7249 # run this cross platform build to ensure all the checks pass (as this is done while building artifacts)
@@ -85,6 +62,10 @@ run_unit_tests() {
8562 return $failed
8663}
8764
65+ run_sobranch () {
66+ go run github.com/openshift-knative/hack/cmd/sobranch@latest " $@ "
67+ }
68+
8869run_client_e2e_tests (){
8970 local tags=$1
9071 local test_name=${2:- }
@@ -121,152 +102,42 @@ run_client_e2e_tests(){
121102 return $failed
122103}
123104
124- # Waits until all pods are running in the given namespace.
125- # Parameters: $1 - namespace.
126- wait_until_pods_running () {
127- echo -n " Waiting until all pods in namespace $1 are up"
128- for i in {1..150}; do # timeout after 5 minutes
129- local pods=" $( kubectl get pods --no-headers -n $1 2> /dev/null) "
130- # All pods must be running
131- local not_running=$( echo " ${pods} " | grep -v Running | grep -v Completed | wc -l)
132- if [[ -n " ${pods} " && ${not_running} -eq 0 ]]; then
133- local all_ready=1
134- while read pod ; do
135- local status=(` echo -n ${pod} | cut -f2 -d' ' | tr ' /' ' ' ` )
136- # All containers must be ready
137- [[ -z ${status[0]} ]] && all_ready=0 && break
138- [[ -z ${status[1]} ]] && all_ready=0 && break
139- [[ ${status[0]} -lt 1 ]] && all_ready=0 && break
140- [[ ${status[1]} -lt 1 ]] && all_ready=0 && break
141- [[ ${status[0]} -ne ${status[1]} ]] && all_ready=0 && break
142- done <<< " $(echo " ${pods} " | grep -v Completed)"
143- if (( all_ready )) ; then
144- echo -e " \nAll pods are up:\n${pods} "
145- return 0
146- fi
147- fi
148- echo -n " ."
149- sleep 2
150- done
151- echo -e " \n\nERROR: timeout waiting for pods to come up\n${pods} "
152- return 1
153- }
154-
155- create_knative_namespace (){
156- local COMPONENT=" knative-$1 "
157-
158- cat << -EOF | oc apply -f -
159- apiVersion: v1
160- kind: Namespace
161- metadata:
162- name: ${COMPONENT}
163- EOF
164- }
165-
166- install_knative_eventing_branch () {
167- local branch=$1
168-
169- header " Installing Knative Eventing from openshift/knative-eventing branch $branch "
170- rm -rf /tmp/knative-eventing
171- git clone --branch $branch https://github.com/openshift-knative/eventing.git /tmp/knative-eventing || return 1
172- pushd /tmp/knative-eventing/
173-
174- create_knative_namespace eventing
175-
176- oc apply -R -f openshift/release/artifacts
177-
178- # Wait for 5 pods to appear first
179- timeout 900 ' [[ $(oc get pods -n $EVENTING_NAMESPACE --no-headers | wc -l) -lt 5 ]]' || return 1
180- wait_until_pods_running $EVENTING_NAMESPACE || return 1
181- header " Knative Eventing installed successfully"
182- popd
183- }
184-
185- install_serverless_operator_release_next () {
186- local branch=${1:- " main" }
105+ install_serverless_operator () {
187106 local repository=" https://github.com/openshift-knative/serverless-operator.git"
107+ local project_tag release so_branch
108+ project_tag=$( yq r " ${ROOT_DIR} /openshift/project.yaml" project.tag)
109+ release=${project_tag/ knative-/ }
110+ so_branch=$( run_sobranch --upstream-version " ${release} " )
111+
112+ if ! git ls-remote --heads --exit-code " $repository " " $so_branch " & > /dev/null; then
113+ echo " Release branch doesn't exist yet, using main"
114+ so_branch=" main"
115+ fi
188116
189117 local operator_dir=/tmp/serverless-operator
190- header " Installing serverless operator from openshift-knative/serverless-operator branch $branch "
118+ local failed=0
119+ header " Installing serverless operator from openshift-knative/serverless-operator branch $so_branch "
191120 rm -rf $operator_dir
192- git clone --branch $branch --depth 1 $repository $operator_dir || failed=1
121+ git clone --branch " ${so_branch} " $repository $operator_dir || failed=1
193122 pushd $operator_dir
194123
195- # Install
196124 export SKIP_MESH_AUTH_POLICY_GENERATION=true
197- export USE_RELEASE_NEXT=true
198- export USE_IMAGE_RELEASE_TAG=" knative-nightly"
199125 export ON_CLUSTER_BUILDS=true
200126 export DOCKER_REPO_OVERRIDE=image-registry.openshift-image-registry.svc:5000/openshift-marketplace
201- make release-files images install-serving || return 12
202- subheader " Successfully installed Serverless Operator."
203-
204- # Workaround default 'https' scheme
205- oc patch knativeserving knative-serving \
206- --namespace knative-serving --type merge \
207- --patch ' {"spec":{"config":{"network":{"default-external-scheme":"http"}}}}' || return 1
208-
209- oc delete cm config-openshift-trusted-cabundle \
210- --namespace knative-eventing
211-
212- popd
213- }
214-
215- install_serverless_operator_branch () {
216- local branch=$1
217- local repository=" https://github.com/openshift-knative/serverless-operator.git"
218-
219- if ! git ls-remote --heads --exit-code " $repository " " $branch " & > /dev/null; then
220- echo " Release branch doesn't exist yet, using main"
221- branch=" main"
127+ if [ " ${project_tag} " == " knative-nightly" ]; then
128+ USE_IMAGE_RELEASE_TAG=" ${project_tag} "
129+ export USE_IMAGE_RELEASE_TAG
130+ make generated-files
222131 fi
223132
224- local operator_dir=/tmp/serverless-operator
225- local failed=0
226- header " Installing serverless operator from openshift-knative/serverless-operator branch $branch "
227- rm -rf $operator_dir
228- git clone --branch $branch $repository $operator_dir || failed=1
229- pushd $operator_dir
230- # unset OPENSHIFT_BUILD_NAMESPACE (old CI) and OPENSHIFT_CI (new CI) as its used in serverless-operator's CI
231- # environment as a switch to use CI built images, we want pre-built images of k-s-o and k-o-i
232- unset OPENSHIFT_BUILD_NAMESPACE
233- unset OPENSHIFT_CI
234-
235- # Install all components Serving,Eventing,Strimzi and Kafka
236- make install-all || failed=1
133+ make images install-serving install-eventing || failed=1
237134 subheader " Successfully installed serverless operator."
238135
239136 # Workaround default 'https' scheme
240137 oc patch knativeserving knative-serving \
241138 --namespace knative-serving --type merge \
242139 --patch ' {"spec":{"config":{"network":{"default-external-scheme":"http"}}}}' || return 1
243140
244- header " Applying Strimzi Topic CR"
245- cat << -EOF | oc apply -n kafka -f - || failed=1
246- apiVersion: kafka.strimzi.io/v1beta1
247- kind: KafkaTopic
248- metadata:
249- name: test-topic
250- labels:
251- strimzi.io/cluster: my-cluster
252- spec:
253- partitions: 100
254- replicas: 1
255- EOF
256-
257141 popd
258142 return $failed
259143}
260-
261- # Add to exec script if needed
262- resources_debug () {
263- echo " >> Check resources"
264- echo " >> - meminfo:"
265- cat /proc/meminfo
266- echo " >> - memory.limit_in_bytes"
267- cat /sys/fs/cgroup/memory/memory.limit_in_bytes
268- echo " >> - cpu.cfs_period_us"
269- cat /sys/fs/cgroup/cpu/cpu.cfs_period_us
270- echo " >> - cpu.cfs_quota_us"
271- cat /sys/fs/cgroup/cpu/cpu.cfs_quota_us
272- }
0 commit comments