Merge pull request #36569 from kolyshkin/t-etc-hosts
TestLinksEtcHostsContentMatch: use container.Exec()
This commit is contained in:
commit
fb95dc7eac
1 changed files with 5 additions and 17 deletions
|
@ -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,
|
||||
})
|
||||
cID := container.Run(t, ctx, client, container.WithNetworkMode("host"))
|
||||
res, err := container.Exec(ctx, client, cID, []string{"cat", "/etc/hosts"})
|
||||
require.NoError(t, err)
|
||||
defer body.Close()
|
||||
require.Empty(t, res.Stderr())
|
||||
require.Equal(t, 0, res.ExitCode)
|
||||
|
||||
var b bytes.Buffer
|
||||
_, err = stdcopy.StdCopy(&b, ioutil.Discard, body)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Equal(t, string(hosts), b.String())
|
||||
assert.Equal(t, string(hosts), res.Stdout())
|
||||
}
|
||||
|
||||
func TestLinksContainerNames(t *testing.T) {
|
||||
|
|
Loading…
Add table
Reference in a new issue