Skip to content

Commit

Permalink
WIP tcp.reflect
Browse files Browse the repository at this point in the history
  • Loading branch information
attilakreiner committed Apr 29, 2024
1 parent 11b41e4 commit 6bc2ad9
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,26 @@ jobs:
working-directory: tcp.echo
run: ./teardown.sh

test-tcp-reflect:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Create k8s Kind Cluster
uses: helm/kind-action@v1
- name: Setup
working-directory: tcp.reflect
run: ./setup.sh
- name: Execute Test
working-directory: tcp.reflect
run: |
set -o pipefail
./test.sh | tee $GITHUB_STEP_SUMMARY
- name: Teardown
if: always()
working-directory: tcp.reflect
run: ./teardown.sh

test-tls-echo:
runs-on: ubuntu-latest
steps:
Expand Down
41 changes: 41 additions & 0 deletions tcp.reflect/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

# GIVEN
PORT="12345"
read -r -d '' EXPECTED <<- EOM
apple
banana
cherry
strawberry
EOM

echo \# Testing tcp.reflect
echo PORT=$PORT
echo EXPECTED=$EXPECTED
echo

# WHEN
# start echo scripts
./testecho1.sh | nc localhost $PORT > .testoutput1 &
./testecho2.sh | nc localhost $PORT > .testoutput2 &

# wait for expected outputs
for i in $(seq 1 20); do
OUTPUT1=$(cat .testoutput1)
OUTPUT2=$(cat .testoutput2)
if [[ "$OUTPUT1" == "$EXPECTED" && "$OUTPUT2" == "$EXPECTED" ]]; then
break
fi
sleep 1
done
echo OUTPUT1=${OUTPUT1}
echo OUTPUT2=${OUTPUT2}

# THEN
rm .testoutput1 .testoutput2
if [[ "$OUTPUT1" == "$EXPECTED" && "$OUTPUT2" == "$EXPECTED" ]]; then
echo
else
echo
exit 1
fi
3 changes: 3 additions & 0 deletions tcp.reflect/testecho1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
echo apple
echo banana
sleep 2
4 changes: 4 additions & 0 deletions tcp.reflect/testecho2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sleep 1
echo cherry
echo strawberry
sleep 2

0 comments on commit 6bc2ad9

Please sign in to comment.