Skip to content

Commit

Permalink
pids_limit: Add test.
Browse files Browse the repository at this point in the history
Signed-off-by: Shishir Mahajan <smahajan@roblox.com>
  • Loading branch information
shishir-a412ed committed Nov 17, 2021
1 parent 124765c commit 35423c9
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions drivers/docker/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,27 @@ func TestDockerDriver_CreateContainerConfig_RuntimeConflict(t *testing.T) {
require.Contains(t, err.Error(), "conflicting runtime requests")
}

func TestDockerDriver_PidsLimit(t *testing.T) {
t.Parallel()

dh := dockerDriverHarness(t, nil)
driver := dh.Impl().(*Driver)
driver.config.PidsLimit = 5

task, cfg, ports := dockerTask(t)
defer freeport.Return(ports)
require.NoError(t, task.EncodeConcreteDriverConfig(cfg))

c, err := driver.createContainerConfig(task, cfg, "org/repo:0.1")
require.NoError(t, err)
require.Equal(t, 5, c.HostConfig.PidsLimit)

cfg.PidsLimit = 7
_, err := driver.createContainerConfig(task, cfg, "org/repo:0.1")
require.Error(t, err)
require.Contains(t, err.Error(), `pids_limit cannot be greater than nomad plugin config pids_limit`)
}

func TestDockerDriver_CreateContainerConfig_ChecksAllowRuntimes(t *testing.T) {
t.Parallel()

Expand Down

0 comments on commit 35423c9

Please sign in to comment.