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}
67 kubectl apply -f e2etest/e2e_test_provisioning_cr.yaml
70 #Check Status of kud job pod
73 while [[ $status == "Running" ]]
75 echo "KUD install job still running"
77 stats=$(kubectl get pods |grep -i kud-${CLUSTER_NAME})
78 status=$(echo $stats | cut -d " " -f 3)
81 if [[ $status == "Completed" ]];
83 printf "KUD Install Job completed\n"
84 printf "Checking cluster status\n"
86 source ../../env/lib/common.sh
87 KUBECONFIG=--kubeconfig=/opt/kud/multi-cluster/${CLUSTER_NAME}/artifacts/admin.conf
88 APISERVER=$(kubectl ${KUBECONFIG} config view --minify -o jsonpath='{.clusters[0].cluster.server}')
89 TOKEN=$(kubectl ${KUBECONFIG} get secret $(kubectl ${KUBECONFIG} get serviceaccount default -o jsonpath='{.secrets[0].name}') -o jsonpath='{.data.token}' | base64 --decode )
90 if ! call_api $APISERVER/api --header "Authorization: Bearer $TOKEN" --insecure;
92 printf "\nKubernetes Cluster Install did not complete successfully\n"
94 printf "\nKubernetes Cluster Install was successful\n"
98 printf "KUD Install Job failed\n"
102 #Print logs of Job Pod
103 jobPod=$(kubectl get pods|grep kud-${CLUSTER_NAME})
104 podName=$(echo $jobPod | cut -d " " -f 1)
105 printf "\nNow Printing Job pod logs\n"
106 kubectl logs $podName
109 printf "\n\nBeginning E2E Test Teardown\n\n"
110 kubectl delete -f e2etest/e2e_test_provisioning_cr.yaml
111 kubectl delete job kud-${CLUSTER_NAME}
112 kubectl delete configmap ${CLUSTER_NAME}-configmap
113 rm e2etest/e2e_test_provisioning_cr.yaml
114 rm -rf /opt/kud/multi-cluster/${CLUSTER_NAME}
115 rm /opt/icn/dhcp/dhcpd.leases