mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
5bf33adba2
``` $ DOCKER_EXPERIMENTAL=1 DOCKER_ROOTLESS=1 TEST_SKIP_INTEGRATION_CLI=1 \ make test-integration ``` test-integration-cli is unsupported currently. Also, tests that spawn custom daemon (testutil/daemon) are skipped. Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
package container // import "github.com/docker/docker/integration/container"
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"io"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/docker/docker/api/types"
|
|
"github.com/docker/docker/integration/internal/container"
|
|
"gotest.tools/v3/assert"
|
|
is "gotest.tools/v3/assert/cmp"
|
|
"gotest.tools/v3/poll"
|
|
"gotest.tools/v3/skip"
|
|
)
|
|
|
|
func TestStats(t *testing.T) {
|
|
skip.If(t, testEnv.DaemonInfo.CgroupDriver == "none")
|
|
skip.If(t, !testEnv.DaemonInfo.MemoryLimit)
|
|
|
|
defer setupTest(t)()
|
|
client := testEnv.APIClient()
|
|
ctx := context.Background()
|
|
|
|
info, err := client.Info(ctx)
|
|
assert.NilError(t, err)
|
|
|
|
cID := container.Run(ctx, t, client)
|
|
|
|
poll.WaitOn(t, container.IsInState(ctx, client, cID, "running"), poll.WithDelay(100*time.Millisecond))
|
|
|
|
resp, err := client.ContainerStats(ctx, cID, false)
|
|
assert.NilError(t, err)
|
|
defer resp.Body.Close()
|
|
|
|
var v *types.Stats
|
|
err = json.NewDecoder(resp.Body).Decode(&v)
|
|
assert.NilError(t, err)
|
|
assert.Check(t, is.Equal(int64(v.MemoryStats.Limit), info.MemTotal))
|
|
err = json.NewDecoder(resp.Body).Decode(&v)
|
|
assert.Assert(t, is.ErrorContains(err, ""), io.EOF)
|
|
}
|