integration tests: list containers & endpoints for debugging

And when endpoints_have_ebpf() fails to find all endpoints with eBPF,
print an example of endpoint.
This commit is contained in:
Alban Crequy
2017-03-17 11:51:48 +01:00
parent 3e2144544b
commit 904da40fad
3 changed files with 23 additions and 0 deletions

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"
}