4 echo "This is to demonstrate the XTesting work flow against the OSC RIC platform deployment and perform health check"
8 echo "Usage: $0 target-ip private-key-file-path [working-directory]"
12 # pick up the input parameters from command line
23 # make the working directory if it's not there yet
29 # copy over the health check test case to the working directory
30 cp healthcheck.robot $WORKDIR
34 # replace it with the target IP address for health check
35 sed -i "s/TARGET-IP/${IP}/" healthcheck.robot
37 ###### step 1 deploy Kubernetes cluster and obtain the Kube config
39 # remove the old one if it's already there
45 # copy over the content to build the kubeadm container
47 cp -r $ORIG/../kubeadm/* kubeadm/
50 # update the host IP in the environment file
51 TMPFILE=/tmp/tmp`date +%s`
52 cat sample_env | sed -e '/ANSIBLE_HOST_IP/d' > $TMPFILE
53 echo "ANSIBLE_HOST_IP=${IP}" > sample_env
54 cat $TMPFILE >> sample_env
56 # copy the private key to the inventory/sample folder as id_rsa
60 # build the Docker image
61 docker build -t kubeadm .
63 # run the docker container to deploy Kubernetes onto the SUT specified by the IP address
64 docker run -v ~/.kube:/kubeadm/config kubeadm
66 ###### step 2 complete the deployment based on the Kube config from step 1
69 # remove the old one if it's already there
75 #copy over the content to build the richelm container
77 cp -r $ORIG/../richelm/* richelm/
80 cd richelm && ./build.sh static
82 #run the container with the kubeconfig to complete the RIC platform deployment
83 sudo docker run -ti --rm -w /apps -v ~/.kube:/root/.kube -t richelmlegacy:1.19.16
85 # sometimes some RIC platform containers are not up right away so wait a bit
89 ###### step 3 run the health check test case
90 ansible-playbook healthcheck.robot
92 ###### step 4 onboard/install the kpimon-go xApp on the remote host
93 # copy over the deploy.sh to remote
94 scp -o StrictHostKeyChecking=no -i $KEYFILE -q $ORIG/../xapp/deploy.sh root@${IP}:~
96 # copy remote IP to the hosts.yaml file
98 echo "${IP}" >> hosts.yaml
100 # onboard/install the kpimon-go xApp on remote
101 ansible-playbook -b -v -i hosts.yaml --become --private-key $KEYFILE cluster.yaml