예제 #1
0
func TestContainerFilterRenderer(t *testing.T) {
	// tag on of the containers in the topology and ensure
	// it is filtered out correctly.
	input := fixture.Report.Copy()
	input.Container.Nodes[fixture.ClientContainerNodeID].Metadata[docker.LabelPrefix+"works.weave.role"] = "system"
	have := render.FilterSystem(render.ContainerWithImageNameRenderer).Render(input).Prune()
	want := expected.RenderedContainers.Copy()
	delete(want, expected.ClientContainerRenderedID)
	if !reflect.DeepEqual(want, have) {
		t.Error(test.Diff(want, have))
	}
}
예제 #2
0
func TestContainerFilterRendererImageName(t *testing.T) {
	// Test nodes are filtered by image name as well.
	input := fixture.Report.Copy()
	input.ContainerImage.Nodes[fixture.ClientContainerImageNodeID] = input.ContainerImage.Nodes[fixture.ClientContainerImageNodeID].WithLatests(map[string]string{
		docker.ImageName: "beta.gcr.io/google_containers/pause",
	})
	have := render.FilterSystem(render.ContainerWithImageNameRenderer).Render(input).Prune()
	want := expected.RenderedContainers.Copy()
	delete(want, expected.ClientContainerRenderedID)
	if !reflect.DeepEqual(want, have) {
		t.Error(test.Diff(want, have))
	}
}
예제 #3
0
func TestPodFilterRenderer(t *testing.T) {
	// tag on containers or pod namespace in the topology and ensure
	// it is filtered out correctly.
	input := fixture.Report.Copy()
	input.Pod.Nodes[fixture.ClientPodNodeID].Metadata[kubernetes.PodID] = "pod:kube-system/foo"
	input.Pod.Nodes[fixture.ClientPodNodeID].Metadata[kubernetes.Namespace] = "kube-system"
	input.Pod.Nodes[fixture.ClientPodNodeID].Metadata[kubernetes.PodName] = "foo"
	input.Container.Nodes[fixture.ClientContainerNodeID].Metadata[docker.LabelPrefix+"io.kubernetes.pod.name"] = "kube-system/foo"
	have := render.FilterSystem(render.PodRenderer).Render(input).Prune()
	want := expected.RenderedPods.Copy()
	delete(want, expected.ClientPodRenderedID)
	delete(want, expected.ClientContainerRenderedID)
	if !reflect.DeepEqual(want, have) {
		t.Error(test.Diff(want, have))
	}
}