|
@@ -1,19 +1,15 @@
|
|
|
package container // import "github.com/docker/docker/integration/container"
|
|
|
|
|
|
import (
|
|
|
- "bytes"
|
|
|
"context"
|
|
|
"io/ioutil"
|
|
|
"os"
|
|
|
"testing"
|
|
|
- "time"
|
|
|
|
|
|
"github.com/docker/docker/api/types"
|
|
|
"github.com/docker/docker/api/types/filters"
|
|
|
"github.com/docker/docker/integration/internal/container"
|
|
|
"github.com/docker/docker/integration/internal/request"
|
|
|
- "github.com/docker/docker/pkg/stdcopy"
|
|
|
- "github.com/gotestyourself/gotestyourself/poll"
|
|
|
"github.com/gotestyourself/gotestyourself/skip"
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
"github.com/stretchr/testify/require"
|
|
@@ -29,21 +25,13 @@ func TestLinksEtcHostsContentMatch(t *testing.T) {
|
|
|
client := request.NewAPIClient(t)
|
|
|
ctx := context.Background()
|
|
|
|
|
|
- cID := container.Run(t, ctx, client, container.WithCmd("cat", "/etc/hosts"), container.WithNetworkMode("host"))
|
|
|
-
|
|
|
- poll.WaitOn(t, container.IsStopped(ctx, client, cID), poll.WithDelay(100*time.Millisecond))
|
|
|
-
|
|
|
- body, err := client.ContainerLogs(ctx, cID, types.ContainerLogsOptions{
|
|
|
- ShowStdout: true,
|
|
|
- })
|
|
|
- require.NoError(t, err)
|
|
|
- defer body.Close()
|
|
|
-
|
|
|
- var b bytes.Buffer
|
|
|
- _, err = stdcopy.StdCopy(&b, ioutil.Discard, body)
|
|
|
+ cID := container.Run(t, ctx, client, container.WithNetworkMode("host"))
|
|
|
+ res, err := container.Exec(ctx, client, cID, []string{"cat", "/etc/hosts"})
|
|
|
require.NoError(t, err)
|
|
|
+ require.Empty(t, res.Stderr())
|
|
|
+ require.Equal(t, 0, res.ExitCode)
|
|
|
|
|
|
- assert.Equal(t, string(hosts), b.String())
|
|
|
+ assert.Equal(t, string(hosts), res.Stdout())
|
|
|
}
|
|
|
|
|
|
func TestLinksContainerNames(t *testing.T) {
|