Skip to content

Commit 6a6a371

Browse files
committed
Add contention testing
In theory these tests will find more non-blocking issues.
1 parent e60aafe commit 6a6a371

File tree

3 files changed

+490
-13
lines changed

3 files changed

+490
-13
lines changed
Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
name: wolfSSH Network Contention Test
2+
3+
on:
4+
push:
5+
branches: [ 'master', 'main', 'release/**' ]
6+
pull_request:
7+
branches: [ '*' ]
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
create_matrix:
16+
runs-on: ubuntu-latest
17+
outputs:
18+
versions: ${{ steps.json.outputs.versions }}
19+
steps:
20+
- name: Create wolfSSL version matrix
21+
id: json
22+
run: |
23+
current=`curl -s https://api.github.com/repos/wolfssl/wolfssl/releases | grep tag_name | cut -d : -f 2,3 | tr -d \" | tr -d , | tr -d ' ' | head -1`
24+
last=`curl -s https://api.github.com/repos/wolfssl/wolfssl/releases | grep tag_name | cut -d : -f 2,3 | tr -d \" | tr -d , | tr -d ' ' | head -2 | tail -1`
25+
VERSIONS=$(echo "[ \"master\", \"$current\", \"$last\" ]")
26+
echo "wolfSSL versions found: $VERSIONS"
27+
echo "versions=$VERSIONS" >> $GITHUB_OUTPUT
28+
29+
build_wolfssl:
30+
needs: create_matrix
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
os: [ ubuntu-latest ]
35+
wolfssl: ${{ fromJson(needs.create_matrix.outputs['versions']) }}
36+
name: Build wolfssl
37+
runs-on: ${{ matrix.os }}
38+
timeout-minutes: 4
39+
steps:
40+
- name: Checking cache for wolfssl
41+
uses: actions/cache@v4
42+
id: cache-wolfssl
43+
with:
44+
path: build-dir/
45+
key: wolfssh-contention-wolfssl-${{ matrix.wolfssl }}-${{ matrix.os }}
46+
lookup-only: true
47+
48+
- name: Checkout, build, and install wolfssl
49+
if: steps.cache-wolfssl.outputs.cache-hit != 'true'
50+
uses: wolfSSL/actions-build-autotools-project@v1
51+
with:
52+
repository: wolfssl/wolfssl
53+
ref: ${{ matrix.wolfssl }}
54+
path: wolfssl
55+
configure: --enable-ssh
56+
check: false
57+
install: true
58+
59+
test_sftp_contention:
60+
needs:
61+
- build_wolfssl
62+
- create_matrix
63+
strategy:
64+
fail-fast: false
65+
matrix:
66+
os: [ ubuntu-latest ]
67+
wolfssl: ${{ fromJson(needs.create_matrix.outputs['versions']) }}
68+
block_prob: [ 30, 50, 70 ]
69+
name: SFTP contention test (prob=${{ matrix.block_prob }}%)
70+
runs-on: ${{ matrix.os }}
71+
timeout-minutes: 15
72+
steps:
73+
- name: Checking cache for wolfssl
74+
uses: actions/cache@v4
75+
with:
76+
path: build-dir/
77+
key: wolfssh-contention-wolfssl-${{ matrix.wolfssl }}-${{ matrix.os }}
78+
fail-on-cache-miss: true
79+
80+
- uses: actions/checkout@v4
81+
with:
82+
path: wolfssh/
83+
84+
- name: autogen
85+
working-directory: ./wolfssh/
86+
run: ./autogen.sh
87+
88+
- name: configure with TEST_BLOCK
89+
working-directory: ./wolfssh/
90+
run: |
91+
./configure --enable-sftp \
92+
LDFLAGS="-L${{ github.workspace }}/build-dir/lib" \
93+
CPPFLAGS="-I${{ github.workspace }}/build-dir/include -DWOLFSSH_TEST_BLOCK -DWOLFSSH_BLOCK_PROB=${{ matrix.block_prob }} -DWOLFSSH_NO_FPKI"
94+
95+
- name: make
96+
working-directory: ./wolfssh/
97+
run: make
98+
99+
- name: Setup network delay with tc/netem
100+
run: |
101+
sudo tc qdisc add dev lo root netem delay 10ms 5ms loss 0.1%
102+
echo "Network delay configured:"
103+
tc qdisc show dev lo
104+
105+
- name: Run SFTP contention tests
106+
working-directory: ./wolfssh/
107+
timeout-minutes: 10
108+
run: ./scripts/sftp.test
109+
110+
- name: Create large test files
111+
run: |
112+
dd if=/dev/urandom of=/tmp/test_1kb.dat bs=1K count=1
113+
dd if=/dev/urandom of=/tmp/test_2mb.dat bs=1M count=2
114+
dd if=/dev/urandom of=/tmp/test_10mb.dat bs=1M count=10
115+
md5sum /tmp/test_*.dat > /tmp/test_checksums.md5
116+
echo "Test files created:"
117+
ls -la /tmp/test_*.dat
118+
119+
- name: Run extended SFTP file transfer tests
120+
working-directory: ./wolfssh/
121+
timeout-minutes: 10
122+
run: |
123+
# Start echoserver in non-blocking mode
124+
./examples/echoserver/echoserver -N -f &
125+
SERVER_PID=$!
126+
sleep 2
127+
128+
# Test 1KB file transfer
129+
echo "Testing 1KB file transfer..."
130+
echo "get /tmp/test_1kb.dat /tmp/recv_1kb.dat" | ./examples/sftpclient/wolfsftp -N -h 127.0.0.1 -p 22222 -u jill -P upthehill
131+
if ! cmp -s /tmp/test_1kb.dat /tmp/recv_1kb.dat; then
132+
echo "FAILED: 1KB file integrity check"
133+
kill $SERVER_PID 2>/dev/null || true
134+
exit 1
135+
fi
136+
echo "1KB file transfer: PASSED"
137+
138+
# Test 2MB file transfer
139+
echo "Testing 2MB file transfer..."
140+
echo "get /tmp/test_2mb.dat /tmp/recv_2mb.dat" | ./examples/sftpclient/wolfsftp -N -h 127.0.0.1 -p 22222 -u jill -P upthehill
141+
if ! cmp -s /tmp/test_2mb.dat /tmp/recv_2mb.dat; then
142+
echo "FAILED: 2MB file integrity check"
143+
kill $SERVER_PID 2>/dev/null || true
144+
exit 1
145+
fi
146+
echo "2MB file transfer: PASSED"
147+
148+
# Test 10MB file transfer
149+
echo "Testing 10MB file transfer..."
150+
echo "get /tmp/test_10mb.dat /tmp/recv_10mb.dat" | ./examples/sftpclient/wolfsftp -N -h 127.0.0.1 -p 22222 -u jill -P upthehill
151+
if ! cmp -s /tmp/test_10mb.dat /tmp/recv_10mb.dat; then
152+
echo "FAILED: 10MB file integrity check"
153+
kill $SERVER_PID 2>/dev/null || true
154+
exit 1
155+
fi
156+
echo "10MB file transfer: PASSED"
157+
158+
kill $SERVER_PID 2>/dev/null || true
159+
echo "All extended SFTP tests PASSED"
160+
161+
- name: Cleanup network delay
162+
if: always()
163+
run: sudo tc qdisc del dev lo root netem || true
164+
165+
test_scp_contention:
166+
needs:
167+
- build_wolfssl
168+
- create_matrix
169+
strategy:
170+
fail-fast: false
171+
matrix:
172+
os: [ ubuntu-latest ]
173+
wolfssl: ${{ fromJson(needs.create_matrix.outputs['versions']) }}
174+
block_prob: [ 30, 50, 70 ]
175+
name: SCP contention test (prob=${{ matrix.block_prob }}%)
176+
runs-on: ${{ matrix.os }}
177+
timeout-minutes: 15
178+
steps:
179+
- name: Checking cache for wolfssl
180+
uses: actions/cache@v4
181+
with:
182+
path: build-dir/
183+
key: wolfssh-contention-wolfssl-${{ matrix.wolfssl }}-${{ matrix.os }}
184+
fail-on-cache-miss: true
185+
186+
- uses: actions/checkout@v4
187+
with:
188+
path: wolfssh/
189+
190+
- name: autogen
191+
working-directory: ./wolfssh/
192+
run: ./autogen.sh
193+
194+
- name: configure with TEST_BLOCK
195+
working-directory: ./wolfssh/
196+
run: |
197+
./configure --enable-scp \
198+
LDFLAGS="-L${{ github.workspace }}/build-dir/lib" \
199+
CPPFLAGS="-I${{ github.workspace }}/build-dir/include -DWOLFSSH_TEST_BLOCK -DWOLFSSH_BLOCK_PROB=${{ matrix.block_prob }} -DWOLFSSH_NO_FPKI"
200+
201+
- name: make
202+
working-directory: ./wolfssh/
203+
run: make
204+
205+
- name: Setup network delay with tc/netem
206+
run: |
207+
sudo tc qdisc add dev lo root netem delay 10ms 5ms loss 0.1%
208+
echo "Network delay configured:"
209+
tc qdisc show dev lo
210+
211+
- name: Run SCP contention tests
212+
working-directory: ./wolfssh/
213+
timeout-minutes: 10
214+
run: ./scripts/scp.test
215+
216+
- name: Cleanup network delay
217+
if: always()
218+
run: sudo tc qdisc del dev lo root netem || true

0 commit comments

Comments
 (0)