From 41681fa1d2effb971b07667c2a863fae3511d7cd Mon Sep 17 00:00:00 2001 From: Kris Hicks Date: Tue, 26 Jan 2021 07:58:01 -0800 Subject: [PATCH] Add unit test for container namespacing --- drivers/shared/executor/executor_linux_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/shared/executor/executor_linux_test.go b/drivers/shared/executor/executor_linux_test.go index e8fbeae95..a75abf3ad 100644 --- a/drivers/shared/executor/executor_linux_test.go +++ b/drivers/shared/executor/executor_linux_test.go @@ -125,6 +125,15 @@ func TestExecutor_IsolationAndConstraints(t *testing.T) { expectedMemLim := strconv.Itoa(int(execCmd.Resources.NomadResources.Memory.MemoryMB * 1024 * 1024)) actualMemLim := strings.TrimSpace(string(data)) require.Equal(actualMemLim, expectedMemLim) + + // Check that namespaces were applied to the container config + config := lexec.container.Config() + require.NoError(err) + + require.Contains(config.Namespaces, lconfigs.Namespace{Type: lconfigs.NEWNS}) + require.Contains(config.Namespaces, lconfigs.Namespace{Type: lconfigs.NEWPID}) + + // Shut down executor require.NoError(executor.Shutdown("", 0)) executor.Wait(context.Background())