From 536959ee925a5be0b51057723c8029fd5053ed43 Mon Sep 17 00:00:00 2001 From: Andreas Neumann Date: Fri, 8 May 2020 16:25:08 +0200 Subject: [PATCH] Add more logs for KIND initialization (#80) Signed-off-by: Andreas Neumann --- pkg/test/harness.go | 5 ++++- pkg/test/kind.go | 6 +++++- pkg/test/kind_integration_test.go | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pkg/test/harness.go b/pkg/test/harness.go index 54be331e..2b20f703 100644 --- a/pkg/test/harness.go +++ b/pkg/test/harness.go @@ -115,12 +115,14 @@ func (h *Harness) RunKIND() (*rest.Config, error) { h.kind = &kind if h.kind.IsRunning() { + h.T.Logf("KIND is already running, using existing cluster") return clientcmd.BuildConfigFromFlags("", h.explicitPath()) } kindCfg := &kindConfig.Cluster{} if h.TestSuite.KINDConfig != "" { + h.T.Logf("Loading KIND config from %s", h.TestSuite.KINDConfig) var err error kindCfg, err = loadKindConfig(h.TestSuite.KINDConfig) if err != nil { @@ -138,11 +140,12 @@ func (h *Harness) RunKIND() (*rest.Config, error) { h.addNodeCaches(dockerClient, kindCfg) + h.T.Log("Starting KIND cluster") if err := h.kind.Run(kindCfg); err != nil { return nil, err } - if err := h.kind.AddContainers(dockerClient, h.TestSuite.KINDContainers); err != nil { + if err := h.kind.AddContainers(dockerClient, h.TestSuite.KINDContainers, h.T); err != nil { return nil, err } } diff --git a/pkg/test/kind.go b/pkg/test/kind.go index 679ef3f8..526ceac6 100644 --- a/pkg/test/kind.go +++ b/pkg/test/kind.go @@ -2,6 +2,7 @@ package test import ( "context" + "testing" "sigs.k8s.io/kind/pkg/apis/config/v1alpha3" "sigs.k8s.io/kind/pkg/cluster" @@ -55,11 +56,13 @@ func (k *kind) IsRunning() bool { // AddContainers loads the named Docker containers into a KIND cluster. // The cluster must be running for this to work. -func (k *kind) AddContainers(docker testutils.DockerClient, containers []string) error { +func (k *kind) AddContainers(docker testutils.DockerClient, containers []string, t *testing.T) error { if !k.IsRunning() { panic("KIND cluster isn't running") } + t.Logf("Adding Containers to KIND...\n") + nodes, err := k.Provider.ListNodes(k.context) if err != nil { return err @@ -67,6 +70,7 @@ func (k *kind) AddContainers(docker testutils.DockerClient, containers []string) for _, node := range nodes { for _, container := range containers { + t.Logf("Add image %s to node %s\n", container, node.String()) if err := loadContainer(docker, node, container); err != nil { return err } diff --git a/pkg/test/kind_integration_test.go b/pkg/test/kind_integration_test.go index 85c65fc4..de584a89 100644 --- a/pkg/test/kind_integration_test.go +++ b/pkg/test/kind_integration_test.go @@ -65,7 +65,7 @@ func TestAddContainers(t *testing.T) { t.Errorf("failed to close image pull output: %v", err) } - if err := kind.AddContainers(docker, []string{testImage}); err != nil { + if err := kind.AddContainers(docker, []string{testImage}, t); err != nil { t.Errorf("failed to add container to KIND cluster: %v", err) }