Skip to content

Commit b2f14a9

Browse files
committed
refactor: extract a couple of test helpers
1 parent 30168c5 commit b2f14a9

7 files changed

+25
-22
lines changed

integration/310_container_to_container_edge_test.sh

+3-5
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ start_suite "Test short lived connections between containers"
77

88
weave_on "$HOST1" launch
99
scope_on "$HOST1" launch
10-
weave_proxy_on "$HOST1" run -d --name nginx nginx
11-
weave_proxy_on "$HOST1" run -d --name client alpine /bin/sh -c "while true; do \
12-
wget http://nginx.weave.local:80/ -O - >/dev/null || true; \
13-
sleep 1; \
14-
done"
10+
11+
server_on "$HOST1"
12+
client_on "$HOST1"
1513

1614
wait_for_containers "$HOST1" 60 nginx client
1715

integration/311_container_to_container_edge_without_ebpf_test.sh

+3-5
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ start_suite "Test short lived connections between containers, without ebpf conne
77

88
weave_on "$HOST1" launch
99
scope_on "$HOST1" launch --probe.ebpf.connections=false
10-
weave_proxy_on "$HOST1" run -d --name nginx nginx
11-
weave_proxy_on "$HOST1" run -d --name client alpine /bin/sh -c "while true; do \
12-
wget http://nginx.weave.local:80/ -O - >/dev/null || true; \
13-
sleep 1; \
14-
done"
10+
11+
server_on "$HOST1"
12+
client_on "$HOST1"
1513

1614
wait_for_containers "$HOST1" 60 nginx client
1715

integration/313_container_to_container_edge_with_ebpf_proc_fallback_test.sh

+3-5
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ weave_on "$HOST1" launch
1212
DOCKER_HOST=tcp://${HOST1}:${DOCKER_PORT} CHECKPOINT_DISABLE=true \
1313
WEAVESCOPE_DOCKER_ARGS="-v /tmp:/sys/kernel/debug/tracing:ro" \
1414
"${SCOPE}" launch
15-
weave_proxy_on "$HOST1" run -d --name nginx nginx
16-
weave_proxy_on "$HOST1" run -d --name client alpine /bin/sh -c "while true; do \
17-
wget http://nginx.weave.local:80/ -O - >/dev/null || true; \
18-
sleep 1; \
19-
done"
15+
16+
server_on "$HOST1"
17+
client_on "$HOST1"
2018

2119
wait_for_containers "$HOST1" 60 nginx client
2220

integration/320_container_edge_cross_host_2_test.sh

+2-5
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,8 @@ weave_on "$HOST2" launch "$HOST1" "$HOST2"
1111
scope_on "$HOST1" launch
1212
scope_on "$HOST2" launch
1313

14-
weave_proxy_on "$HOST1" run -d --name nginx nginx
15-
weave_proxy_on "$HOST2" run -d --name client alpine /bin/sh -c "while true; do \
16-
wget http://nginx.weave.local:80/ -O - >/dev/null || true; \
17-
sleep 1; \
18-
done"
14+
server_on "$HOST1"
15+
client_on "$HOST2"
1916

2017
sleep 30 # need to allow the scopes to poll dns, resolve the other app ids, and send them reports
2118

integration/330_process_edge_test.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ start_suite "Test long connections (procspy) between processes"
77

88
weave_on "$HOST1" launch
99
scope_on "$HOST1" launch --probe.conntrack=false
10-
weave_proxy_on "$HOST1" run -d --name nginx nginx
10+
11+
server_on "$HOST1"
1112
weave_proxy_on "$HOST1" run -dti --name client alpine /bin/sh -c "while true; do \
1213
nc nginx.weave.local 80 || true; \
1314
sleep 1; \

integration/340_process_edge_across_host_2_test.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ weave_on "$HOST2" launch "$HOST1" "$HOST2"
1111
scope_on "$HOST1" launch --probe.conntrack=false
1212
scope_on "$HOST2" launch --probe.conntrack=false
1313

14-
weave_proxy_on "$HOST1" run -d --name nginx nginx
14+
server_on "$HOST1"
1515
weave_proxy_on "$HOST2" run -dti --name client alpine /bin/sh -c "while true; do \
1616
nc nginx.weave.local 80 || true; \
1717
sleep 1; \

integration/config.sh

+11
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,17 @@ weave_proxy_on() {
3535
DOCKER_PORT=12375 docker_on "$host" "$@"
3636
}
3737

38+
server_on() {
39+
weave_proxy_on "$1" run -d --name nginx nginx
40+
}
41+
42+
client_on() {
43+
weave_proxy_on "$1" run -d --name client alpine /bin/sh -c "while true; do \
44+
wget http://nginx.weave.local:80/ -O - >/dev/null || true; \
45+
sleep 1; \
46+
done"
47+
}
48+
3849
scope_end_suite() {
3950
end_suite
4051
for host in $HOSTS; do

0 commit comments

Comments
 (0)