4 CLUSTER_NAME=test-bmh-cluster
6 kubectl create -f e2etest/test_bmh_provisioning_cr.yaml
9 #Check Status of kud job pod
12 while [[ $status == "Running" ]]
14 echo "KUD install job still running"
16 stats=$(kubectl get pods |grep -i kud-${CLUSTER_NAME})
17 status=$(echo $stats | cut -d " " -f 3)
20 #Print logs of Job Pod
21 jobPod=$(kubectl get pods|grep kud-${CLUSTER_NAME})
22 podName=$(echo $jobPod | cut -d " " -f 1)
23 printf "\nNow Printing Job pod logs\n"
26 if [[ $status == "Completed" ]];
28 printf "KUD Install Job completed\n"
29 printf "Checking cluster status\n"
31 source ../../env/lib/common.sh
32 CLUSTER_KUBECONFIG=/opt/kud/multi-cluster/${CLUSTER_NAME}/artifacts/admin.conf
33 APISERVER=$(KUBECONFIG=${CLUSTER_KUBECONFIG} kubectl config view --minify -o jsonpath='{.clusters[0].cluster.server}')
34 TOKEN=$(KUBECONFIG=${CLUSTER_KUBECONFIG} kubectl get secret $(KUBECONFIG=${CLUSTER_KUBECONFIG} kubectl get serviceaccount default -o jsonpath='{.secrets[0].name}') -o jsonpath='{.data.token}' | base64 --decode)
35 if ! call_api $APISERVER/api --header "Authorization: Bearer $TOKEN" --insecure;
37 printf "\nKubernetes Cluster Install did not complete successfully\n"
40 printf "\nKubernetes Cluster Install was successful\n"
44 printf "KUD Install Job failed\n"
49 printf "Installing KUD addons\n"
50 pushd /opt/kud/multi-cluster/${CLUSTER_NAME}/artifacts/addons
51 /opt/kud/multi-cluster/${CLUSTER_NAME}/artifacts/emcoctl.sh apply -f prerequisites.yaml -v values.yaml
52 /opt/kud/multi-cluster/${CLUSTER_NAME}/artifacts/emcoctl.sh apply -f composite-app.yaml -v values.yaml
55 #Wait for addons to be ready
56 # The deployment intent group status reports instantiated before all
57 # Pods are ready, so wait for the instance label (.spec.version) of
58 # the deployment intent group instead.
60 for try in {0..19}; do
61 printf "Waiting for KUD addons to be ready\n"
63 if KUBECONFIG=${CLUSTER_KUBECONFIG} kubectl wait pod -l app.kubernetes.io/instance=r1 --for=condition=Ready --all-namespaces --timeout=0s 2>/dev/null >/dev/null; then
68 [[ $status == "Ready" ]]
70 #Install addon resources
71 printf "Installing KUD addon resources\n"
72 pushd /opt/kud/multi-cluster/${CLUSTER_NAME}/artifacts/addons
73 /opt/kud/multi-cluster/${CLUSTER_NAME}/artifacts/emcoctl.sh apply -f composite-app.yaml -v values-resources.yaml
76 #Wait for addon resources to be ready
79 printf "Waiting for KUD addon resources to be ready\n"
81 if KUBECONFIG=${CLUSTER_KUBECONFIG} kubectl wait pod -l app.kubernetes.io/instance=r1 --for=condition=Ready --all-namespaces --timeout=0s 2>/dev/null >/dev/null; then
86 [[ $status == "Ready" ]]
89 printf "Testing KUD addons\n"
90 pushd /opt/kud/multi-cluster/addons/tests
92 container_runtime=$(KUBECONFIG=${CLUSTER_KUBECONFIG} kubectl get nodes -o jsonpath='{.items[].status.nodeInfo.containerRuntimeVersion}')
93 if [[ "${container_runtime}" == "containerd://1.2.13" ]]; then
94 #With containerd 1.2.13, the qat test container image fails to unpack.
95 kud_tests="topology-manager-sriov multus ovn4nfv nfd sriov-network cmk"
97 kud_tests="topology-manager-sriov multus ovn4nfv nfd sriov-network qat cmk"
99 for test in ${kud_tests}; do
100 KUBECONFIG=${CLUSTER_KUBECONFIG} bash ${test}.sh || failed_kud_tests="${failed_kud_tests} ${test}"
102 if [[ ! -z "$failed_kud_tests" ]]; then
103 printf "Test cases failed:${failed_kud_tests}\n"
107 printf "All test cases passed\n"
110 printf "\n\nBeginning BMH E2E Test Teardown\n\n"
111 # Workaround known issue with emcoctl resource deletion by retrying
112 # until a 404 is received.
113 pushd /opt/kud/multi-cluster/${CLUSTER_NAME}/artifacts/addons
114 until [[ $(/opt/kud/multi-cluster/${CLUSTER_NAME}/artifacts/emcoctl.sh delete -f composite-app.yaml -v values-resources.yaml |
115 awk '/Response Code:/ {code=$3} END{print code}') =~ 404 ]]; do
116 echo "Waiting for KUD addon resources to terminate"
119 until [[ $(/opt/kud/multi-cluster/${CLUSTER_NAME}/artifacts/emcoctl.sh delete -f composite-app.yaml -v values.yaml |
120 awk '/Response Code:/ {code=$3} END{print code}') =~ 404 ]]; do
121 echo "Waiting for KUD addons to terminate"
124 until [[ $(/opt/kud/multi-cluster/${CLUSTER_NAME}/artifacts/emcoctl.sh delete -f prerequisites.yaml -v values.yaml |
125 awk '/Response Code:/ {code=$3} END{print code}') =~ 404 ]]; do
126 echo "Waiting for KUD addons to terminate"
130 kubectl delete -f e2etest/test_bmh_provisioning_cr.yaml
131 kubectl delete job kud-${CLUSTER_NAME}
132 kubectl delete --ignore-not-found=true configmap ${CLUSTER_NAME}-configmap
133 rm -rf /opt/kud/multi-cluster/${CLUSTER_NAME}
134 rm -rf /opt/kud/multi-cluster/addons