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";
46 echo "Building KUD image"
47 git clone https://github.com/onap/multicloud-k8s.git
50 --build-arg http_proxy=${http_proxy} \
51 --build-arg HTTP_PROXY=${HTTP_PROXY} \
52 --build-arg https_proxy=${https_proxy} \
53 --build-arg HTTPS_PROXY=${HTTPS_PROXY} \
54 --build-arg no_proxy=${no_proxy} \
55 --build-arg NO_PROXY=${NO_PROXY} \
56 -t github.com/onap/multicloud-k8s:latest . -f kud/build/Dockerfile
59 # Create ssh-key-secret required for job
60 kubectl create secret generic ssh-key-secret --from-file=id_rsa=/root/.ssh/id_rsa --from-file=id_rsa.pub=/root/.ssh/id_rsa.pub
62 # Create provisioning CR file for testing
63 cat <<EOF > e2e_test_provisioning_cr.yaml
64 apiVersion: bpa.akraino.org/v1alpha1
67 name: e2e-test-provisioning
74 mac-address: ${masterMAC}
77 mac-address: ${workerMAC}
79 kubectl apply -f e2e_test_provisioning_cr.yaml
82 #Check Status of kud job pod
85 while [[ $status == "Running" ]]
87 echo "KUD install job still running"
89 stats=$(kubectl get pods |grep -i kud-cluster-test)
90 status=$(echo $stats | cut -d " " -f 3)
93 if [[ $status == "Completed" ]];
95 printf "KUD Install Job completed\n"
97 printf "KUD Install Job failed\n"
100 printf "Checking cluster status\n"
102 source ../../env/lib/common.sh
103 CLUSTER_NAME=cluster-test
104 KUBECONFIG=--kubeconfig=/opt/kud/multi-cluster/${CLUSTER_NAME}/artifacts/admin.conf
105 APISERVER=$(kubectl ${KUBECONFIG} config view --minify -o jsonpath='{.clusters[0].cluster.server}')
106 TOKEN=$(kubectl ${KUBECONFIG} get secret $(kubectl ${KUBECONFIG} get serviceaccount default -o jsonpath='{.secrets[0].name}') -o jsonpath='{.data.token}' | base64 --decode )
107 call_api $APISERVER/api --header "Authorization: Bearer $TOKEN" --insecure
111 printf "\nKubernetes Cluster Install did not complete successfully\n"
113 printf "\nKubernetes Cluster Install was successful\n"
117 printf "\n\nBeginning E2E Test Teardown\n\n"
118 kubectl delete -f e2e_test_provisioning_cr.yaml
119 kubectl delete job kud-cluster-test
120 kubectl delete secret ssh-key-secret
121 rm e2e_test_provisioning_cr.yaml
122 rm -rf /multi-cluster/cluster-test
123 rm /opt/icn/dhcp/dhcpd.leases
124 rm -rf multicloud-k8s