X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=XTesting%2FXTesting-demo%2Fdemo.sh;fp=XTesting%2FXTesting-demo%2Fdemo.sh;h=8cac36a3d964a1bc47b37f285130cf5e87b6e41f;hb=a1d10aced510b9794aee3006dc12a97f7514bcae;hp=0000000000000000000000000000000000000000;hpb=8cd731c571e117533f5c8a84690fbc7ffda0956b;p=it%2Ftest.git diff --git a/XTesting/XTesting-demo/demo.sh b/XTesting/XTesting-demo/demo.sh new file mode 100755 index 0000000..8cac36a --- /dev/null +++ b/XTesting/XTesting-demo/demo.sh @@ -0,0 +1,90 @@ +#! /bin/bash +set -x + +echo "This is to demonstrate the XTesting work flow against the OSC RIC platform deployment and perform health check" + +if [ $# -lt 2 ] +then + echo "Usage: $0 target-ip private-key-file-path [working-directory]" + exit 1 +fi + +# pick up the input parameters from command line +IP=$1 +KEYFILE=$2 +ORIG=$PWD +if [ $# -ge 3 ] +then + WORKDIR=$3 +else + WORKDIR=$PWD +fi + +# make the working directory if it's not there yet +if [ ! -d $WORKDIR ] +then + mkdir -p $WORKDIR +fi + +# copy over the health check test case to the working directory +cp healthcheck.robot $WORKDIR + +cd $WORKDIR + +# replace it with the target IP address for health check +sed -i "s/TARGET-IP/${IP}/" healthcheck.robot + +###### step 1 deploy Kubernetes cluster and obtain the Kube config + +# remove the old one if it's already there +if [ -d kubeadm ] +then + rm -rf kubeadm +fi + +# copy over the content to build the kubeadm container +mkdir kubeadm +cp -r $ORIG/../kubeadm/* kubeadm/ + +cd kubeadm +# update the host IP in the environment file +TMPFILE=/tmp/tmp`date +%s` +cat sample_env | sed -e '/ANSIBLE_HOST_IP/d' > $TMPFILE +echo "ANSIBLE_HOST_IP=${IP}" > sample_env +cat $TMPFILE >> sample_env + +# copy the private key to the inventory/sample folder as id_rsa +cp $KEYFILE id_rsa +chmod 400 id_rsa + +# build the Docker image +docker build -t kubeadm . + +# run the docker container to deploy Kubernetes onto the SUT specified by the IP address +docker run -v ~/.kube:/kubeadm/config kubeadm + +###### step 2 complete the deployment based on the Kube config from step 1 + +cd $WORKDIR +# remove the old one if it's already there +if [ -d richelm ] +then + rm -rf richelm +fi + +#copy over the content to build the richelm container +mkdir richelm +cp -r $ORIG/../richelm/* richelm/ + +#build the container +cd richelm && ./build.sh static + +#run the container with the kubeconfig to complete the RIC platform deployment +sudo docker run -ti --rm -w /apps -v ~/.kube:/root/.kube -t richelmlegacy:1.19.16 + +# sometimes some RIC platform containers are not up right away so wait a bit +sleep 60 + +cd $WORKDIR +###### step 3 run the health check test case to complete the demo +ansible-playbook healthcheck.robot