Skip to content

Commit

Permalink
sctp test added in k3s-base-sanity
Browse files Browse the repository at this point in the history
  • Loading branch information
nik-netlox committed Mar 26, 2024
1 parent fdd1c25 commit 5fa6209
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/k3s-base-sanity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
with:
go-version: '>=1.18.0'
- run: sudo apt-get update
- run: sudo apt-get -y install bridge-utils net-tools iperf curl wget clang-10 llvm libelf-dev gcc-multilib libpcap-dev linux-tools-$(uname -r) elfutils dwarves git libbsd-dev bridge-utils unzip build-essential bison flex iperf iproute2 nodejs socat ethtool
- run: sudo apt-get -y install bridge-utils net-tools iperf curl lksctp-tools wget clang-10 llvm libelf-dev gcc-multilib libpcap-dev linux-tools-$(uname -r) elfutils dwarves git libbsd-dev bridge-utils unzip build-essential bison flex iperf iproute2 nodejs socat ethtool
- run: docker pull ghcr.io/loxilb-io/loxilb:latest
- run: docker run -u root --cap-add SYS_ADMIN --restart unless-stopped --privileged -dit -v /dev/log:/dev/log --name loxilb ghcr.io/loxilb-io/loxilb:latest
- run: pwd && ls && sudo mkdir /opt/loxilb/ && sudo -E env "PATH=$PATH" make docker-cp
Expand Down
3 changes: 2 additions & 1 deletion cicd/k3s-base-sanity/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ kubectl $KUBECONFIG apply -f nginx-svc-lb1.yml
sleep 10
kubectl $KUBECONFIG apply -f udp-svc-lb.yml
sleep 30

kubectl $KUBECONFIG apply -f sctp-svc-lb.yml
sleep 10
# External LB service must be created by now
kubectl $KUBECONFIG get svc

Expand Down
6 changes: 6 additions & 0 deletions cicd/k3s-base-sanity/input
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@






33 changes: 33 additions & 0 deletions cicd/k3s-base-sanity/sctp-svc-lb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: v1
kind: Service
metadata:
name: sctp-lb1
annotations:
loxilb.io/lbmode: "fullnat"
loxilb.io/liveness: "yes"
spec:
externalTrafficPolicy: Local
loadBalancerClass: loxilb.io/loxilb
selector:
what: sctp-test
ports:
- port: 55003
protocol: SCTP
targetPort: 9999
type: LoadBalancer
---
apiVersion: v1
kind: Pod
metadata:
name: sctp-test
labels:
what: sctp-test
spec:
containers:
- name: sctp-test
image: loxilbio/sctp-darn:latest
imagePullPolicy: Always
#command: ["/bin/sh", "-ec", "while :; do echo '.'; sleep 6 ; done"]
command: ["sctp_darn","-H", "0.0.0.0","-P", "9999", "-l"]
ports:
- containerPort: 9999
47 changes: 42 additions & 5 deletions cicd/k3s-base-sanity/validation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ echo "********************"

out=$($hexec user curl -s --connect-timeout 10 http://$extIP:55002)
if [[ ${out} == *"Welcome to nginx"* ]]; then
echo "cluster-k3s (kube-loxilb) tcp [OK]"
echo "cluster-k3s (kube-loxilb) tcp [OK]"
else
echo "cluster-k3s (kube-loxilb) tcp [FAILED]"
echo "cluster-k3s (kube-loxilb) tcp [FAILED]"
code=1
fi

Expand All @@ -97,17 +97,54 @@ done

out=$($hexec user timeout 30 ../common/udp_client $extIP 55003)
if [[ ${out} == *"Client"* ]]; then
echo "cluster-k3s (kube-loxilb) udp [OK]"
echo "cluster-k3s (kube-loxilb) udp [OK]"
else
echo "cluster-k3s (kube-loxilb) udp [FAILED]"
echo "cluster-k3s (kube-loxilb) udp [FAILED]"
code=1
fi

for((i=0; i<120; i++))
do
extLB=$(sudo kubectl $KUBECONFIG get svc | grep "sctp-lb")
read -a strarr <<< "$extLB"
len=${#strarr[*]}
if [[ $((len)) -lt 6 ]]; then
echo "Can't find sctp-lb service"
sleep 1
continue
fi
if [[ ${strarr[3]} != *"none"* ]]; then
extIP="$(cut -d'-' -f2 <<<${strarr[3]})"
break
fi
echo "No external LB allocated"
sleep 1
done

$hexec user timeout 5 stdbuf -oL sctp_darn -H 0.0.0.0 -h $extIP -p 55003 -s < input > output
sleep 5
exp="New connection, peer addresses
$extIP:55003"

res=`cat output | grep -A 1 "New connection, peer addresses"`
#echo "Result"
#echo $res
#echo "Expected"
#echo $exp
sudo rm -rf output
if [[ "$res" == "$exp" ]]; then
#echo $res
echo "cluster-k3s (kube-loxilb) sctp [OK]"
else
echo "cluster-k3s (kube-loxilb) sctp [NOK]"
print_debug_info
code=1
fi
if [[ $code -eq 1 ]]; then
print_debug_info
echo "cluster-k3s failed"
touch /vagrant/error
exit 1
fi


exit

0 comments on commit 5fa6209

Please sign in to comment.