beef up the AI/ML framework tests by adding InfluxDB as data source and populate...
[it/test.git] / XTesting / XTesting-demo / demo.sh
1 #! /bin/bash
2 set -x
3
4 echo "This is to demonstrate the XTesting work flow against the OSC RIC platform deployment and perform health check"
5
6 if [ $# -lt 2 ]
7 then 
8         echo "Usage: $0 target-ip private-key-file-path [working-directory]"
9         exit 1
10 fi
11
12 # pick up the input parameters from command line
13 IP=$1
14 KEYFILE=$2
15 ORIG=$PWD
16 if [ $# -ge 3 ]
17 then
18         WORKDIR=$3
19 else
20         WORKDIR=$PWD
21 fi
22
23 # make the working directory if it's not there yet
24 if [ ! -d $WORKDIR ]
25 then 
26         mkdir -p $WORKDIR
27 fi
28
29 # copy over the health check test case to the working directory
30 cp healthcheck.robot $WORKDIR
31
32 cd $WORKDIR
33
34 # replace it with the target IP address for health check
35 sed -i "s/TARGET-IP/${IP}/" healthcheck.robot
36
37 ###### step 1 deploy Kubernetes cluster and obtain the Kube config
38
39 # remove the old one if it's already there
40 if [ -d kubeadm ]
41 then
42         rm -rf kubeadm
43 fi
44
45 # copy over the content to build the kubeadm container
46 mkdir kubeadm
47 cp -r $ORIG/../kubeadm/* kubeadm/
48
49 cd 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
55
56 # copy the private key to the inventory/sample folder as id_rsa
57 cp $KEYFILE id_rsa
58 chmod 400 id_rsa
59
60 # build the Docker image
61 docker build -t kubeadm .
62
63 # run the docker container to deploy Kubernetes onto the SUT specified by the IP address
64 docker run -v ~/.kube:/kubeadm/config kubeadm 
65
66 ###### step 2 complete the deployment based on the Kube config from step 1
67
68 cd $WORKDIR
69 # remove the old one if it's already there
70 if [ -d richelm ]
71 then
72         rm -rf richelm
73 fi
74
75 #copy over the content to build the richelm container
76 mkdir richelm
77 cp -r $ORIG/../richelm/* richelm/
78
79 #build the container
80 cd richelm && ./build.sh static
81
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 
84
85 # sometimes some RIC platform containers are not up right away so wait a bit
86 sleep 60        
87
88 cd $WORKDIR
89 ###### step 3 run the health check test case 
90 ansible-playbook healthcheck.robot
91
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}:~
95
96 # copy remote IP to the hosts.yaml file
97 cd $ORIG/../xapp
98 echo "${IP}" >> hosts.yaml
99
100 # onboard/install the kpimon-go xApp on remote
101 ansible-playbook -b -v  -i hosts.yaml --become --private-key $KEYFILE cluster.yaml