4 CLUSTER_NAME=cluster-test
6 # Get MAC and IP addresses of VMs provisioned by metal3
7 master0=$(virsh net-dhcp-leases baremetal |grep master-0)
8 masterMAC=$(echo $master0 | cut -d " " -f 3)
9 masterIP=$(echo $master0 | cut -d " " -f 5)
10 masterIP="${masterIP%%/*}"
12 worker0=$(virsh net-dhcp-leases baremetal |grep worker-0)
13 workerMAC=$(echo $worker0 | cut -d " " -f 3)
14 workerIP=$(echo $worker0 | cut -d " " -f 5)
15 workerIP="${workerIP%%/*}"
17 # Create Fake DHCP File
18 mkdir -p /opt/icn/dhcp
19 cat <<EOF > /opt/icn/dhcp/dhcpd.leases
20 # The format of this file is documented in the dhcpd.leases(5) manual page.
21 # This lease file was written by isc-dhcp-4.3.5
23 # authoring-byte-order entry is generated, DO NOT DELETE
24 authoring-byte-order little-endian;
27 starts 4 2019/08/08 22:32:49;
28 ends 4 2019/08/08 23:52:49;
29 cltt 4 2019/08/08 22:32:49;
31 next binding state free;
32 rewind binding state free;
33 hardware ethernet ${masterMAC};
34 client-hostname "master-0";
37 starts 4 2019/08/08 22:32:49;
38 ends 4 2019/08/08 23:52:49;
39 cltt 4 2019/08/08 22:32:49;
41 next binding state free;
42 rewind binding state free;
43 hardware ethernet ${workerMAC};
44 client-hostname "worker-0";
48 # Create provisioning CR file for testing
49 cat <<EOF > e2etest/e2e_test_provisioning_cr.yaml
50 apiVersion: bpa.akraino.org/v1alpha1
53 name: e2e-test-provisioning
55 cluster: ${CLUSTER_NAME}
60 mac-address: ${masterMAC}
63 mac-address: ${workerMAC}
65 kubectl apply -f e2etest/e2e_test_provisioning_cr.yaml
68 #Check Status of kud job pod
71 while [[ $status == "Running" ]]
73 echo "KUD install job still running"
75 stats=$(kubectl get pods |grep -i kud-${CLUSTER_NAME})
76 status=$(echo $stats | cut -d " " -f 3)
79 if [[ $status == "Completed" ]];
81 printf "KUD Install Job completed\n"
82 printf "Checking cluster status\n"
84 source ../../env/lib/common.sh
85 KUBECONFIG=--kubeconfig=/opt/kud/multi-cluster/${CLUSTER_NAME}/artifacts/admin.conf
86 APISERVER=$(kubectl ${KUBECONFIG} config view --minify -o jsonpath='{.clusters[0].cluster.server}')
87 TOKEN=$(kubectl ${KUBECONFIG} get secret $(kubectl ${KUBECONFIG} get serviceaccount default -o jsonpath='{.secrets[0].name}') -o jsonpath='{.data.token}' | base64 --decode )
88 if ! call_api $APISERVER/api --header "Authorization: Bearer $TOKEN" --insecure;
90 printf "\nKubernetes Cluster Install did not complete successfully\n"
92 printf "\nKubernetes Cluster Install was successful\n"
96 printf "KUD Install Job failed\n"
100 #Print logs of Job Pod
101 jobPod=$(kubectl get pods|grep kud-${CLUSTER_NAME})
102 podName=$(echo $jobPod | cut -d " " -f 1)
103 printf "\nNow Printing Job pod logs\n"
104 kubectl logs $podName
107 printf "\n\nBeginning E2E Test Teardown\n\n"
108 kubectl delete -f e2etest/e2e_test_provisioning_cr.yaml
109 kubectl delete job kud-${CLUSTER_NAME}
110 kubectl delete configmap ${CLUSTER_NAME}-configmap
111 rm e2etest/e2e_test_provisioning_cr.yaml
112 rm -rf /opt/kud/multi-cluster/${CLUSTER_NAME}
113 rm /opt/icn/dhcp/dhcpd.leases