1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
11 dockercontainer "github.com/docker/docker/api/types/container"
15 var _ = Suite(&dockerSuite{})
17 type dockerSuite struct {
21 func (s *dockerSuite) SetUpSuite(c *C) {
22 _, err := exec.LookPath("docker")
24 c.Skip("looks like docker is not installed")
26 s.newExecutor = func(c *C) {
27 exec.Command("docker", "rm", "zzzzz-zzzzz-zzzzzzzzzzzzzzz").Run()
29 s.executor, err = newDockerExecutor("zzzzz-zzzzz-zzzzzzzzzzzzzzz", c.Logf, time.Second/2)
34 var _ = Suite(&dockerStubSuite{})
36 // dockerStubSuite tests don't really connect to the docker service,
37 // so we can run them even if docker is not installed.
38 type dockerStubSuite struct{}
40 func (s *dockerStubSuite) TestDockerContainerConfig(c *C) {
41 e, err := newDockerExecutor("zzzzz-zzzzz-zzzzzzzzzzzzzzz", c.Logf, time.Second/2)
43 cfg, hostCfg := e.config(containerSpec{
46 WorkingDir: "/WorkingDir",
47 Env: map[string]string{"FOO": "bar"},
48 BindMounts: map[string]bindmount{"/mnt": {HostPath: "/hostpath", ReadOnly: true}},
52 c.Check(cfg.WorkingDir, Equals, "/WorkingDir")
53 c.Check(cfg.Env, DeepEquals, []string{"FOO=bar"})
54 c.Check(hostCfg.NetworkMode, Equals, dockercontainer.NetworkMode("none"))
55 c.Check(hostCfg.Resources.NanoCPUs, Equals, int64(4000000000))
56 c.Check(hostCfg.Resources.Memory, Equals, int64(123123123))
57 c.Check(hostCfg.Resources.MemorySwap, Equals, int64(123123123))
58 c.Check(hostCfg.Resources.KernelMemory, Equals, int64(123123123))
59 c.Check(hostCfg.Resources.DeviceRequests, DeepEquals, []dockercontainer.DeviceRequest{{
62 Capabilities: [][]string{{"gpu", "nvidia", "compute", "utility"}},