3 # Get MAC and IP addresses of VMs provisioned by metal3
4 master0=$(virsh net-dhcp-leases baremetal |grep master-0)
5 masterMAC=$(echo $master0 | cut -d " " -f 3)
6 masterIP=$(echo $master0 | cut -d " " -f 5)
7 masterIP="${masterIP%%/*}"
9 worker0=$(virsh net-dhcp-leases baremetal |grep worker-0)
10 workerMAC=$(echo $worker0 | cut -d " " -f 3)
11 workerIP=$(echo $worker0 | cut -d " " -f 5)
12 workerIP="${workerIP%%/*}"
14 # Create Fake DHCP File
15 mkdir -p /opt/icn/dhcp
16 cat <<EOF > /opt/icn/dhcp/dhcpd.leases
17 # The format of this file is documented in the dhcpd.leases(5) manual page.
18 # This lease file was written by isc-dhcp-4.3.5
20 # authoring-byte-order entry is generated, DO NOT DELETE
21 authoring-byte-order little-endian;
24 starts 4 2019/08/08 22:32:49;
25 ends 4 2019/08/08 23:52:49;
26 cltt 4 2019/08/08 22:32:49;
28 next binding state free;
29 rewind binding state free;
30 hardware ethernet ${masterMAC};
31 client-hostname "master-0";
34 starts 4 2019/08/08 22:32:49;
35 ends 4 2019/08/08 23:52:49;
36 cltt 4 2019/08/08 22:32:49;
38 next binding state free;
39 rewind binding state free;
40 hardware ethernet ${workerMAC};
41 client-hostname "worker-0";
45 # Create provisioning CR file for testing
46 cat <<EOF > e2etest/e2e_test_provisioning_cr.yaml
47 apiVersion: bpa.akraino.org/v1alpha1
50 name: e2e-test-provisioning
57 mac-address: ${masterMAC}
60 mac-address: ${workerMAC}
62 kubectl apply -f e2etest/e2e_test_provisioning_cr.yaml
65 #Check Status of kud job pod
68 while [[ $status == "Running" ]]
70 echo "KUD install job still running"
72 stats=$(kubectl get pods |grep -i kud-cluster-test)
73 status=$(echo $stats | cut -d " " -f 3)
76 if [[ $status == "Completed" ]];
78 printf "KUD Install Job completed\n"
79 printf "Checking cluster status\n"
81 source ../../env/lib/common.sh
82 CLUSTER_NAME=cluster-test
83 KUBECONFIG=--kubeconfig=/opt/kud/multi-cluster/${CLUSTER_NAME}/artifacts/admin.conf
84 APISERVER=$(kubectl ${KUBECONFIG} config view --minify -o jsonpath='{.clusters[0].cluster.server}')
85 TOKEN=$(kubectl ${KUBECONFIG} get secret $(kubectl ${KUBECONFIG} get serviceaccount default -o jsonpath='{.secrets[0].name}') -o jsonpath='{.data.token}' | base64 --decode )
86 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 printf "\n\nBeginning E2E Test Teardown\n\n"
101 kubectl delete -f e2etest/e2e_test_provisioning_cr.yaml
102 kubectl delete job kud-cluster-test
103 kubectl delete configmap cluster-test-configmap
104 rm e2etest/e2e_test_provisioning_cr.yaml
105 rm -rf /opt/kud/multi-cluster/cluster-test
106 rm /opt/icn/dhcp/dhcpd.leases