Skip to content

Commit

Permalink
Update tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Wilkie committed Oct 19, 2015
1 parent bb39881 commit 11ed35b
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 129 deletions.
2 changes: 1 addition & 1 deletion app/api_topology_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func TestAPITopologyWebsocket(t *testing.T) {
if err := json.Unmarshal(p, &d); err != nil {
t.Fatalf("JSON parse error: %s", err)
}
equals(t, 7, len(d.Add))
equals(t, 8, len(d.Add))
equals(t, 0, len(d.Update))
equals(t, 0, len(d.Remove))
}
Expand Down
4 changes: 2 additions & 2 deletions integration/300_internet_edge_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ do_connections&
wait_for_containers $HOST1 60 nginx "The Internet"

has_container $HOST1 nginx
has_container $HOST1 "The Internet"
has_connection $HOST1 "The Internet" nginx
has_container_id $HOST1 'in-theinternet'
has_connection $HOST1 'in-theinternet' $(container_id $1 nginx)

kill %do_connections

Expand Down
2 changes: 1 addition & 1 deletion integration/310_container_to_container_edge_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ wait_for_containers $HOST1 60 nginx client

has_container $HOST1 nginx
has_container $HOST1 client
has_connection $HOST1 client nginx
has_connection $HOST1 $(container_id $HOST1 client) $(container_id $HOST1 nginx)

scope_end_suite
2 changes: 1 addition & 1 deletion integration/320_container_edge_cross_host_2_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ sleep 30 # need to allow the scopes to poll dns, resolve the other app ids, and
check() {
has_container $1 nginx
has_container $1 client
has_connection $1 client nginx
has_connection $1 $(container_id $1 client) $(container_id $1 nginx)
}

check $HOST1
Expand Down
13 changes: 9 additions & 4 deletions integration/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ has_container() {
assert "curl -s http://$host:4040/api/topology/containers?system=show | jq -r '[.nodes[] | select(.label_major == \"$name\")] | length'" $count
}

has_container_id() {
local host=$1
local id=$2
local count=${3:-1}
assert "curl -s http://$host:4040/api/topology/containers?system=show | jq -r '[.nodes[] | select(.id == \"$id\")] | length'" $count
}

scope_end_suite() {
end_suite
for host in $HOSTS; do
Expand All @@ -56,11 +63,9 @@ container_id() {
# this checks we have an edge from container 1 to container 2
has_connection() {
local host="$1"
local from="$2"
local to="$3"
local from_id="$2"
local to_id="$3"
local timeout="${4:-60}"
local from_id=$(container_id "$host" "$from")
local to_id=$(container_id "$host" "$to")

for i in $(seq $timeout); do
local containers="$(curl -s http://$host:4040/api/topology/containers?system=show)"
Expand Down
196 changes: 94 additions & 102 deletions render/expected/expected.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ var (
),
}
}
theInternetNode = func(adjacent string) render.RenderableNode {
theIncomingInternetNode = func(adjacent string) render.RenderableNode {
return render.RenderableNode{
ID: render.TheInternetID,
ID: render.IncomingInternetID,
LabelMajor: render.TheInternetMajor,
LabelMinor: render.Incoming,
Pseudo: true,
Node: report.MakeNode().WithAdjacent(adjacent),
EdgeMetadata: report.EdgeMetadata{
Expand All @@ -56,10 +57,20 @@ var (
},
Origins: report.MakeIDList(
test.RandomClientNodeID,
test.GoogleEndpointNodeID,
),
}
}
theOutgoingInternetNode = render.RenderableNode{
ID: render.OutgoingInternetID,
LabelMajor: render.TheInternetMajor,
LabelMinor: render.Outgoing,
Pseudo: true,
Node: report.MakeNode(),
EdgeMetadata: report.EdgeMetadata{},
Origins: report.MakeIDList(
test.GoogleEndpointNodeID,
),
}
ClientProcess1ID = render.MakeProcessID(test.ClientHostID, test.Client1PID)
ClientProcess2ID = render.MakeProcessID(test.ClientHostID, test.Client2PID)
ServerProcessID = render.MakeProcessID(test.ServerHostID, test.ServerPID)
Expand Down Expand Up @@ -128,12 +139,13 @@ var (
test.ServerHostNodeID,
test.NonContainerNodeID,
),
Node: report.MakeNode().WithAdjacent(render.TheInternetID),
Node: report.MakeNode().WithAdjacent(render.OutgoingInternetID),
EdgeMetadata: report.EdgeMetadata{},
},
unknownPseudoNode1ID: unknownPseudoNode1(ServerProcessID),
unknownPseudoNode2ID: unknownPseudoNode2(ServerProcessID),
render.TheInternetID: theInternetNode(ServerProcessID),
unknownPseudoNode1ID: unknownPseudoNode1(ServerProcessID),
unknownPseudoNode2ID: unknownPseudoNode2(ServerProcessID),
render.IncomingInternetID: theIncomingInternetNode(ServerProcessID),
render.OutgoingInternetID: theOutgoingInternetNode,
}).Prune()

RenderedProcessNames = (render.RenderableNodes{
Expand Down Expand Up @@ -184,12 +196,13 @@ var (
test.ServerHostNodeID,
test.NonContainerNodeID,
),
Node: report.MakeNode().WithAdjacent(render.TheInternetID),
Node: report.MakeNode().WithAdjacent(render.OutgoingInternetID),
EdgeMetadata: report.EdgeMetadata{},
},
unknownPseudoNode1ID: unknownPseudoNode1("apache"),
unknownPseudoNode2ID: unknownPseudoNode2("apache"),
render.TheInternetID: theInternetNode("apache"),
unknownPseudoNode1ID: unknownPseudoNode1("apache"),
unknownPseudoNode2ID: unknownPseudoNode2("apache"),
render.IncomingInternetID: theIncomingInternetNode("apache"),
render.OutgoingInternetID: theOutgoingInternetNode,
}).Prune()

RenderedContainers = (render.RenderableNodes{
Expand Down Expand Up @@ -244,10 +257,11 @@ var (
test.ServerHostNodeID,
test.NonContainerNodeID,
),
Node: report.MakeNode().WithAdjacent(render.TheInternetID),
Node: report.MakeNode().WithAdjacent(render.OutgoingInternetID),
EdgeMetadata: report.EdgeMetadata{},
},
render.TheInternetID: theInternetNode(test.ServerContainerID),
render.IncomingInternetID: theIncomingInternetNode(test.ServerContainerID),
render.OutgoingInternetID: theOutgoingInternetNode,
}).Prune()

RenderedContainerImages = (render.RenderableNodes{
Expand Down Expand Up @@ -301,72 +315,11 @@ var (
test.NonContainerProcessNodeID,
test.ServerHostNodeID,
),
Node: report.MakeNode().WithAdjacent(render.TheInternetID),
EdgeMetadata: report.EdgeMetadata{},
},
render.TheInternetID: theInternetNode(test.ServerContainerImageName),
}).Prune()

ServerHostRenderedID = render.MakeHostID(test.ServerHostID)
ClientHostRenderedID = render.MakeHostID(test.ClientHostID)
pseudoHostID1 = render.MakePseudoNodeID(test.UnknownClient1IP, test.ServerIP)
pseudoHostID2 = render.MakePseudoNodeID(test.UnknownClient3IP, test.ServerIP)

RenderedHosts = (render.RenderableNodes{
ServerHostRenderedID: {
ID: ServerHostRenderedID,
LabelMajor: "server", // before first .
LabelMinor: "hostname.com", // after first .
Rank: "hostname.com",
Pseudo: false,
Origins: report.MakeIDList(
test.ServerHostNodeID,
test.ServerAddressNodeID,
),
Node: report.MakeNode(),
EdgeMetadata: report.EdgeMetadata{
MaxConnCountTCP: newu64(3),
},
},
ClientHostRenderedID: {
ID: ClientHostRenderedID,
LabelMajor: "client", // before first .
LabelMinor: "hostname.com", // after first .
Rank: "hostname.com",
Pseudo: false,
Origins: report.MakeIDList(
test.ClientHostNodeID,
test.ClientAddressNodeID,
),
Node: report.MakeNode().WithAdjacent(ServerHostRenderedID),
EdgeMetadata: report.EdgeMetadata{
MaxConnCountTCP: newu64(3),
},
},
pseudoHostID1: {
ID: pseudoHostID1,
LabelMajor: test.UnknownClient1IP,
Pseudo: true,
Node: report.MakeNode().WithAdjacent(ServerHostRenderedID),
Node: report.MakeNode().WithAdjacent(render.OutgoingInternetID),
EdgeMetadata: report.EdgeMetadata{},
Origins: report.MakeIDList(test.UnknownAddress1NodeID, test.UnknownAddress2NodeID),
},
pseudoHostID2: {
ID: pseudoHostID2,
LabelMajor: test.UnknownClient3IP,
Pseudo: true,
Node: report.MakeNode().WithAdjacent(ServerHostRenderedID),
EdgeMetadata: report.EdgeMetadata{},
Origins: report.MakeIDList(test.UnknownAddress3NodeID),
},
render.TheInternetID: {
ID: render.TheInternetID,
LabelMajor: render.TheInternetMajor,
Pseudo: true,
Node: report.MakeNode().WithAdjacent(ServerHostRenderedID),
EdgeMetadata: report.EdgeMetadata{},
Origins: report.MakeIDList(test.RandomAddressNodeID),
},
render.IncomingInternetID: theIncomingInternetNode(test.ServerContainerImageName),
render.OutgoingInternetID: theOutgoingInternetNode,
}).Prune()

RenderedPods = (render.RenderableNodes{
Expand Down Expand Up @@ -423,23 +376,11 @@ var (
test.NonContainerProcessNodeID,
test.NonContainerNodeID,
),
Node: report.MakeNode().WithAdjacent(render.TheInternetID),
Node: report.MakeNode().WithAdjacent(render.OutgoingInternetID),
EdgeMetadata: report.EdgeMetadata{},
},
render.TheInternetID: {
ID: render.TheInternetID,
LabelMajor: render.TheInternetMajor,
Pseudo: true,
Node: report.MakeNode().WithAdjacent("ping/pong-b"),
EdgeMetadata: report.EdgeMetadata{
EgressPacketCount: newu64(60),
EgressByteCount: newu64(600),
},
Origins: report.MakeIDList(
test.RandomClientNodeID,
test.GoogleEndpointNodeID,
),
},
render.IncomingInternetID: theIncomingInternetNode("ping/pong-b"),
render.OutgoingInternetID: theOutgoingInternetNode,
}).Prune()

RenderedPodServices = (render.RenderableNodes{
Expand Down Expand Up @@ -485,22 +426,73 @@ var (
test.NonContainerProcessNodeID,
test.NonContainerNodeID,
),
Node: report.MakeNode().WithAdjacent(render.TheInternetID),
Node: report.MakeNode().WithAdjacent(render.OutgoingInternetID),
EdgeMetadata: report.EdgeMetadata{},
},
render.TheInternetID: {
ID: render.TheInternetID,
LabelMajor: render.TheInternetMajor,
Pseudo: true,
Node: report.MakeNode().WithAdjacent(test.ServiceID),
render.IncomingInternetID: theIncomingInternetNode(test.ServiceID),
render.OutgoingInternetID: theOutgoingInternetNode,
}).Prune()

ServerHostRenderedID = render.MakeHostID(test.ServerHostID)
ClientHostRenderedID = render.MakeHostID(test.ClientHostID)
pseudoHostID1 = render.MakePseudoNodeID(test.UnknownClient1IP, test.ServerIP)
pseudoHostID2 = render.MakePseudoNodeID(test.UnknownClient3IP, test.ServerIP)

RenderedHosts = (render.RenderableNodes{
ServerHostRenderedID: {
ID: ServerHostRenderedID,
LabelMajor: "server", // before first .
LabelMinor: "hostname.com", // after first .
Rank: "hostname.com",
Pseudo: false,
Origins: report.MakeIDList(
test.ServerHostNodeID,
test.ServerAddressNodeID,
),
Node: report.MakeNode(),
EdgeMetadata: report.EdgeMetadata{
EgressPacketCount: newu64(60),
EgressByteCount: newu64(600),
MaxConnCountTCP: newu64(3),
},
},
ClientHostRenderedID: {
ID: ClientHostRenderedID,
LabelMajor: "client", // before first .
LabelMinor: "hostname.com", // after first .
Rank: "hostname.com",
Pseudo: false,
Origins: report.MakeIDList(
test.RandomClientNodeID,
test.GoogleEndpointNodeID,
test.ClientHostNodeID,
test.ClientAddressNodeID,
),
Node: report.MakeNode().WithAdjacent(ServerHostRenderedID),
EdgeMetadata: report.EdgeMetadata{
MaxConnCountTCP: newu64(3),
},
},
pseudoHostID1: {
ID: pseudoHostID1,
LabelMajor: test.UnknownClient1IP,
Pseudo: true,
Node: report.MakeNode().WithAdjacent(ServerHostRenderedID),
EdgeMetadata: report.EdgeMetadata{},
Origins: report.MakeIDList(test.UnknownAddress1NodeID, test.UnknownAddress2NodeID),
},
pseudoHostID2: {
ID: pseudoHostID2,
LabelMajor: test.UnknownClient3IP,
Pseudo: true,
Node: report.MakeNode().WithAdjacent(ServerHostRenderedID),
EdgeMetadata: report.EdgeMetadata{},
Origins: report.MakeIDList(test.UnknownAddress3NodeID),
},
render.IncomingInternetID: {
ID: render.IncomingInternetID,
LabelMajor: render.TheInternetMajor,
LabelMinor: render.Incoming,
Pseudo: true,
Node: report.MakeNode().WithAdjacent(ServerHostRenderedID),
EdgeMetadata: report.EdgeMetadata{},
Origins: report.MakeIDList(test.RandomAddressNodeID),
},
}).Prune()
)
Expand Down
Loading

0 comments on commit 11ed35b

Please sign in to comment.