Skip to content

Commit

Permalink
tests/k8s.sh: Fix iperf server setup
Browse files Browse the repository at this point in the history
This commit fixes the iperf server setup.

Signed-off-by: Or Ozeri <[email protected]>
  • Loading branch information
orozery committed Oct 8, 2023
1 parent 3287f9d commit a13d6ff
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions tests/k8s.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,38 +32,38 @@ function test_k8s {
kubectl wait --for=condition=ready pod/gwctl

# install iperf3 and jq
kubectl exec -it gwctl -- apk add iperf3 jq
kubectl exec -i gwctl -- apk add iperf3 jq

# start iperf3 server
kubectl exec -it gwctl -- iperf3 -s -D -p 1234
kubectl exec -i gwctl -- iperf3 -s -D -p 1234

# expose iperf3 server
kubectl expose pod gwctl --name=foo --port=80 --target-port=1234

# wait for API server to come up
kubectl exec -it gwctl -- timeout 30 sh -c 'until gwctl get peer; do sleep 0.1; done > /dev/null 2>&1'
kubectl exec -i gwctl -- timeout 30 sh -c 'until gwctl get peer; do sleep 0.1; done > /dev/null 2>&1'

# export iperf server
kubectl exec -it gwctl -- gwctl create export --name foo --host foo --port 80
kubectl exec -i gwctl -- gwctl create export --name foo --host foo --port 80

# import
kubectl exec -it gwctl -- gwctl create peer --host cl-dataplane --port 443 --name peer1
kubectl exec -it gwctl -- gwctl create import --name foo --host bla --port 9999
kubectl exec -it gwctl -- gwctl create binding --import foo --peer peer1
kubectl exec -i gwctl -- gwctl create peer --host cl-dataplane --port 443 --name peer1
kubectl exec -i gwctl -- gwctl create import --name foo --host bla --port 9999
kubectl exec -i gwctl -- gwctl create binding --import foo --peer peer1

# get imported service port
PORT=$(kubectl exec -it gwctl -- /bin/bash -c "gwctl get import --name foo | jq '.Status.Listener.Port' | tr -d '\n'")
PORT=$(kubectl exec -i gwctl -- /bin/bash -c "gwctl get import --name foo | jq '.Status.Listener.Port' | tr -d '\n'")

# expose imported service (TODO: remove this when controlplane automatically creates a service)
kubectl expose deployment cl-dataplane --name=bla --port=9999 --target-port=$PORT

# wait for imported service socket to come up
kubectl exec -it gwctl -- timeout 30 sh -c 'until nc -z $0 $1; do sleep 0.1; done' bla 9999
kubectl exec -i gwctl -- timeout 30 sh -c 'until nc -z $0 $1; do sleep 0.1; done' bla 9999
# wait for iperf server to come up
kubectl exec -it gwctl -- timeout 30 sh -c 'until nc -z $0 $1; do sleep 0.1; done' gwctl 1234
time kubectl exec -i gwctl -- timeout 30 sh -c 'until nc -z $0 $1; do sleep 0.1; done' gwctl 1234

# run iperf client
kubectl exec -it gwctl -- iperf3 -c bla -p 9999 -t 1
kubectl exec -i gwctl -- iperf3 -c bla -p 9999 -t 1
}

cd $TEST_DIR
Expand Down

0 comments on commit a13d6ff

Please sign in to comment.