From 4f69f420f2ae4adb74711ace43764f3ba6f14141 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Sun, 25 Jun 2017 08:30:28 +0100 Subject: [PATCH] refactor: extract a couple of test helpers --- integration/310_container_to_container_edge_test.sh | 8 +++----- ...1_container_to_container_edge_without_ebpf_test.sh | 8 +++----- ..._to_container_edge_with_ebpf_proc_fallback_test.sh | 8 +++----- integration/320_container_edge_cross_host_2_test.sh | 7 ++----- integration/330_process_edge_test.sh | 3 ++- integration/340_process_edge_across_host_2_test.sh | 2 +- integration/config.sh | 11 +++++++++++ 7 files changed, 25 insertions(+), 22 deletions(-) diff --git a/integration/310_container_to_container_edge_test.sh b/integration/310_container_to_container_edge_test.sh index 307d4e5163..dbf9a4dd9a 100755 --- a/integration/310_container_to_container_edge_test.sh +++ b/integration/310_container_to_container_edge_test.sh @@ -7,11 +7,9 @@ start_suite "Test short lived connections between containers" weave_on "$HOST1" launch scope_on "$HOST1" launch -weave_proxy_on "$HOST1" run -d --name nginx nginx -weave_proxy_on "$HOST1" run -d --name client alpine /bin/sh -c "while true; do \ - wget http://nginx.weave.local:80/ -O - >/dev/null || true; \ - sleep 1; \ -done" + +server_on "$HOST1" +client_on "$HOST1" wait_for_containers "$HOST1" 60 nginx client diff --git a/integration/311_container_to_container_edge_without_ebpf_test.sh b/integration/311_container_to_container_edge_without_ebpf_test.sh index 84b95f7255..dd841acd40 100755 --- a/integration/311_container_to_container_edge_without_ebpf_test.sh +++ b/integration/311_container_to_container_edge_without_ebpf_test.sh @@ -7,11 +7,9 @@ start_suite "Test short lived connections between containers, without ebpf conne weave_on "$HOST1" launch scope_on "$HOST1" launch --probe.ebpf.connections=false -weave_proxy_on "$HOST1" run -d --name nginx nginx -weave_proxy_on "$HOST1" run -d --name client alpine /bin/sh -c "while true; do \ - wget http://nginx.weave.local:80/ -O - >/dev/null || true; \ - sleep 1; \ -done" + +server_on "$HOST1" +client_on "$HOST1" wait_for_containers "$HOST1" 60 nginx client diff --git a/integration/313_container_to_container_edge_with_ebpf_proc_fallback_test.sh b/integration/313_container_to_container_edge_with_ebpf_proc_fallback_test.sh index 44e9e6b126..5924077197 100755 --- a/integration/313_container_to_container_edge_with_ebpf_proc_fallback_test.sh +++ b/integration/313_container_to_container_edge_with_ebpf_proc_fallback_test.sh @@ -12,11 +12,9 @@ weave_on "$HOST1" launch DOCKER_HOST=tcp://${HOST1}:${DOCKER_PORT} CHECKPOINT_DISABLE=true \ WEAVESCOPE_DOCKER_ARGS="-v /tmp:/sys/kernel/debug/tracing:ro" \ "${SCOPE}" launch -weave_proxy_on "$HOST1" run -d --name nginx nginx -weave_proxy_on "$HOST1" run -d --name client alpine /bin/sh -c "while true; do \ - wget http://nginx.weave.local:80/ -O - >/dev/null || true; \ - sleep 1; \ -done" + +server_on "$HOST1" +client_on "$HOST1" wait_for_containers "$HOST1" 60 nginx client diff --git a/integration/320_container_edge_cross_host_2_test.sh b/integration/320_container_edge_cross_host_2_test.sh index 7e63b95e06..4e0a057a9b 100755 --- a/integration/320_container_edge_cross_host_2_test.sh +++ b/integration/320_container_edge_cross_host_2_test.sh @@ -11,11 +11,8 @@ weave_on "$HOST2" launch "$HOST1" "$HOST2" scope_on "$HOST1" launch scope_on "$HOST2" launch -weave_proxy_on "$HOST1" run -d --name nginx nginx -weave_proxy_on "$HOST2" run -d --name client alpine /bin/sh -c "while true; do \ - wget http://nginx.weave.local:80/ -O - >/dev/null || true; \ - sleep 1; \ -done" +server_on "$HOST1" +client_on "$HOST2" sleep 30 # need to allow the scopes to poll dns, resolve the other app ids, and send them reports diff --git a/integration/330_process_edge_test.sh b/integration/330_process_edge_test.sh index 414e564934..c78629c40c 100755 --- a/integration/330_process_edge_test.sh +++ b/integration/330_process_edge_test.sh @@ -7,7 +7,8 @@ start_suite "Test long connections (procspy) between processes" weave_on "$HOST1" launch scope_on "$HOST1" launch --probe.conntrack=false -weave_proxy_on "$HOST1" run -d --name nginx nginx + +server_on "$HOST1" weave_proxy_on "$HOST1" run -dti --name client alpine /bin/sh -c "while true; do \ nc nginx.weave.local 80 || true; \ sleep 1; \ diff --git a/integration/340_process_edge_across_host_2_test.sh b/integration/340_process_edge_across_host_2_test.sh index 0ead397f89..60442e3f4e 100755 --- a/integration/340_process_edge_across_host_2_test.sh +++ b/integration/340_process_edge_across_host_2_test.sh @@ -11,7 +11,7 @@ weave_on "$HOST2" launch "$HOST1" "$HOST2" scope_on "$HOST1" launch --probe.conntrack=false scope_on "$HOST2" launch --probe.conntrack=false -weave_proxy_on "$HOST1" run -d --name nginx nginx +server_on "$HOST1" weave_proxy_on "$HOST2" run -dti --name client alpine /bin/sh -c "while true; do \ nc nginx.weave.local 80 || true; \ sleep 1; \ diff --git a/integration/config.sh b/integration/config.sh index a69a265386..19116d105a 100644 --- a/integration/config.sh +++ b/integration/config.sh @@ -35,6 +35,17 @@ weave_proxy_on() { DOCKER_PORT=12375 docker_on "$host" "$@" } +server_on() { + weave_proxy_on "$1" run -d --name client alpine /bin/sh -c "while true; do \ + wget http://nginx.weave.local:80/ -O - >/dev/null || true; \ + sleep 1; \ + done" +} + +client_on() { + weave_proxy_on "$1" run -d --name nginx nginx +} + scope_end_suite() { end_suite for host in $HOSTS; do