-
Notifications
You must be signed in to change notification settings - Fork 712
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #493 from weaveworks/short-lived-internet-node-con…
…nections In containers view, show short lived connections to/from the internet.
- Loading branch information
Showing
9 changed files
with
227 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#! /bin/bash | ||
|
||
. ./config.sh | ||
|
||
start_suite "Test short lived connections from the Internet" | ||
|
||
weave_on $HOST1 launch | ||
scope_on $HOST1 launch | ||
docker_on $HOST1 run -d -p 80:80 --name nginx nginx | ||
|
||
do_connections() { | ||
while true; do | ||
curl -s http://$HOST1:80/ >/dev/null | ||
sleep 1 | ||
done | ||
} | ||
do_connections& | ||
|
||
sleep 5 # give the probe a few seconds to build a report and send it to the app | ||
|
||
has_container $HOST1 nginx 1 | ||
has_connection $HOST1 "The Internet" nginx | ||
|
||
kill %do_connections | ||
|
||
scope_end_suite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package render_test | ||
|
||
import ( | ||
"fmt" | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/weaveworks/scope/probe/docker" | ||
"github.com/weaveworks/scope/probe/endpoint" | ||
"github.com/weaveworks/scope/render" | ||
"github.com/weaveworks/scope/report" | ||
"github.com/weaveworks/scope/test" | ||
) | ||
|
||
var ( | ||
serverHostID = "host1" | ||
serverHostNodeID = report.MakeHostNodeID(serverHostID) | ||
|
||
randomIP = "3.4.5.6" | ||
randomPort = "56789" | ||
randomEndpointNodeID = report.MakeEndpointNodeID(serverHostID, randomIP, randomPort) | ||
|
||
serverIP = "192.168.1.1" | ||
serverPort = "80" | ||
serverEndpointNodeID = report.MakeEndpointNodeID(serverHostID, serverIP, serverPort) | ||
|
||
containerID = "a1b2c3d4e5" | ||
containerIP = "192.168.0.1" | ||
containerName = "foo" | ||
containerNodeID = report.MakeContainerNodeID(serverHostID, containerID) | ||
|
||
rpt = report.Report{ | ||
Endpoint: report.Topology{ | ||
Nodes: report.Nodes{ | ||
randomEndpointNodeID: report.MakeNode().WithMetadata(map[string]string{ | ||
endpoint.Addr: randomIP, | ||
endpoint.Port: randomPort, | ||
endpoint.Conntracked: "true", | ||
}).WithAdjacent(serverEndpointNodeID), | ||
|
||
serverEndpointNodeID: report.MakeNode().WithMetadata(map[string]string{ | ||
endpoint.Addr: serverIP, | ||
endpoint.Port: serverPort, | ||
endpoint.Conntracked: "true", | ||
}), | ||
}, | ||
}, | ||
Container: report.Topology{ | ||
Nodes: report.Nodes{ | ||
containerNodeID: report.MakeNode().WithMetadata(map[string]string{ | ||
docker.ContainerID: containerID, | ||
docker.ContainerName: containerName, | ||
docker.ContainerIPs: containerIP, | ||
docker.ContainerPorts: fmt.Sprintf("%s:%s->%s/tcp", serverIP, serverPort, serverPort), | ||
report.HostNodeID: serverHostNodeID, | ||
}), | ||
}, | ||
}, | ||
Host: report.Topology{ | ||
Nodes: report.Nodes{ | ||
serverHostNodeID: report.MakeNodeWith(map[string]string{ | ||
"local_networks": "192.168.0.0/16", | ||
report.HostNodeID: serverHostNodeID, | ||
}), | ||
}, | ||
}, | ||
} | ||
|
||
want = (render.RenderableNodes{ | ||
render.TheInternetID: { | ||
ID: render.TheInternetID, | ||
LabelMajor: render.TheInternetMajor, | ||
Pseudo: true, | ||
Node: report.MakeNode().WithAdjacent(containerID), | ||
Origins: report.MakeIDList(randomEndpointNodeID), | ||
}, | ||
containerID: { | ||
ID: containerID, | ||
LabelMajor: containerName, | ||
LabelMinor: serverHostID, | ||
Rank: "", | ||
Pseudo: false, | ||
Origins: report.MakeIDList(containerNodeID, serverEndpointNodeID, serverHostNodeID), | ||
Node: report.MakeNode(), | ||
}, | ||
}).Prune() | ||
) | ||
|
||
func TestShortLivedInternetNodeConnections(t *testing.T) { | ||
have := (render.ContainerWithImageNameRenderer.Render(rpt)).Prune() | ||
if !reflect.DeepEqual(want, have) { | ||
t.Error(test.Diff(want, have)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters