diff --git a/.circleci/config.yml b/.circleci/config.yml index 97e954da..3fcbf5f7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -198,6 +198,7 @@ jobs: CREATE_IMAGE: 1 USE_IMAGE: 1 IMAGE_NAME: centos-cloud/centos-7 + WKP_DEBUG: true working_directory: /src/github.com/weaveworks/wksctl steps: - checkout @@ -269,6 +270,7 @@ jobs: CREATE_IMAGE: 1 USE_IMAGE: 1 IMAGE_NAME: rhel-cloud/rhel-7 + WKP_DEBUG: false working_directory: /src/github.com/weaveworks/wksctl steps: - checkout diff --git a/test/integration/spawn/executor.go b/test/integration/spawn/executor.go index abf56ad1..02e869fc 100644 --- a/test/integration/spawn/executor.go +++ b/test/integration/spawn/executor.go @@ -144,8 +144,16 @@ func (e *Executor) RunCmd(cmd *exec.Cmd) (*Entry, error) { return nil, err } - go e.handStream(entry, stdout, stdoutPipe) - go e.handStream(entry, stderr, stderrPipe) + syncChan := make(chan bool) + go func() { + e.handStream(entry, stdout, stdoutPipe) + syncChan <- true + }() + + go func() { + e.handStream(entry, stderr, stderrPipe) + syncChan <- true + }() if e.showBreadcrumbs { fmt.Printf("=== EXE %s\n", strings.Join(cmd.Args, " ")) @@ -155,6 +163,10 @@ func (e *Executor) RunCmd(cmd *exec.Cmd) (*Entry, error) { return nil, err } + // Make sure copying is finished + <-syncChan + <-syncChan + err = cmd.Wait() exitCode, err := exitCode(err) entry.exitCode = exitCode diff --git a/test/integration/test/apply_test.go b/test/integration/test/apply_test.go index 63fa5c6a..361dd13f 100644 --- a/test/integration/test/apply_test.go +++ b/test/integration/test/apply_test.go @@ -271,6 +271,29 @@ func testKubectl(t *testing.T, kubeconfig string) { assert.True(t, run.Contains("Ready")) } +func testDebugLogging(t *testing.T, kubeconfig string) { + exe := run.NewExecutor() + + run, err := exe.RunV(kubectl, + fmt.Sprintf("--kubeconfig=%s", kubeconfig), "get", "pods", "-l", "name=wks-controller", "--namespace=default", "-o", "jsonpath={.items[].spec.containers[].command}") + assert.NoError(t, err) + assert.Equal(t, 0, run.ExitCode()) + verbose := false + if run.Contains("--verbose") { + verbose = true + } + + run, err = exe.RunV(kubectl, + fmt.Sprintf("--kubeconfig=%s", kubeconfig), "logs", "-l", "name=wks-controller", "--namespace=default") + assert.NoError(t, err) + assert.Equal(t, 0, run.ExitCode()) + if verbose { + assert.True(t, run.Contains("level=debug")) + } else { + assert.False(t, run.Contains("level=debug")) + } +} + func nodeIsMaster(n *v1.Node) bool { const masterLabel = "node-role.kubernetes.io/master" if _, ok := n.Labels[masterLabel]; ok { @@ -450,4 +473,9 @@ func TestApply(t *testing.T) { t.Run("kubectl", func(t *testing.T) { testKubectl(t, kubeconfig) }) + + // Test the we are getting debug logging messages. + t.Run("loglevel", func(t *testing.T) { + testDebugLogging(t, kubeconfig) + }) } diff --git a/test/integration/test/kubectl b/test/integration/test/kubectl new file mode 100755 index 00000000..7ddc7cf2 Binary files /dev/null and b/test/integration/test/kubectl differ