Merge pull request #12622 from hashicorp/b-fix-docker-logger-test

ci: fix docker logger not supported test
This commit is contained in:
Seth Hoenig 2022-04-19 12:57:47 -05:00 committed by GitHub
commit 46066fb7fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -216,8 +216,6 @@ func TestDockerLogger_LoggingNotSupported(t *testing.T) {
ci.Parallel(t) ci.Parallel(t)
ctu.DockerCompatible(t) ctu.DockerCompatible(t)
require := require.New(t)
containerImage, containerImageName, containerImageTag := testContainerDetails() containerImage, containerImageName, containerImageTag := testContainerDetails()
client, err := docker.NewClientFromEnv() client, err := docker.NewClientFromEnv()
@ -231,7 +229,7 @@ func TestDockerLogger_LoggingNotSupported(t *testing.T) {
Repository: containerImageName, Repository: containerImageName,
Tag: containerImageTag, Tag: containerImageTag,
}, docker.AuthConfiguration{}) }, docker.AuthConfiguration{})
require.NoError(err, "failed to pull image") require.NoError(t, err, "failed to pull image")
} }
containerConf := docker.CreateContainerOptions{ containerConf := docker.CreateContainerOptions{
@ -243,19 +241,15 @@ func TestDockerLogger_LoggingNotSupported(t *testing.T) {
}, },
HostConfig: &docker.HostConfig{ HostConfig: &docker.HostConfig{
LogConfig: docker.LogConfig{ LogConfig: docker.LogConfig{
Type: "gelf", Type: "none",
Config: map[string]string{ Config: map[string]string{},
"gelf-address": "udp://localhost:12201",
"mode": "non-blocking",
"max-buffer-size": "4m",
},
}, },
}, },
Context: context.Background(), Context: context.Background(),
} }
container, err := client.CreateContainer(containerConf) container, err := client.CreateContainer(containerConf)
require.NoError(err) require.NoError(t, err)
defer client.RemoveContainer(docker.RemoveContainerOptions{ defer client.RemoveContainer(docker.RemoveContainerOptions{
ID: container.ID, ID: container.ID,
@ -263,7 +257,7 @@ func TestDockerLogger_LoggingNotSupported(t *testing.T) {
}) })
err = client.StartContainer(container.ID, nil) err = client.StartContainer(container.ID, nil)
require.NoError(err) require.NoError(t, err)
testutil.WaitForResult(func() (bool, error) { testutil.WaitForResult(func() (bool, error) {
container, err = client.InspectContainer(container.ID) container, err = client.InspectContainer(container.ID)
@ -275,7 +269,7 @@ func TestDockerLogger_LoggingNotSupported(t *testing.T) {
} }
return true, nil return true, nil
}, func(err error) { }, func(err error) {
require.NoError(err) require.NoError(t, err)
}) })
stdout := &noopCloser{bytes.NewBuffer(nil)} stdout := &noopCloser{bytes.NewBuffer(nil)}
@ -284,14 +278,14 @@ func TestDockerLogger_LoggingNotSupported(t *testing.T) {
dl := NewDockerLogger(testlog.HCLogger(t)).(*dockerLogger) dl := NewDockerLogger(testlog.HCLogger(t)).(*dockerLogger)
dl.stdout = stdout dl.stdout = stdout
dl.stderr = stderr dl.stderr = stderr
require.NoError(dl.Start(&StartOpts{ require.NoError(t, dl.Start(&StartOpts{
ContainerID: container.ID, ContainerID: container.ID,
})) }))
select { select {
case <-dl.doneCh: case <-dl.doneCh:
case <-time.After(10 * time.Second): 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")
} }
} }