From 904da40fadeba5d39fdc5817603c49fbaaf0c1a6 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Fri, 17 Mar 2017 11:51:48 +0100 Subject: [PATCH] integration tests: list containers & endpoints for debugging And when endpoints_have_ebpf() fails to find all endpoints with eBPF, print an example of endpoint. --- ..._container_to_container_edge_with_ebpf_test.sh | 4 ++++ ...to_container_edge_same_netns_with_ebpf_test.sh | 4 ++++ integration/config.sh | 15 +++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/integration/311_container_to_container_edge_with_ebpf_test.sh b/integration/311_container_to_container_edge_with_ebpf_test.sh index 8d3356e2e..7c66be7b9 100755 --- a/integration/311_container_to_container_edge_with_ebpf_test.sh +++ b/integration/311_container_to_container_edge_with_ebpf_test.sh @@ -17,6 +17,10 @@ wait_for_containers "$HOST1" 60 nginx client has_container "$HOST1" nginx has_container "$HOST1" client + +list_containers "$HOST1" +list_connections "$HOST1" + has_connection containers "$HOST1" client nginx endpoints_have_ebpf "$HOST1" diff --git a/integration/312_container_to_container_edge_same_netns_with_ebpf_test.sh b/integration/312_container_to_container_edge_same_netns_with_ebpf_test.sh index 828c35dcf..820114e9a 100755 --- a/integration/312_container_to_container_edge_same_netns_with_ebpf_test.sh +++ b/integration/312_container_to_container_edge_same_netns_with_ebpf_test.sh @@ -13,6 +13,10 @@ wait_for_containers "$HOST1" 60 nginx client has_container "$HOST1" nginx has_container "$HOST1" client + +list_containers "$HOST1" +list_connections "$HOST1" + has_connection containers "$HOST1" client nginx endpoints_have_ebpf "$HOST1" diff --git a/integration/config.sh b/integration/config.sh index 99f5cdf74..72eb51fdf 100644 --- a/integration/config.sh +++ b/integration/config.sh @@ -40,6 +40,19 @@ scope_end_suite() { done } +list_containers() { + local host=$1 + echo "Listing containers on ${host}:" + curl -s "http://${host}:4040/api/topology/containers?system=show" | jq -r '.nodes[] | select(has("metadata")) | .metadata[] | select(.id == "docker_image_name") | .value' +} + +list_connections() { + local host=$1 + echo "Listing connections on ${host}:" + curl -s "http://${host}:4040/api/topology/containers?system=show" | jq -r '.nodes[] | select(has("adjacency")) | { "from": .id, "to": .adjacency[]} | .from + " -> " + .to' + +} + # this checks we have a named node in the given view has() { local view=$1 @@ -111,6 +124,8 @@ endpoints_have_ebpf() { done echo "Only ${have_ebpf} endpoints of ${number_of_endpoints} have ebpf enabled, should be equal" + echo "Example of one endpoint:" + echo "${report}" | jq -r '[.Endpoint.nodes[]][0]' assert "echo '$have_ebpf" "$number_of_endpoints" }