From 9faac0713ae45406a4170eae58b75536436cc0db Mon Sep 17 00:00:00 2001 From: Trekkie Coder Date: Wed, 20 Nov 2024 14:50:54 +0900 Subject: [PATCH] loxilb-io/loxilb#864 added cicd scripts --- cicd/tcplb-src/config.sh | 42 +++++++++++++++++++++++ cicd/tcplb-src/rmconfig.sh | 18 ++++++++++ cicd/tcplb-src/validation.sh | 64 ++++++++++++++++++++++++++++++++++++ 3 files changed, 124 insertions(+) create mode 100755 cicd/tcplb-src/config.sh create mode 100755 cicd/tcplb-src/rmconfig.sh create mode 100755 cicd/tcplb-src/validation.sh diff --git a/cicd/tcplb-src/config.sh b/cicd/tcplb-src/config.sh new file mode 100755 index 000000000..fbf14d197 --- /dev/null +++ b/cicd/tcplb-src/config.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +source ../common.sh + +echo "#########################################" +echo "Spawning all hosts" +echo "#########################################" + +spawn_docker_host --dock-type loxilb --dock-name llb1 +spawn_docker_host --dock-type host --dock-name l3h1 +spawn_docker_host --dock-type host --dock-name l3ep1 +spawn_docker_host --dock-type host --dock-name l3ep2 +spawn_docker_host --dock-type host --dock-name l3ep3 + +echo "#########################################" +echo "Connecting and configuring hosts" +echo "#########################################" + + +connect_docker_hosts l3h1 llb1 +connect_docker_hosts l3ep1 llb1 +connect_docker_hosts l3ep2 llb1 +connect_docker_hosts l3ep3 llb1 + +sleep 5 + +#L3 config +config_docker_host --host1 l3h1 --host2 llb1 --ptype phy --addr 10.10.10.1/24 --gw 10.10.10.254 +config_docker_host --host1 l3ep1 --host2 llb1 --ptype phy --addr 31.31.31.1/24 --gw 31.31.31.254 +config_docker_host --host1 l3ep2 --host2 llb1 --ptype phy --addr 32.32.32.1/24 --gw 32.32.32.254 +config_docker_host --host1 l3ep3 --host2 llb1 --ptype phy --addr 33.33.33.1/24 --gw 33.33.33.254 +config_docker_host --host1 llb1 --host2 l3h1 --ptype phy --addr 10.10.10.254/24 +config_docker_host --host1 llb1 --host2 l3ep1 --ptype phy --addr 31.31.31.254/24 +config_docker_host --host1 llb1 --host2 l3ep2 --ptype phy --addr 32.32.32.254/24 +config_docker_host --host1 llb1 --host2 l3ep3 --ptype phy --addr 33.33.33.254/24 + +$dexec llb1 ip addr add 10.10.10.3/32 dev lo + +sleep 5 +create_lb_rule llb1 20.20.20.1 --tcp=2020:8080 --endpoints=31.31.31.1:1,32.32.32.1:1,33.33.33.1:1 --sources=10.10.10.1/32 +create_lb_rule llb1 10.10.10.254 --tcp=2020:8080 --endpoints=31.31.31.1:1,32.32.32.1:1,33.33.33.1:1 --sources=10.10.10.1/32 +create_lb_rule llb1 10.10.10.3 --tcp=2020:8080 --endpoints=31.31.31.1:1,32.32.32.1:1,33.33.33.1:1 --sources=10.10.10.1/32 diff --git a/cicd/tcplb-src/rmconfig.sh b/cicd/tcplb-src/rmconfig.sh new file mode 100755 index 000000000..9ea80577f --- /dev/null +++ b/cicd/tcplb-src/rmconfig.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +source ../common.sh + +disconnect_docker_hosts l3h1 llb1 +disconnect_docker_hosts l3ep1 llb1 +disconnect_docker_hosts l3ep2 llb1 +disconnect_docker_hosts l3ep3 llb1 + +delete_docker_host llb1 +delete_docker_host l3h1 +delete_docker_host l3ep1 +delete_docker_host l3ep2 +delete_docker_host l3ep3 + +echo "#########################################" +echo "Deleted testbed" +echo "#########################################" diff --git a/cicd/tcplb-src/validation.sh b/cicd/tcplb-src/validation.sh new file mode 100755 index 000000000..e7447fb9d --- /dev/null +++ b/cicd/tcplb-src/validation.sh @@ -0,0 +1,64 @@ +#!/bin/bash +source ../common.sh +echo SCENARIO-tcplb +$hexec l3ep1 node ../common/tcp_server.js server1 & +$hexec l3ep2 node ../common/tcp_server.js server2 & +$hexec l3ep3 node ../common/tcp_server.js server3 & + +sleep 5 +code=0 +servIP=( "10.10.10.254" "20.20.20.1" "10.10.10.3" ) +servArr=( "server1" "server2" "server3" ) +ep=( "31.31.31.1" "32.32.32.1" "33.33.33.1" ) +j=0 +waitCount=0 +while [ $j -le 2 ] +do + res=$($hexec l3h1 curl --max-time 10 -s ${ep[j]}:8080) + #echo $res + if [[ $res == "${servArr[j]}" ]] + then + echo "$res UP" + j=$(( $j + 1 )) + else + echo "Waiting for ${servArr[j]}(${ep[j]})" + waitCount=$(( $waitCount + 1 )) + if [[ $waitCount == 10 ]]; + then + echo "All Servers are not UP" + echo SCENARIO-tcplb [FAILED] + sudo killall -9 node 2>&1 > /dev/null + exit 1 + fi + fi + sleep 1 +done + +for k in {0..2} +do +echo "Testing Service IP: ${servIP[k]}" +lcode=0 +for i in {1..4} +do +for j in {0..2} +do + res=$($hexec l3h1 curl --max-time 10 -s ${servIP[k]}:2020) + echo $res + if [[ $res != "${servArr[j]}" ]] + then + lcode=1 + fi + sleep 1 +done +done +if [[ $lcode == 0 ]] +then + echo SCENARIO-tcplb with ${servIP[k]} [OK] +else + echo SCENARIO-tcplb with ${servIP[k]} [FAILED] + code=1 +fi +done + +sudo killall -9 node 2>&1 > /dev/null +exit $code