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
1 changed files with 8 additions and 14 deletions

View File

@ -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")
}
}