From 16cab103461e645d85449880ab1c06a52beab93b Mon Sep 17 00:00:00 2001 From: Seth Hoenig Date: Tue, 19 Apr 2022 10:24:35 -0500 Subject: [PATCH] ci: fix docker logger not supported test This test checks for behavior when asking for logs of a docker task configured with a log driver that does not support streaming logs. Previously this was using the 'gelf' log driver, but it seems that no longer returns an error as expected. Instead we can just use the 'none' log driver, which has the desired effect 2022-04-19T10:23:19.129-0500 [ERROR] docklog/docker_logger.go:133: log streaming ended with terminal error: error="API error (501): configured logging driver does not support reading" --- drivers/docker/docklog/docker_logger_test.go | 22 +++++++------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/drivers/docker/docklog/docker_logger_test.go b/drivers/docker/docklog/docker_logger_test.go index 611877f3d..d57c09a0d 100644 --- a/drivers/docker/docklog/docker_logger_test.go +++ b/drivers/docker/docklog/docker_logger_test.go @@ -216,8 +216,6 @@ func TestDockerLogger_LoggingNotSupported(t *testing.T) { ci.Parallel(t) ctu.DockerCompatible(t) - require := require.New(t) - containerImage, containerImageName, containerImageTag := testContainerDetails() client, err := docker.NewClientFromEnv() @@ -231,7 +229,7 @@ func TestDockerLogger_LoggingNotSupported(t *testing.T) { Repository: containerImageName, Tag: containerImageTag, }, docker.AuthConfiguration{}) - require.NoError(err, "failed to pull image") + require.NoError(t, err, "failed to pull image") } containerConf := docker.CreateContainerOptions{ @@ -243,19 +241,15 @@ func TestDockerLogger_LoggingNotSupported(t *testing.T) { }, HostConfig: &docker.HostConfig{ LogConfig: docker.LogConfig{ - Type: "gelf", - Config: map[string]string{ - "gelf-address": "udp://localhost:12201", - "mode": "non-blocking", - "max-buffer-size": "4m", - }, + Type: "none", + Config: map[string]string{}, }, }, Context: context.Background(), } container, err := client.CreateContainer(containerConf) - require.NoError(err) + require.NoError(t, err) defer client.RemoveContainer(docker.RemoveContainerOptions{ ID: container.ID, @@ -263,7 +257,7 @@ func TestDockerLogger_LoggingNotSupported(t *testing.T) { }) err = client.StartContainer(container.ID, nil) - require.NoError(err) + require.NoError(t, err) testutil.WaitForResult(func() (bool, error) { container, err = client.InspectContainer(container.ID) @@ -275,7 +269,7 @@ func TestDockerLogger_LoggingNotSupported(t *testing.T) { } return true, nil }, func(err error) { - require.NoError(err) + require.NoError(t, err) }) stdout := &noopCloser{bytes.NewBuffer(nil)} @@ -284,14 +278,14 @@ func TestDockerLogger_LoggingNotSupported(t *testing.T) { dl := NewDockerLogger(testlog.HCLogger(t)).(*dockerLogger) dl.stdout = stdout dl.stderr = stderr - require.NoError(dl.Start(&StartOpts{ + require.NoError(t, dl.Start(&StartOpts{ ContainerID: container.ID, })) select { case <-dl.doneCh: case <-time.After(10 * time.Second): - require.Fail("timedout while waiting for docker_logging to terminate") + require.Fail(t, "timeout while waiting for docker_logging to terminate") } }