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