2018-02-08 21:35:51 -05:00
|
|
|
package container // import "github.com/docker/docker/integration/container"
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"encoding/json"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/docker/docker/client"
|
2018-02-09 13:37:55 -05:00
|
|
|
"github.com/docker/docker/integration/internal/container"
|
2018-04-17 04:22:04 -04:00
|
|
|
"github.com/docker/docker/internal/test/request"
|
2018-06-11 09:32:11 -04:00
|
|
|
"gotest.tools/assert"
|
|
|
|
is "gotest.tools/assert/cmp"
|
|
|
|
"gotest.tools/poll"
|
|
|
|
"gotest.tools/skip"
|
2018-02-08 21:35:51 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestInspectCpusetInConfigPre120(t *testing.T) {
|
2018-04-19 05:14:15 -04:00
|
|
|
skip.If(t, testEnv.DaemonInfo.OSType == "windows" || !testEnv.DaemonInfo.CPUSet)
|
2018-02-08 21:35:51 -05:00
|
|
|
|
|
|
|
defer setupTest(t)()
|
|
|
|
client := request.NewAPIClient(t, client.WithVersion("1.19"))
|
|
|
|
ctx := context.Background()
|
|
|
|
|
2018-03-21 17:47:49 -04:00
|
|
|
name := "cpusetinconfig-pre120-" + t.Name()
|
2018-02-08 21:35:51 -05:00
|
|
|
// Create container with up to-date-API
|
2018-02-09 13:37:55 -05:00
|
|
|
container.Run(t, ctx, request.NewAPIClient(t), container.WithName(name),
|
|
|
|
container.WithCmd("true"),
|
|
|
|
func(c *container.TestContainerConfig) {
|
|
|
|
c.HostConfig.Resources.CpusetCpus = "0"
|
|
|
|
},
|
|
|
|
)
|
2018-02-22 05:30:51 -05:00
|
|
|
poll.WaitOn(t, container.IsInState(ctx, client, name, "exited"), poll.WithDelay(100*time.Millisecond))
|
2018-02-08 21:35:51 -05:00
|
|
|
|
|
|
|
_, body, err := client.ContainerInspectWithRaw(ctx, name, false)
|
2018-03-13 15:28:34 -04:00
|
|
|
assert.NilError(t, err)
|
2018-02-08 21:35:51 -05:00
|
|
|
|
|
|
|
var inspectJSON map[string]interface{}
|
|
|
|
err = json.Unmarshal(body, &inspectJSON)
|
2018-03-13 15:28:34 -04:00
|
|
|
assert.NilError(t, err, "unable to unmarshal body for version 1.19: %s", err)
|
2018-02-08 21:35:51 -05:00
|
|
|
|
|
|
|
config, ok := inspectJSON["Config"]
|
2018-03-13 15:28:34 -04:00
|
|
|
assert.Check(t, is.Equal(true, ok), "Unable to find 'Config'")
|
2018-02-08 21:35:51 -05:00
|
|
|
|
|
|
|
cfg := config.(map[string]interface{})
|
|
|
|
_, ok = cfg["Cpuset"]
|
2018-03-13 15:28:34 -04:00
|
|
|
assert.Check(t, is.Equal(true, ok), "API version 1.19 expected to include Cpuset in 'Config'")
|
2018-02-08 21:35:51 -05:00
|
|
|
}
|