4 CLUSTER_NAME=cluster-test
5 NUM_MASTERS=${NUM_MASTERS:-"1"}
6 NUM_WORKERS=${NUM_WORKERS:-"1"}
8 # Create Fake DHCP File
10 cat <<EOF > /opt/icn/dhcp/dhcpd.leases
11 # The format of this file is documented in the dhcpd.leases(5) manual page.
12 # This lease file was written by isc-dhcp-4.3.5
14 # authoring-byte-order entry is generated, DO NOT DELETE
15 authoring-byte-order little-endian;
18 for ((master=0;master<NUM_MASTERS;++master)); do
19 lease=$(virsh net-dhcp-leases baremetal |grep "master-${master}")
20 mac=$(echo $lease | cut -d " " -f 3)
21 ip=$(echo $lease | cut -d " " -f 5)
23 cat <<EOF >> /opt/icn/dhcp/dhcpd.leases
25 starts 4 2019/08/08 22:32:49;
26 ends 4 2019/08/08 23:52:49;
27 cltt 4 2019/08/08 22:32:49;
29 next binding state free;
30 rewind binding state free;
31 hardware ethernet ${mac};
32 client-hostname "master-${master}";
36 for ((worker=0;worker<NUM_WORKERS;++worker)); do
37 lease=$(virsh net-dhcp-leases baremetal |grep "worker-${worker}")
38 mac=$(echo $lease | cut -d " " -f 3)
39 ip=$(echo $lease | cut -d " " -f 5)
41 cat <<EOF >> /opt/icn/dhcp/dhcpd.leases
43 starts 4 2019/08/08 22:32:49;
44 ends 4 2019/08/08 23:52:49;
45 cltt 4 2019/08/08 22:32:49;
47 next binding state free;
48 rewind binding state free;
49 hardware ethernet ${mac};
50 client-hostname "worker-${worker}";
55 # Create provisioning CR file for testing
56 cat <<EOF > e2etest/e2e_test_provisioning_cr.yaml
57 apiVersion: bpa.akraino.org/v1alpha1
60 name: e2e-test-provisioning
62 cluster: ${CLUSTER_NAME}
67 for ((master=0;master<NUM_MASTERS;++master)); do
68 lease=$(virsh net-dhcp-leases baremetal |grep "master-${master}")
69 mac=$(echo $lease | cut -d " " -f 3)
70 cat <<EOF >> e2etest/e2e_test_provisioning_cr.yaml
75 cat <<EOF >> e2etest/e2e_test_provisioning_cr.yaml
78 for ((worker=0;worker<NUM_WORKERS;++worker)); do
79 lease=$(virsh net-dhcp-leases baremetal |grep "worker-${worker}")
80 mac=$(echo $lease | cut -d " " -f 3)
81 cat <<EOF >> e2etest/e2e_test_provisioning_cr.yaml
86 cat <<EOF >> e2etest/e2e_test_provisioning_cr.yaml
90 kubectl apply -f e2etest/e2e_test_provisioning_cr.yaml
93 #Check Status of kud job pod
96 while [[ $status == "Running" ]]
98 echo "KUD install job still running"
100 stats=$(kubectl get pods |grep -i kud-${CLUSTER_NAME})
101 status=$(echo $stats | cut -d " " -f 3)
104 if [[ $status == "Completed" ]];
106 printf "KUD Install Job completed\n"
107 printf "Checking cluster status\n"
109 source ../../env/lib/common.sh
110 KUBECONFIG=--kubeconfig=/opt/kud/multi-cluster/${CLUSTER_NAME}/artifacts/admin.conf
111 APISERVER=$(kubectl ${KUBECONFIG} config view --minify -o jsonpath='{.clusters[0].cluster.server}')
112 TOKEN=$(kubectl ${KUBECONFIG} get secret $(kubectl ${KUBECONFIG} get serviceaccount default -o jsonpath='{.secrets[0].name}') -o jsonpath='{.data.token}' | base64 --decode )
113 if ! call_api $APISERVER/api --header "Authorization: Bearer $TOKEN" --insecure;
115 printf "\nKubernetes Cluster Install did not complete successfully\n"
117 printf "\nKubernetes Cluster Install was successful\n"
121 printf "KUD Install Job failed\n"
125 #Print logs of Job Pod
126 jobPod=$(kubectl get pods|grep kud-${CLUSTER_NAME})
127 podName=$(echo $jobPod | cut -d " " -f 1)
128 printf "\nNow Printing Job pod logs\n"
129 kubectl logs $podName
132 printf "\n\nBeginning E2E Test Teardown\n\n"
133 kubectl delete -f e2etest/e2e_test_provisioning_cr.yaml
134 kubectl delete job kud-${CLUSTER_NAME}
135 kubectl delete --ignore-not-found=true configmap ${CLUSTER_NAME}-configmap
136 rm e2etest/e2e_test_provisioning_cr.yaml
137 rm -rf /opt/kud/multi-cluster/${CLUSTER_NAME}
138 rm /opt/icn/dhcp/dhcpd.leases