|
@@ -30,8 +30,10 @@ import org.apache.hadoop.registry.client.binding.RegistryPathUtils;
|
|
import org.apache.hadoop.security.Credentials;
|
|
import org.apache.hadoop.security.Credentials;
|
|
import org.apache.hadoop.util.Shell;
|
|
import org.apache.hadoop.util.Shell;
|
|
import org.apache.hadoop.util.StringUtils;
|
|
import org.apache.hadoop.util.StringUtils;
|
|
|
|
+import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
|
|
import org.apache.hadoop.yarn.api.records.ContainerId;
|
|
import org.apache.hadoop.yarn.api.records.ContainerId;
|
|
import org.apache.hadoop.yarn.api.records.ContainerLaunchContext;
|
|
import org.apache.hadoop.yarn.api.records.ContainerLaunchContext;
|
|
|
|
+import org.apache.hadoop.yarn.server.nodemanager.LocalDirsHandlerService;
|
|
import org.apache.hadoop.yarn.util.DockerClientConfigHandler;
|
|
import org.apache.hadoop.yarn.util.DockerClientConfigHandler;
|
|
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
|
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
|
import org.apache.hadoop.yarn.security.TestDockerClientConfigHandler;
|
|
import org.apache.hadoop.yarn.security.TestDockerClientConfigHandler;
|
|
@@ -84,6 +86,7 @@ import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
import java.util.Random;
|
|
import java.util.Random;
|
|
import java.util.Set;
|
|
import java.util.Set;
|
|
|
|
+import java.util.concurrent.ConcurrentMap;
|
|
|
|
|
|
import static org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.LinuxContainerRuntimeConstants.APPID;
|
|
import static org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.LinuxContainerRuntimeConstants.APPID;
|
|
import static org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.LinuxContainerRuntimeConstants.APPLICATION_LOCAL_DIRS;
|
|
import static org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.LinuxContainerRuntimeConstants.APPLICATION_LOCAL_DIRS;
|
|
@@ -104,6 +107,7 @@ import static org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.r
|
|
import static org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.LinuxContainerRuntimeConstants.TC_COMMAND_FILE;
|
|
import static org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.LinuxContainerRuntimeConstants.TC_COMMAND_FILE;
|
|
import static org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.LinuxContainerRuntimeConstants.USER;
|
|
import static org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.LinuxContainerRuntimeConstants.USER;
|
|
import static org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.LinuxContainerRuntimeConstants.USER_FILECACHE_DIRS;
|
|
import static org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.LinuxContainerRuntimeConstants.USER_FILECACHE_DIRS;
|
|
|
|
+import static org.mockito.Matchers.anyString;
|
|
import static org.mockito.Mockito.any;
|
|
import static org.mockito.Mockito.any;
|
|
import static org.mockito.Mockito.anyBoolean;
|
|
import static org.mockito.Mockito.anyBoolean;
|
|
import static org.mockito.Mockito.anyList;
|
|
import static org.mockito.Mockito.anyList;
|
|
@@ -123,7 +127,9 @@ public class TestDockerContainerRuntime {
|
|
private String containerId;
|
|
private String containerId;
|
|
private Container container;
|
|
private Container container;
|
|
private ContainerId cId;
|
|
private ContainerId cId;
|
|
|
|
+ private ApplicationAttemptId appAttemptId;
|
|
private ContainerLaunchContext context;
|
|
private ContainerLaunchContext context;
|
|
|
|
+ private Context nmContext;
|
|
private HashMap<String, String> env;
|
|
private HashMap<String, String> env;
|
|
private String image;
|
|
private String image;
|
|
private String uidGidPair;
|
|
private String uidGidPair;
|
|
@@ -162,13 +168,15 @@ public class TestDockerContainerRuntime {
|
|
mockExecutor = Mockito
|
|
mockExecutor = Mockito
|
|
.mock(PrivilegedOperationExecutor.class);
|
|
.mock(PrivilegedOperationExecutor.class);
|
|
mockCGroupsHandler = Mockito.mock(CGroupsHandler.class);
|
|
mockCGroupsHandler = Mockito.mock(CGroupsHandler.class);
|
|
- containerId = "container_id";
|
|
|
|
|
|
+ containerId = "container_e11_1518975676334_14532816_01_000001";
|
|
container = mock(Container.class);
|
|
container = mock(Container.class);
|
|
cId = mock(ContainerId.class);
|
|
cId = mock(ContainerId.class);
|
|
|
|
+ appAttemptId = mock(ApplicationAttemptId.class);
|
|
context = mock(ContainerLaunchContext.class);
|
|
context = mock(ContainerLaunchContext.class);
|
|
env = new HashMap<String, String>();
|
|
env = new HashMap<String, String>();
|
|
env.put("FROM_CLIENT", "1");
|
|
env.put("FROM_CLIENT", "1");
|
|
image = "busybox:latest";
|
|
image = "busybox:latest";
|
|
|
|
+ nmContext = createMockNMContext();
|
|
|
|
|
|
dockerStopGracePeriod = conf.getInt(
|
|
dockerStopGracePeriod = conf.getInt(
|
|
YarnConfiguration.NM_DOCKER_STOP_GRACE_PERIOD,
|
|
YarnConfiguration.NM_DOCKER_STOP_GRACE_PERIOD,
|
|
@@ -177,6 +185,7 @@ public class TestDockerContainerRuntime {
|
|
env.put(DockerLinuxContainerRuntime.ENV_DOCKER_CONTAINER_IMAGE, image);
|
|
env.put(DockerLinuxContainerRuntime.ENV_DOCKER_CONTAINER_IMAGE, image);
|
|
when(container.getContainerId()).thenReturn(cId);
|
|
when(container.getContainerId()).thenReturn(cId);
|
|
when(cId.toString()).thenReturn(containerId);
|
|
when(cId.toString()).thenReturn(containerId);
|
|
|
|
+ when(cId.getApplicationAttemptId()).thenReturn(appAttemptId);
|
|
when(container.getLaunchContext()).thenReturn(context);
|
|
when(container.getLaunchContext()).thenReturn(context);
|
|
when(context.getEnvironment()).thenReturn(env);
|
|
when(context.getEnvironment()).thenReturn(env);
|
|
when(container.getUser()).thenReturn(submittingUser);
|
|
when(container.getUser()).thenReturn(submittingUser);
|
|
@@ -265,6 +274,34 @@ public class TestDockerContainerRuntime {
|
|
.setExecutionAttribute(RESOURCES_OPTIONS, resourcesOptions);
|
|
.setExecutionAttribute(RESOURCES_OPTIONS, resourcesOptions);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public Context createMockNMContext() {
|
|
|
|
+ Context mockNMContext = mock(Context.class);
|
|
|
|
+ LocalDirsHandlerService localDirsHandler =
|
|
|
|
+ mock(LocalDirsHandlerService.class);
|
|
|
|
+ ResourcePluginManager resourcePluginManager =
|
|
|
|
+ mock(ResourcePluginManager.class);
|
|
|
|
+
|
|
|
|
+ String tmpPath = new StringBuffer(System.getProperty("test.build.data"))
|
|
|
|
+ .append('/').append("hadoop.tmp.dir").toString();
|
|
|
|
+
|
|
|
|
+ ConcurrentMap<ContainerId, Container> containerMap =
|
|
|
|
+ mock(ConcurrentMap.class);
|
|
|
|
+
|
|
|
|
+ when(mockNMContext.getLocalDirsHandler()).thenReturn(localDirsHandler);
|
|
|
|
+ when(mockNMContext.getResourcePluginManager())
|
|
|
|
+ .thenReturn(resourcePluginManager);
|
|
|
|
+ when(mockNMContext.getContainers()).thenReturn(containerMap);
|
|
|
|
+ when(containerMap.get(any())).thenReturn(container);
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ when(localDirsHandler.getLocalPathForWrite(anyString()))
|
|
|
|
+ .thenReturn(new Path(tmpPath));
|
|
|
|
+ } catch (IOException ioe) {
|
|
|
|
+ LOG.info("LocalDirsHandler failed" + ioe);
|
|
|
|
+ }
|
|
|
|
+ return mockNMContext;
|
|
|
|
+ }
|
|
|
|
+
|
|
@Test
|
|
@Test
|
|
public void testSelectDockerContainerType() {
|
|
public void testSelectDockerContainerType() {
|
|
Map<String, String> envDockerType = new HashMap<>();
|
|
Map<String, String> envDockerType = new HashMap<>();
|
|
@@ -341,7 +378,7 @@ public class TestDockerContainerRuntime {
|
|
IOException {
|
|
IOException {
|
|
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
|
|
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
|
|
mockExecutor, mockCGroupsHandler);
|
|
mockExecutor, mockCGroupsHandler);
|
|
- runtime.initialize(conf, null);
|
|
|
|
|
|
+ runtime.initialize(conf, nmContext);
|
|
runtime.launchContainer(builder.build());
|
|
runtime.launchContainer(builder.build());
|
|
|
|
|
|
PrivilegedOperation op = capturePrivilegedOperationAndVerifyArgs();
|
|
PrivilegedOperation op = capturePrivilegedOperationAndVerifyArgs();
|
|
@@ -368,7 +405,9 @@ public class TestDockerContainerRuntime {
|
|
Assert.assertEquals(
|
|
Assert.assertEquals(
|
|
" launch-command=bash,/test_container_work_dir/launch_container.sh",
|
|
" launch-command=bash,/test_container_work_dir/launch_container.sh",
|
|
dockerCommands.get(counter++));
|
|
dockerCommands.get(counter++));
|
|
- Assert.assertEquals(" name=container_id", dockerCommands.get(counter++));
|
|
|
|
|
|
+ Assert.assertEquals(
|
|
|
|
+ " name=container_e11_1518975676334_14532816_01_000001",
|
|
|
|
+ dockerCommands.get(counter++));
|
|
Assert.assertEquals(" net=host", dockerCommands.get(counter++));
|
|
Assert.assertEquals(" net=host", dockerCommands.get(counter++));
|
|
Assert.assertEquals(" ro-mounts=/test_filecache_dir:/test_filecache_dir,"
|
|
Assert.assertEquals(" ro-mounts=/test_filecache_dir:/test_filecache_dir,"
|
|
+ "/test_user_filecache_dir:/test_user_filecache_dir",
|
|
+ "/test_user_filecache_dir:/test_user_filecache_dir",
|
|
@@ -390,7 +429,7 @@ public class TestDockerContainerRuntime {
|
|
true);
|
|
true);
|
|
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
|
|
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
|
|
mockExecutor, mockCGroupsHandler);
|
|
mockExecutor, mockCGroupsHandler);
|
|
- runtime.initialize(conf, null);
|
|
|
|
|
|
+ runtime.initialize(conf, nmContext);
|
|
runtime.launchContainer(builder.build());
|
|
runtime.launchContainer(builder.build());
|
|
|
|
|
|
PrivilegedOperation op = capturePrivilegedOperationAndVerifyArgs();
|
|
PrivilegedOperation op = capturePrivilegedOperationAndVerifyArgs();
|
|
@@ -416,7 +455,9 @@ public class TestDockerContainerRuntime {
|
|
Assert.assertEquals(
|
|
Assert.assertEquals(
|
|
" launch-command=bash,/test_container_work_dir/launch_container.sh",
|
|
" launch-command=bash,/test_container_work_dir/launch_container.sh",
|
|
dockerCommands.get(counter++));
|
|
dockerCommands.get(counter++));
|
|
- Assert.assertEquals(" name=container_id", dockerCommands.get(counter++));
|
|
|
|
|
|
+ Assert.assertEquals(
|
|
|
|
+ " name=container_e11_1518975676334_14532816_01_000001",
|
|
|
|
+ dockerCommands.get(counter++));
|
|
Assert
|
|
Assert
|
|
.assertEquals(" net=host", dockerCommands.get(counter++));
|
|
.assertEquals(" net=host", dockerCommands.get(counter++));
|
|
Assert.assertEquals(" ro-mounts=/test_filecache_dir:/test_filecache_dir,"
|
|
Assert.assertEquals(" ro-mounts=/test_filecache_dir:/test_filecache_dir,"
|
|
@@ -439,7 +480,7 @@ public class TestDockerContainerRuntime {
|
|
|
|
|
|
DockerLinuxContainerRuntime runtime =
|
|
DockerLinuxContainerRuntime runtime =
|
|
new DockerLinuxContainerRuntime(mockExecutor, mockCGroupsHandler);
|
|
new DockerLinuxContainerRuntime(mockExecutor, mockCGroupsHandler);
|
|
- runtime.initialize(conf, null);
|
|
|
|
|
|
+ runtime.initialize(conf, nmContext);
|
|
|
|
|
|
//invalid default network configuration - sdn2 is included in allowed
|
|
//invalid default network configuration - sdn2 is included in allowed
|
|
// networks
|
|
// networks
|
|
@@ -455,7 +496,7 @@ public class TestDockerContainerRuntime {
|
|
try {
|
|
try {
|
|
runtime =
|
|
runtime =
|
|
new DockerLinuxContainerRuntime(mockExecutor, mockCGroupsHandler);
|
|
new DockerLinuxContainerRuntime(mockExecutor, mockCGroupsHandler);
|
|
- runtime.initialize(conf, null);
|
|
|
|
|
|
+ runtime.initialize(conf, nmContext);
|
|
Assert.fail("Invalid default network configuration should did not "
|
|
Assert.fail("Invalid default network configuration should did not "
|
|
+ "trigger initialization failure.");
|
|
+ "trigger initialization failure.");
|
|
} catch (ContainerExecutionException e) {
|
|
} catch (ContainerExecutionException e) {
|
|
@@ -471,7 +512,7 @@ public class TestDockerContainerRuntime {
|
|
validDefaultNetwork);
|
|
validDefaultNetwork);
|
|
runtime =
|
|
runtime =
|
|
new DockerLinuxContainerRuntime(mockExecutor, mockCGroupsHandler);
|
|
new DockerLinuxContainerRuntime(mockExecutor, mockCGroupsHandler);
|
|
- runtime.initialize(conf, null);
|
|
|
|
|
|
+ runtime.initialize(conf, nmContext);
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
@@ -481,7 +522,7 @@ public class TestDockerContainerRuntime {
|
|
PrivilegedOperationException {
|
|
PrivilegedOperationException {
|
|
DockerLinuxContainerRuntime runtime =
|
|
DockerLinuxContainerRuntime runtime =
|
|
new DockerLinuxContainerRuntime(mockExecutor, mockCGroupsHandler);
|
|
new DockerLinuxContainerRuntime(mockExecutor, mockCGroupsHandler);
|
|
- runtime.initialize(conf, null);
|
|
|
|
|
|
+ runtime.initialize(conf, nmContext);
|
|
|
|
|
|
Random randEngine = new Random();
|
|
Random randEngine = new Random();
|
|
String disallowedNetwork = "sdn" + Integer.toString(randEngine.nextInt());
|
|
String disallowedNetwork = "sdn" + Integer.toString(randEngine.nextInt());
|
|
@@ -532,7 +573,9 @@ public class TestDockerContainerRuntime {
|
|
Assert.assertEquals(
|
|
Assert.assertEquals(
|
|
" launch-command=bash,/test_container_work_dir/launch_container.sh",
|
|
" launch-command=bash,/test_container_work_dir/launch_container.sh",
|
|
dockerCommands.get(counter++));
|
|
dockerCommands.get(counter++));
|
|
- Assert.assertEquals(" name=container_id", dockerCommands.get(counter++));
|
|
|
|
|
|
+ Assert.assertEquals(
|
|
|
|
+ " name=container_e11_1518975676334_14532816_01_000001",
|
|
|
|
+ dockerCommands.get(counter++));
|
|
Assert
|
|
Assert
|
|
.assertEquals(" net=" + allowedNetwork, dockerCommands.get(counter++));
|
|
.assertEquals(" net=" + allowedNetwork, dockerCommands.get(counter++));
|
|
Assert.assertEquals(" ro-mounts=/test_filecache_dir:/test_filecache_dir,"
|
|
Assert.assertEquals(" ro-mounts=/test_filecache_dir:/test_filecache_dir,"
|
|
@@ -557,7 +600,7 @@ public class TestDockerContainerRuntime {
|
|
conf.setBoolean(RegistryConstants.KEY_DNS_ENABLED, true);
|
|
conf.setBoolean(RegistryConstants.KEY_DNS_ENABLED, true);
|
|
DockerLinuxContainerRuntime runtime =
|
|
DockerLinuxContainerRuntime runtime =
|
|
new DockerLinuxContainerRuntime(mockExecutor, mockCGroupsHandler);
|
|
new DockerLinuxContainerRuntime(mockExecutor, mockCGroupsHandler);
|
|
- runtime.initialize(conf, null);
|
|
|
|
|
|
+ runtime.initialize(conf, nmContext);
|
|
|
|
|
|
String expectedHostname = "test.hostname";
|
|
String expectedHostname = "test.hostname";
|
|
env.put(DockerLinuxContainerRuntime.ENV_DOCKER_CONTAINER_HOSTNAME,
|
|
env.put(DockerLinuxContainerRuntime.ENV_DOCKER_CONTAINER_HOSTNAME,
|
|
@@ -590,7 +633,9 @@ public class TestDockerContainerRuntime {
|
|
Assert.assertEquals(
|
|
Assert.assertEquals(
|
|
" launch-command=bash,/test_container_work_dir/launch_container.sh",
|
|
" launch-command=bash,/test_container_work_dir/launch_container.sh",
|
|
dockerCommands.get(counter++));
|
|
dockerCommands.get(counter++));
|
|
- Assert.assertEquals(" name=container_id", dockerCommands.get(counter++));
|
|
|
|
|
|
+ Assert.assertEquals(
|
|
|
|
+ " name=container_e11_1518975676334_14532816_01_000001",
|
|
|
|
+ dockerCommands.get(counter++));
|
|
Assert
|
|
Assert
|
|
.assertEquals(" net=host", dockerCommands.get(counter++));
|
|
.assertEquals(" net=host", dockerCommands.get(counter++));
|
|
Assert.assertEquals(" ro-mounts=/test_filecache_dir:/test_filecache_dir,"
|
|
Assert.assertEquals(" ro-mounts=/test_filecache_dir:/test_filecache_dir,"
|
|
@@ -628,7 +673,7 @@ public class TestDockerContainerRuntime {
|
|
customNetwork1);
|
|
customNetwork1);
|
|
|
|
|
|
//this should cause no failures.
|
|
//this should cause no failures.
|
|
- runtime.initialize(conf, null);
|
|
|
|
|
|
+ runtime.initialize(conf, nmContext);
|
|
runtime.launchContainer(builder.build());
|
|
runtime.launchContainer(builder.build());
|
|
PrivilegedOperation op = capturePrivilegedOperationAndVerifyArgs();
|
|
PrivilegedOperation op = capturePrivilegedOperationAndVerifyArgs();
|
|
List<String> args = op.getArguments();
|
|
List<String> args = op.getArguments();
|
|
@@ -651,13 +696,17 @@ public class TestDockerContainerRuntime {
|
|
Assert.assertEquals(" docker-command=run", dockerCommands.get(counter++));
|
|
Assert.assertEquals(" docker-command=run", dockerCommands.get(counter++));
|
|
Assert.assertEquals(" group-add=" + String.join(",", groups),
|
|
Assert.assertEquals(" group-add=" + String.join(",", groups),
|
|
dockerCommands.get(counter++));
|
|
dockerCommands.get(counter++));
|
|
- Assert.assertEquals(" hostname=ctr-id", dockerCommands.get(counter++));
|
|
|
|
|
|
+ Assert.assertEquals(
|
|
|
|
+ " hostname=ctr-e11-1518975676334-14532816-01-000001",
|
|
|
|
+ dockerCommands.get(counter++));
|
|
Assert
|
|
Assert
|
|
.assertEquals(" image=busybox:latest", dockerCommands.get(counter++));
|
|
.assertEquals(" image=busybox:latest", dockerCommands.get(counter++));
|
|
Assert.assertEquals(
|
|
Assert.assertEquals(
|
|
" launch-command=bash,/test_container_work_dir/launch_container.sh",
|
|
" launch-command=bash,/test_container_work_dir/launch_container.sh",
|
|
dockerCommands.get(counter++));
|
|
dockerCommands.get(counter++));
|
|
- Assert.assertEquals(" name=container_id", dockerCommands.get(counter++));
|
|
|
|
|
|
+ Assert.assertEquals(
|
|
|
|
+ " name=container_e11_1518975676334_14532816_01_000001",
|
|
|
|
+ dockerCommands.get(counter++));
|
|
Assert.assertEquals(" net=sdn1", dockerCommands.get(counter++));
|
|
Assert.assertEquals(" net=sdn1", dockerCommands.get(counter++));
|
|
Assert.assertEquals(" ro-mounts=/test_filecache_dir:/test_filecache_dir,"
|
|
Assert.assertEquals(" ro-mounts=/test_filecache_dir:/test_filecache_dir,"
|
|
+ "/test_user_filecache_dir:/test_user_filecache_dir",
|
|
+ "/test_user_filecache_dir:/test_user_filecache_dir",
|
|
@@ -696,14 +745,18 @@ public class TestDockerContainerRuntime {
|
|
Assert.assertEquals(" docker-command=run", dockerCommands.get(counter++));
|
|
Assert.assertEquals(" docker-command=run", dockerCommands.get(counter++));
|
|
Assert.assertEquals(" group-add=" + String.join(",", groups),
|
|
Assert.assertEquals(" group-add=" + String.join(",", groups),
|
|
dockerCommands.get(counter++));
|
|
dockerCommands.get(counter++));
|
|
- Assert.assertEquals(" hostname=ctr-id", dockerCommands.get(counter++));
|
|
|
|
|
|
+ Assert.assertEquals(
|
|
|
|
+ " hostname=ctr-e11-1518975676334-14532816-01-000001",
|
|
|
|
+ dockerCommands.get(counter++));
|
|
Assert
|
|
Assert
|
|
.assertEquals(" image=busybox:latest", dockerCommands.get(counter++));
|
|
.assertEquals(" image=busybox:latest", dockerCommands.get(counter++));
|
|
Assert.assertEquals(
|
|
Assert.assertEquals(
|
|
" launch-command=bash,/test_container_work_dir/launch_container.sh",
|
|
" launch-command=bash,/test_container_work_dir/launch_container.sh",
|
|
dockerCommands.get(counter++));
|
|
dockerCommands.get(counter++));
|
|
|
|
|
|
- Assert.assertEquals(" name=container_id", dockerCommands.get(counter++));
|
|
|
|
|
|
+ Assert.assertEquals(
|
|
|
|
+ " name=container_e11_1518975676334_14532816_01_000001",
|
|
|
|
+ dockerCommands.get(counter++));
|
|
Assert.assertEquals(" net=sdn2", dockerCommands.get(counter++));
|
|
Assert.assertEquals(" net=sdn2", dockerCommands.get(counter++));
|
|
Assert.assertEquals(" ro-mounts=/test_filecache_dir:/test_filecache_dir,"
|
|
Assert.assertEquals(" ro-mounts=/test_filecache_dir:/test_filecache_dir,"
|
|
+ "/test_user_filecache_dir:/test_user_filecache_dir",
|
|
+ "/test_user_filecache_dir:/test_user_filecache_dir",
|
|
@@ -736,7 +789,7 @@ public class TestDockerContainerRuntime {
|
|
IOException {
|
|
IOException {
|
|
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
|
|
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
|
|
mockExecutor, mockCGroupsHandler);
|
|
mockExecutor, mockCGroupsHandler);
|
|
- runtime.initialize(conf, null);
|
|
|
|
|
|
+ runtime.initialize(conf, nmContext);
|
|
|
|
|
|
env.put(DockerLinuxContainerRuntime
|
|
env.put(DockerLinuxContainerRuntime
|
|
.ENV_DOCKER_CONTAINER_PID_NAMESPACE, "invalid-value");
|
|
.ENV_DOCKER_CONTAINER_PID_NAMESPACE, "invalid-value");
|
|
@@ -764,7 +817,7 @@ public class TestDockerContainerRuntime {
|
|
throws ContainerExecutionException {
|
|
throws ContainerExecutionException {
|
|
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
|
|
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
|
|
mockExecutor, mockCGroupsHandler);
|
|
mockExecutor, mockCGroupsHandler);
|
|
- runtime.initialize(conf, null);
|
|
|
|
|
|
+ runtime.initialize(conf, nmContext);
|
|
|
|
|
|
env.put(DockerLinuxContainerRuntime
|
|
env.put(DockerLinuxContainerRuntime
|
|
.ENV_DOCKER_CONTAINER_PID_NAMESPACE, "host");
|
|
.ENV_DOCKER_CONTAINER_PID_NAMESPACE, "host");
|
|
@@ -787,7 +840,7 @@ public class TestDockerContainerRuntime {
|
|
|
|
|
|
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
|
|
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
|
|
mockExecutor, mockCGroupsHandler);
|
|
mockExecutor, mockCGroupsHandler);
|
|
- runtime.initialize(conf, null);
|
|
|
|
|
|
+ runtime.initialize(conf, nmContext);
|
|
|
|
|
|
env.put(DockerLinuxContainerRuntime
|
|
env.put(DockerLinuxContainerRuntime
|
|
.ENV_DOCKER_CONTAINER_PID_NAMESPACE, "host");
|
|
.ENV_DOCKER_CONTAINER_PID_NAMESPACE, "host");
|
|
@@ -817,7 +870,9 @@ public class TestDockerContainerRuntime {
|
|
Assert.assertEquals(
|
|
Assert.assertEquals(
|
|
" launch-command=bash,/test_container_work_dir/launch_container.sh",
|
|
" launch-command=bash,/test_container_work_dir/launch_container.sh",
|
|
dockerCommands.get(counter++));
|
|
dockerCommands.get(counter++));
|
|
- Assert.assertEquals(" name=container_id", dockerCommands.get(counter++));
|
|
|
|
|
|
+ Assert.assertEquals(
|
|
|
|
+ " name=container_e11_1518975676334_14532816_01_000001",
|
|
|
|
+ dockerCommands.get(counter++));
|
|
Assert.assertEquals(" net=host", dockerCommands.get(counter++));
|
|
Assert.assertEquals(" net=host", dockerCommands.get(counter++));
|
|
Assert.assertEquals(" pid=host", dockerCommands.get(counter++));
|
|
Assert.assertEquals(" pid=host", dockerCommands.get(counter++));
|
|
Assert.assertEquals(" ro-mounts=/test_filecache_dir:/test_filecache_dir,"
|
|
Assert.assertEquals(" ro-mounts=/test_filecache_dir:/test_filecache_dir,"
|
|
@@ -838,7 +893,7 @@ public class TestDockerContainerRuntime {
|
|
IOException {
|
|
IOException {
|
|
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
|
|
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
|
|
mockExecutor, mockCGroupsHandler);
|
|
mockExecutor, mockCGroupsHandler);
|
|
- runtime.initialize(conf, null);
|
|
|
|
|
|
+ runtime.initialize(conf, nmContext);
|
|
|
|
|
|
env.put(DockerLinuxContainerRuntime
|
|
env.put(DockerLinuxContainerRuntime
|
|
.ENV_DOCKER_CONTAINER_RUN_PRIVILEGED_CONTAINER, "invalid-value");
|
|
.ENV_DOCKER_CONTAINER_RUN_PRIVILEGED_CONTAINER, "invalid-value");
|
|
@@ -866,7 +921,7 @@ public class TestDockerContainerRuntime {
|
|
throws ContainerExecutionException {
|
|
throws ContainerExecutionException {
|
|
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
|
|
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
|
|
mockExecutor, mockCGroupsHandler);
|
|
mockExecutor, mockCGroupsHandler);
|
|
- runtime.initialize(conf, null);
|
|
|
|
|
|
+ runtime.initialize(conf, nmContext);
|
|
|
|
|
|
env.put(DockerLinuxContainerRuntime
|
|
env.put(DockerLinuxContainerRuntime
|
|
.ENV_DOCKER_CONTAINER_RUN_PRIVILEGED_CONTAINER, "true");
|
|
.ENV_DOCKER_CONTAINER_RUN_PRIVILEGED_CONTAINER, "true");
|
|
@@ -888,7 +943,7 @@ public class TestDockerContainerRuntime {
|
|
|
|
|
|
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
|
|
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
|
|
mockExecutor, mockCGroupsHandler);
|
|
mockExecutor, mockCGroupsHandler);
|
|
- runtime.initialize(conf, null);
|
|
|
|
|
|
+ runtime.initialize(conf, nmContext);
|
|
|
|
|
|
env.put(DockerLinuxContainerRuntime
|
|
env.put(DockerLinuxContainerRuntime
|
|
.ENV_DOCKER_CONTAINER_RUN_PRIVILEGED_CONTAINER, "true");
|
|
.ENV_DOCKER_CONTAINER_RUN_PRIVILEGED_CONTAINER, "true");
|
|
@@ -917,7 +972,7 @@ public class TestDockerContainerRuntime {
|
|
|
|
|
|
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
|
|
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
|
|
mockExecutor, mockCGroupsHandler);
|
|
mockExecutor, mockCGroupsHandler);
|
|
- runtime.initialize(conf, null);
|
|
|
|
|
|
+ runtime.initialize(conf, nmContext);
|
|
|
|
|
|
env.put(DockerLinuxContainerRuntime
|
|
env.put(DockerLinuxContainerRuntime
|
|
.ENV_DOCKER_CONTAINER_RUN_PRIVILEGED_CONTAINER, "true");
|
|
.ENV_DOCKER_CONTAINER_RUN_PRIVILEGED_CONTAINER, "true");
|
|
@@ -944,7 +999,7 @@ public class TestDockerContainerRuntime {
|
|
|
|
|
|
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
|
|
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
|
|
mockExecutor, mockCGroupsHandler);
|
|
mockExecutor, mockCGroupsHandler);
|
|
- runtime.initialize(conf, null);
|
|
|
|
|
|
+ runtime.initialize(conf, nmContext);
|
|
|
|
|
|
env.put(DockerLinuxContainerRuntime
|
|
env.put(DockerLinuxContainerRuntime
|
|
.ENV_DOCKER_CONTAINER_RUN_PRIVILEGED_CONTAINER, "true");
|
|
.ENV_DOCKER_CONTAINER_RUN_PRIVILEGED_CONTAINER, "true");
|
|
@@ -972,7 +1027,9 @@ public class TestDockerContainerRuntime {
|
|
Assert.assertEquals(
|
|
Assert.assertEquals(
|
|
" launch-command=bash,/test_container_work_dir/launch_container.sh",
|
|
" launch-command=bash,/test_container_work_dir/launch_container.sh",
|
|
dockerCommands.get(counter++));
|
|
dockerCommands.get(counter++));
|
|
- Assert.assertEquals(" name=container_id", dockerCommands.get(counter++));
|
|
|
|
|
|
+ Assert.assertEquals(
|
|
|
|
+ " name=container_e11_1518975676334_14532816_01_000001",
|
|
|
|
+ dockerCommands.get(counter++));
|
|
Assert.assertEquals(" net=host", dockerCommands.get(counter++));
|
|
Assert.assertEquals(" net=host", dockerCommands.get(counter++));
|
|
Assert.assertEquals(" privileged=true", dockerCommands.get(counter++));
|
|
Assert.assertEquals(" privileged=true", dockerCommands.get(counter++));
|
|
Assert.assertEquals(" ro-mounts=/test_filecache_dir:/test_filecache_dir,"
|
|
Assert.assertEquals(" ro-mounts=/test_filecache_dir:/test_filecache_dir,"
|
|
@@ -996,7 +1053,7 @@ public class TestDockerContainerRuntime {
|
|
|
|
|
|
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime
|
|
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime
|
|
(mockExecutor, mockCGroupsHandler);
|
|
(mockExecutor, mockCGroupsHandler);
|
|
- runtime.initialize(conf, null);
|
|
|
|
|
|
+ runtime.initialize(conf, nmContext);
|
|
|
|
|
|
String resourceOptionsNone = "cgroups=none";
|
|
String resourceOptionsNone = "cgroups=none";
|
|
DockerRunCommand command = Mockito.mock(DockerRunCommand.class);
|
|
DockerRunCommand command = Mockito.mock(DockerRunCommand.class);
|
|
@@ -1023,7 +1080,7 @@ public class TestDockerContainerRuntime {
|
|
|
|
|
|
runtime = new DockerLinuxContainerRuntime
|
|
runtime = new DockerLinuxContainerRuntime
|
|
(mockExecutor, null);
|
|
(mockExecutor, null);
|
|
- runtime.initialize(conf, null);
|
|
|
|
|
|
+ runtime.initialize(conf, nmContext);
|
|
|
|
|
|
runtime.addCGroupParentIfRequired(resourceOptionsNone, containerIdStr,
|
|
runtime.addCGroupParentIfRequired(resourceOptionsNone, containerIdStr,
|
|
command);
|
|
command);
|
|
@@ -1038,7 +1095,7 @@ public class TestDockerContainerRuntime {
|
|
public void testMountSourceOnly() throws ContainerExecutionException {
|
|
public void testMountSourceOnly() throws ContainerExecutionException {
|
|
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
|
|
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
|
|
mockExecutor, mockCGroupsHandler);
|
|
mockExecutor, mockCGroupsHandler);
|
|
- runtime.initialize(conf, null);
|
|
|
|
|
|
+ runtime.initialize(conf, nmContext);
|
|
|
|
|
|
env.put(
|
|
env.put(
|
|
DockerLinuxContainerRuntime.ENV_DOCKER_CONTAINER_LOCAL_RESOURCE_MOUNTS,
|
|
DockerLinuxContainerRuntime.ENV_DOCKER_CONTAINER_LOCAL_RESOURCE_MOUNTS,
|
|
@@ -1058,7 +1115,7 @@ public class TestDockerContainerRuntime {
|
|
IOException {
|
|
IOException {
|
|
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
|
|
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
|
|
mockExecutor, mockCGroupsHandler);
|
|
mockExecutor, mockCGroupsHandler);
|
|
- runtime.initialize(conf, null);
|
|
|
|
|
|
+ runtime.initialize(conf, nmContext);
|
|
|
|
|
|
env.put(
|
|
env.put(
|
|
DockerLinuxContainerRuntime.ENV_DOCKER_CONTAINER_LOCAL_RESOURCE_MOUNTS,
|
|
DockerLinuxContainerRuntime.ENV_DOCKER_CONTAINER_LOCAL_RESOURCE_MOUNTS,
|
|
@@ -1089,7 +1146,9 @@ public class TestDockerContainerRuntime {
|
|
Assert.assertEquals(
|
|
Assert.assertEquals(
|
|
" launch-command=bash,/test_container_work_dir/launch_container.sh",
|
|
" launch-command=bash,/test_container_work_dir/launch_container.sh",
|
|
dockerCommands.get(counter++));
|
|
dockerCommands.get(counter++));
|
|
- Assert.assertEquals(" name=container_id", dockerCommands.get(counter++));
|
|
|
|
|
|
+ Assert.assertEquals(
|
|
|
|
+ " name=container_e11_1518975676334_14532816_01_000001",
|
|
|
|
+ dockerCommands.get(counter++));
|
|
Assert.assertEquals(" net=host", dockerCommands.get(counter++));
|
|
Assert.assertEquals(" net=host", dockerCommands.get(counter++));
|
|
Assert.assertEquals(
|
|
Assert.assertEquals(
|
|
" ro-mounts=/test_filecache_dir:/test_filecache_dir,/"
|
|
" ro-mounts=/test_filecache_dir:/test_filecache_dir,/"
|
|
@@ -1109,7 +1168,7 @@ public class TestDockerContainerRuntime {
|
|
public void testMountInvalid() throws ContainerExecutionException {
|
|
public void testMountInvalid() throws ContainerExecutionException {
|
|
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
|
|
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
|
|
mockExecutor, mockCGroupsHandler);
|
|
mockExecutor, mockCGroupsHandler);
|
|
- runtime.initialize(conf, null);
|
|
|
|
|
|
+ runtime.initialize(conf, nmContext);
|
|
|
|
|
|
env.put(
|
|
env.put(
|
|
DockerLinuxContainerRuntime.ENV_DOCKER_CONTAINER_LOCAL_RESOURCE_MOUNTS,
|
|
DockerLinuxContainerRuntime.ENV_DOCKER_CONTAINER_LOCAL_RESOURCE_MOUNTS,
|
|
@@ -1129,7 +1188,7 @@ public class TestDockerContainerRuntime {
|
|
IOException {
|
|
IOException {
|
|
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
|
|
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
|
|
mockExecutor, mockCGroupsHandler);
|
|
mockExecutor, mockCGroupsHandler);
|
|
- runtime.initialize(conf, null);
|
|
|
|
|
|
+ runtime.initialize(conf, nmContext);
|
|
|
|
|
|
env.put(
|
|
env.put(
|
|
DockerLinuxContainerRuntime.ENV_DOCKER_CONTAINER_LOCAL_RESOURCE_MOUNTS,
|
|
DockerLinuxContainerRuntime.ENV_DOCKER_CONTAINER_LOCAL_RESOURCE_MOUNTS,
|
|
@@ -1161,7 +1220,9 @@ public class TestDockerContainerRuntime {
|
|
Assert.assertEquals(
|
|
Assert.assertEquals(
|
|
" launch-command=bash,/test_container_work_dir/launch_container.sh",
|
|
" launch-command=bash,/test_container_work_dir/launch_container.sh",
|
|
dockerCommands.get(counter++));
|
|
dockerCommands.get(counter++));
|
|
- Assert.assertEquals(" name=container_id", dockerCommands.get(counter++));
|
|
|
|
|
|
+ Assert.assertEquals(
|
|
|
|
+ " name=container_e11_1518975676334_14532816_01_000001",
|
|
|
|
+ dockerCommands.get(counter++));
|
|
Assert.assertEquals(" net=host", dockerCommands.get(counter++));
|
|
Assert.assertEquals(" net=host", dockerCommands.get(counter++));
|
|
Assert.assertEquals(
|
|
Assert.assertEquals(
|
|
" ro-mounts=/test_filecache_dir:/test_filecache_dir,"
|
|
" ro-mounts=/test_filecache_dir:/test_filecache_dir,"
|
|
@@ -1184,7 +1245,7 @@ public class TestDockerContainerRuntime {
|
|
IOException {
|
|
IOException {
|
|
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
|
|
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
|
|
mockExecutor, mockCGroupsHandler);
|
|
mockExecutor, mockCGroupsHandler);
|
|
- runtime.initialize(conf, null);
|
|
|
|
|
|
+ runtime.initialize(conf, nmContext);
|
|
|
|
|
|
env.put(
|
|
env.put(
|
|
DockerLinuxContainerRuntime.ENV_DOCKER_CONTAINER_MOUNTS,
|
|
DockerLinuxContainerRuntime.ENV_DOCKER_CONTAINER_MOUNTS,
|
|
@@ -1215,7 +1276,9 @@ public class TestDockerContainerRuntime {
|
|
Assert.assertEquals(
|
|
Assert.assertEquals(
|
|
" launch-command=bash,/test_container_work_dir/launch_container.sh",
|
|
" launch-command=bash,/test_container_work_dir/launch_container.sh",
|
|
dockerCommands.get(counter++));
|
|
dockerCommands.get(counter++));
|
|
- Assert.assertEquals(" name=container_id", dockerCommands.get(counter++));
|
|
|
|
|
|
+ Assert.assertEquals(
|
|
|
|
+ " name=container_e11_1518975676334_14532816_01_000001",
|
|
|
|
+ dockerCommands.get(counter++));
|
|
Assert.assertEquals(" net=host", dockerCommands.get(counter++));
|
|
Assert.assertEquals(" net=host", dockerCommands.get(counter++));
|
|
Assert.assertEquals(" ro-mounts=/test_filecache_dir:/test_filecache_dir,"
|
|
Assert.assertEquals(" ro-mounts=/test_filecache_dir:/test_filecache_dir,"
|
|
+ "/test_user_filecache_dir:/test_user_filecache_dir,"
|
|
+ "/test_user_filecache_dir:/test_user_filecache_dir,"
|
|
@@ -1235,7 +1298,7 @@ public class TestDockerContainerRuntime {
|
|
public void testUserMountInvalid() throws ContainerExecutionException {
|
|
public void testUserMountInvalid() throws ContainerExecutionException {
|
|
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
|
|
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
|
|
mockExecutor, mockCGroupsHandler);
|
|
mockExecutor, mockCGroupsHandler);
|
|
- runtime.initialize(conf, null);
|
|
|
|
|
|
+ runtime.initialize(conf, nmContext);
|
|
|
|
|
|
env.put(
|
|
env.put(
|
|
DockerLinuxContainerRuntime.ENV_DOCKER_CONTAINER_MOUNTS,
|
|
DockerLinuxContainerRuntime.ENV_DOCKER_CONTAINER_MOUNTS,
|
|
@@ -1253,7 +1316,7 @@ public class TestDockerContainerRuntime {
|
|
public void testUserMountModeInvalid() throws ContainerExecutionException {
|
|
public void testUserMountModeInvalid() throws ContainerExecutionException {
|
|
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
|
|
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
|
|
mockExecutor, mockCGroupsHandler);
|
|
mockExecutor, mockCGroupsHandler);
|
|
- runtime.initialize(conf, null);
|
|
|
|
|
|
+ runtime.initialize(conf, nmContext);
|
|
|
|
|
|
env.put(
|
|
env.put(
|
|
DockerLinuxContainerRuntime.ENV_DOCKER_CONTAINER_MOUNTS,
|
|
DockerLinuxContainerRuntime.ENV_DOCKER_CONTAINER_MOUNTS,
|
|
@@ -1271,7 +1334,7 @@ public class TestDockerContainerRuntime {
|
|
public void testUserMountModeNulInvalid() throws ContainerExecutionException {
|
|
public void testUserMountModeNulInvalid() throws ContainerExecutionException {
|
|
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
|
|
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
|
|
mockExecutor, mockCGroupsHandler);
|
|
mockExecutor, mockCGroupsHandler);
|
|
- runtime.initialize(conf, null);
|
|
|
|
|
|
+ runtime.initialize(conf, nmContext);
|
|
|
|
|
|
env.put(
|
|
env.put(
|
|
DockerLinuxContainerRuntime.ENV_DOCKER_CONTAINER_MOUNTS,
|
|
DockerLinuxContainerRuntime.ENV_DOCKER_CONTAINER_MOUNTS,
|
|
@@ -1318,7 +1381,9 @@ public class TestDockerContainerRuntime {
|
|
Assert.assertEquals(4, dockerCommands.size());
|
|
Assert.assertEquals(4, dockerCommands.size());
|
|
Assert.assertEquals("[docker-command-execution]", dockerCommands.get(0));
|
|
Assert.assertEquals("[docker-command-execution]", dockerCommands.get(0));
|
|
Assert.assertEquals(" docker-command=stop", dockerCommands.get(1));
|
|
Assert.assertEquals(" docker-command=stop", dockerCommands.get(1));
|
|
- Assert.assertEquals(" name=container_id", dockerCommands.get(2));
|
|
|
|
|
|
+ Assert.assertEquals(
|
|
|
|
+ " name=container_e11_1518975676334_14532816_01_000001",
|
|
|
|
+ dockerCommands.get(2));
|
|
Assert.assertEquals(" time=10", dockerCommands.get(3));
|
|
Assert.assertEquals(" time=10", dockerCommands.get(3));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1332,7 +1397,9 @@ public class TestDockerContainerRuntime {
|
|
Assert.assertEquals(4, dockerCommands.size());
|
|
Assert.assertEquals(4, dockerCommands.size());
|
|
Assert.assertEquals("[docker-command-execution]", dockerCommands.get(0));
|
|
Assert.assertEquals("[docker-command-execution]", dockerCommands.get(0));
|
|
Assert.assertEquals(" docker-command=stop", dockerCommands.get(1));
|
|
Assert.assertEquals(" docker-command=stop", dockerCommands.get(1));
|
|
- Assert.assertEquals(" name=container_id", dockerCommands.get(2));
|
|
|
|
|
|
+ Assert.assertEquals(
|
|
|
|
+ " name=container_e11_1518975676334_14532816_01_000001",
|
|
|
|
+ dockerCommands.get(2));
|
|
Assert.assertEquals(" time=10", dockerCommands.get(3));
|
|
Assert.assertEquals(" time=10", dockerCommands.get(3));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1344,7 +1411,9 @@ public class TestDockerContainerRuntime {
|
|
Assert.assertEquals(4, dockerCommands.size());
|
|
Assert.assertEquals(4, dockerCommands.size());
|
|
Assert.assertEquals("[docker-command-execution]", dockerCommands.get(0));
|
|
Assert.assertEquals("[docker-command-execution]", dockerCommands.get(0));
|
|
Assert.assertEquals(" docker-command=kill", dockerCommands.get(1));
|
|
Assert.assertEquals(" docker-command=kill", dockerCommands.get(1));
|
|
- Assert.assertEquals(" name=container_id", dockerCommands.get(2));
|
|
|
|
|
|
+ Assert.assertEquals(
|
|
|
|
+ " name=container_e11_1518975676334_14532816_01_000001",
|
|
|
|
+ dockerCommands.get(2));
|
|
Assert.assertEquals(" signal=QUIT", dockerCommands.get(3));
|
|
Assert.assertEquals(" signal=QUIT", dockerCommands.get(3));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1563,7 +1632,7 @@ public class TestDockerContainerRuntime {
|
|
any(File.class), anyMap(), anyBoolean(), anyBoolean())).thenReturn(
|
|
any(File.class), anyMap(), anyBoolean(), anyBoolean())).thenReturn(
|
|
dockerVolumeListOutput);
|
|
dockerVolumeListOutput);
|
|
|
|
|
|
- Context nmContext = mock(Context.class);
|
|
|
|
|
|
+ Context mockNMContext = createMockNMContext();
|
|
ResourcePluginManager rpm = mock(ResourcePluginManager.class);
|
|
ResourcePluginManager rpm = mock(ResourcePluginManager.class);
|
|
Map<String, ResourcePlugin> pluginsMap = new HashMap<>();
|
|
Map<String, ResourcePlugin> pluginsMap = new HashMap<>();
|
|
ResourcePlugin plugin1 = mock(ResourcePlugin.class);
|
|
ResourcePlugin plugin1 = mock(ResourcePlugin.class);
|
|
@@ -1580,9 +1649,9 @@ public class TestDockerContainerRuntime {
|
|
|
|
|
|
when(rpm.getNameToPlugins()).thenReturn(pluginsMap);
|
|
when(rpm.getNameToPlugins()).thenReturn(pluginsMap);
|
|
|
|
|
|
- when(nmContext.getResourcePluginManager()).thenReturn(rpm);
|
|
|
|
|
|
+ when(mockNMContext.getResourcePluginManager()).thenReturn(rpm);
|
|
|
|
|
|
- runtime.initialize(conf, nmContext);
|
|
|
|
|
|
+ runtime.initialize(conf, mockNMContext);
|
|
|
|
|
|
ContainerRuntimeContext containerRuntimeContext = builder.build();
|
|
ContainerRuntimeContext containerRuntimeContext = builder.build();
|
|
|
|
|
|
@@ -1660,7 +1729,7 @@ public class TestDockerContainerRuntime {
|
|
any(File.class), anyMap(), anyBoolean(), anyBoolean())).thenReturn(
|
|
any(File.class), anyMap(), anyBoolean(), anyBoolean())).thenReturn(
|
|
"volume1,local");
|
|
"volume1,local");
|
|
|
|
|
|
- Context nmContext = mock(Context.class);
|
|
|
|
|
|
+ Context mockNMContext = createMockNMContext();
|
|
ResourcePluginManager rpm = mock(ResourcePluginManager.class);
|
|
ResourcePluginManager rpm = mock(ResourcePluginManager.class);
|
|
Map<String, ResourcePlugin> pluginsMap = new HashMap<>();
|
|
Map<String, ResourcePlugin> pluginsMap = new HashMap<>();
|
|
ResourcePlugin plugin1 = mock(ResourcePlugin.class);
|
|
ResourcePlugin plugin1 = mock(ResourcePlugin.class);
|
|
@@ -1677,9 +1746,9 @@ public class TestDockerContainerRuntime {
|
|
|
|
|
|
when(rpm.getNameToPlugins()).thenReturn(pluginsMap);
|
|
when(rpm.getNameToPlugins()).thenReturn(pluginsMap);
|
|
|
|
|
|
- when(nmContext.getResourcePluginManager()).thenReturn(rpm);
|
|
|
|
|
|
+ when(mockNMContext.getResourcePluginManager()).thenReturn(rpm);
|
|
|
|
|
|
- runtime.initialize(conf, nmContext);
|
|
|
|
|
|
+ runtime.initialize(conf, mockNMContext);
|
|
|
|
|
|
ContainerRuntimeContext containerRuntimeContext = builder.build();
|
|
ContainerRuntimeContext containerRuntimeContext = builder.build();
|
|
|
|
|
|
@@ -1711,7 +1780,9 @@ public class TestDockerContainerRuntime {
|
|
Assert.assertEquals(
|
|
Assert.assertEquals(
|
|
" launch-command=bash,/test_container_work_dir/launch_container.sh",
|
|
" launch-command=bash,/test_container_work_dir/launch_container.sh",
|
|
dockerCommands.get(counter++));
|
|
dockerCommands.get(counter++));
|
|
- Assert.assertEquals(" name=container_id", dockerCommands.get(counter++));
|
|
|
|
|
|
+ Assert.assertEquals(
|
|
|
|
+ " name=container_e11_1518975676334_14532816_01_000001",
|
|
|
|
+ dockerCommands.get(counter++));
|
|
Assert.assertEquals(" net=host", dockerCommands.get(counter++));
|
|
Assert.assertEquals(" net=host", dockerCommands.get(counter++));
|
|
Assert.assertEquals(" ro-mounts=/test_filecache_dir:/test_filecache_dir,"
|
|
Assert.assertEquals(" ro-mounts=/test_filecache_dir:/test_filecache_dir,"
|
|
+ "/test_user_filecache_dir:/test_user_filecache_dir,"
|
|
+ "/test_user_filecache_dir:/test_user_filecache_dir,"
|
|
@@ -1737,7 +1808,7 @@ public class TestDockerContainerRuntime {
|
|
try {
|
|
try {
|
|
conf.setStrings(YarnConfiguration.NM_DOCKER_CONTAINER_CAPABILITIES,
|
|
conf.setStrings(YarnConfiguration.NM_DOCKER_CONTAINER_CAPABILITIES,
|
|
"none", "CHOWN", "DAC_OVERRIDE");
|
|
"none", "CHOWN", "DAC_OVERRIDE");
|
|
- runtime.initialize(conf, null);
|
|
|
|
|
|
+ runtime.initialize(conf, nmContext);
|
|
Assert.fail("Initialize didn't fail with invalid capabilities " +
|
|
Assert.fail("Initialize didn't fail with invalid capabilities " +
|
|
"'none', 'CHOWN', 'DAC_OVERRIDE'");
|
|
"'none', 'CHOWN', 'DAC_OVERRIDE'");
|
|
} catch (ContainerExecutionException e) {
|
|
} catch (ContainerExecutionException e) {
|
|
@@ -1746,7 +1817,7 @@ public class TestDockerContainerRuntime {
|
|
try {
|
|
try {
|
|
conf.setStrings(YarnConfiguration.NM_DOCKER_CONTAINER_CAPABILITIES,
|
|
conf.setStrings(YarnConfiguration.NM_DOCKER_CONTAINER_CAPABILITIES,
|
|
"CHOWN", "DAC_OVERRIDE", "NONE");
|
|
"CHOWN", "DAC_OVERRIDE", "NONE");
|
|
- runtime.initialize(conf, null);
|
|
|
|
|
|
+ runtime.initialize(conf, nmContext);
|
|
Assert.fail("Initialize didn't fail with invalid capabilities " +
|
|
Assert.fail("Initialize didn't fail with invalid capabilities " +
|
|
"'CHOWN', 'DAC_OVERRIDE', 'NONE'");
|
|
"'CHOWN', 'DAC_OVERRIDE', 'NONE'");
|
|
} catch (ContainerExecutionException e) {
|
|
} catch (ContainerExecutionException e) {
|
|
@@ -1754,17 +1825,17 @@ public class TestDockerContainerRuntime {
|
|
|
|
|
|
conf.setStrings(YarnConfiguration.NM_DOCKER_CONTAINER_CAPABILITIES,
|
|
conf.setStrings(YarnConfiguration.NM_DOCKER_CONTAINER_CAPABILITIES,
|
|
"NONE");
|
|
"NONE");
|
|
- runtime.initialize(conf, null);
|
|
|
|
|
|
+ runtime.initialize(conf, nmContext);
|
|
Assert.assertEquals(0, runtime.getCapabilities().size());
|
|
Assert.assertEquals(0, runtime.getCapabilities().size());
|
|
|
|
|
|
conf.setStrings(YarnConfiguration.NM_DOCKER_CONTAINER_CAPABILITIES,
|
|
conf.setStrings(YarnConfiguration.NM_DOCKER_CONTAINER_CAPABILITIES,
|
|
"none");
|
|
"none");
|
|
- runtime.initialize(conf, null);
|
|
|
|
|
|
+ runtime.initialize(conf, nmContext);
|
|
Assert.assertEquals(0, runtime.getCapabilities().size());
|
|
Assert.assertEquals(0, runtime.getCapabilities().size());
|
|
|
|
|
|
conf.setStrings(YarnConfiguration.NM_DOCKER_CONTAINER_CAPABILITIES,
|
|
conf.setStrings(YarnConfiguration.NM_DOCKER_CONTAINER_CAPABILITIES,
|
|
"CHOWN", "DAC_OVERRIDE");
|
|
"CHOWN", "DAC_OVERRIDE");
|
|
- runtime.initialize(conf, null);
|
|
|
|
|
|
+ runtime.initialize(conf, nmContext);
|
|
Iterator<String> it = runtime.getCapabilities().iterator();
|
|
Iterator<String> it = runtime.getCapabilities().iterator();
|
|
Assert.assertEquals("CHOWN", it.next());
|
|
Assert.assertEquals("CHOWN", it.next());
|
|
Assert.assertEquals("DAC_OVERRIDE", it.next());
|
|
Assert.assertEquals("DAC_OVERRIDE", it.next());
|
|
@@ -1792,7 +1863,7 @@ public class TestDockerContainerRuntime {
|
|
when(context.getTokens()).thenReturn(tokens);
|
|
when(context.getTokens()).thenReturn(tokens);
|
|
DockerLinuxContainerRuntime runtime =
|
|
DockerLinuxContainerRuntime runtime =
|
|
new DockerLinuxContainerRuntime(mockExecutor, mockCGroupsHandler);
|
|
new DockerLinuxContainerRuntime(mockExecutor, mockCGroupsHandler);
|
|
- runtime.initialize(conf, null);
|
|
|
|
|
|
+ runtime.initialize(conf, nmContext);
|
|
|
|
|
|
Set<PosixFilePermission> perms =
|
|
Set<PosixFilePermission> perms =
|
|
PosixFilePermissions.fromString("rwxr-xr--");
|
|
PosixFilePermissions.fromString("rwxr-xr--");
|
|
@@ -1852,7 +1923,9 @@ public class TestDockerContainerRuntime {
|
|
Assert.assertEquals(
|
|
Assert.assertEquals(
|
|
" launch-command=bash,/test_container_work_dir/launch_container.sh",
|
|
" launch-command=bash,/test_container_work_dir/launch_container.sh",
|
|
dockerCommands.get(counter++));
|
|
dockerCommands.get(counter++));
|
|
- Assert.assertEquals(" name=container_id", dockerCommands.get(counter++));
|
|
|
|
|
|
+ Assert.assertEquals(
|
|
|
|
+ " name=container_e11_1518975676334_14532816_01_000001",
|
|
|
|
+ dockerCommands.get(counter++));
|
|
Assert.assertEquals(" net=host", dockerCommands.get(counter++));
|
|
Assert.assertEquals(" net=host", dockerCommands.get(counter++));
|
|
Assert.assertEquals(" ro-mounts=/test_filecache_dir:/test_filecache_dir,"
|
|
Assert.assertEquals(" ro-mounts=/test_filecache_dir:/test_filecache_dir,"
|
|
+ "/test_user_filecache_dir:/test_user_filecache_dir",
|
|
+ "/test_user_filecache_dir:/test_user_filecache_dir",
|
|
@@ -1889,7 +1962,9 @@ public class TestDockerContainerRuntime {
|
|
dockerCommands.get(counter++));
|
|
dockerCommands.get(counter++));
|
|
Assert.assertEquals(" docker-command=start",
|
|
Assert.assertEquals(" docker-command=start",
|
|
dockerCommands.get(counter++));
|
|
dockerCommands.get(counter++));
|
|
- Assert.assertEquals(" name=container_id", dockerCommands.get(counter));
|
|
|
|
|
|
+ Assert.assertEquals(
|
|
|
|
+ " name=container_e11_1518975676334_14532816_01_000001",
|
|
|
|
+ dockerCommands.get(counter));
|
|
}
|
|
}
|
|
|
|
|
|
class MockRuntime extends DockerLinuxContainerRuntime {
|
|
class MockRuntime extends DockerLinuxContainerRuntime {
|
|
@@ -1922,7 +1997,8 @@ public class TestDockerContainerRuntime {
|
|
new DockerStopCommand(containerName)
|
|
new DockerStopCommand(containerName)
|
|
.setGracePeriod(dockerStopGracePeriod);
|
|
.setGracePeriod(dockerStopGracePeriod);
|
|
DockerCommandExecutor.executeDockerCommand(dockerStopCommand,
|
|
DockerCommandExecutor.executeDockerCommand(dockerStopCommand,
|
|
- containerName, environment, conf, mockExecutor, false);
|
|
|
|
|
|
+ containerName, environment, conf, mockExecutor, false,
|
|
|
|
+ nmContext);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
if (DockerCommandExecutor.isKillable(containerStatus)) {
|
|
if (DockerCommandExecutor.isKillable(containerStatus)) {
|
|
@@ -1930,7 +2006,8 @@ public class TestDockerContainerRuntime {
|
|
new DockerKillCommand(containerName);
|
|
new DockerKillCommand(containerName);
|
|
dockerKillCommand.setSignal(signal.name());
|
|
dockerKillCommand.setSignal(signal.name());
|
|
DockerCommandExecutor.executeDockerCommand(dockerKillCommand,
|
|
DockerCommandExecutor.executeDockerCommand(dockerKillCommand,
|
|
- containerName, environment, conf, mockExecutor, false);
|
|
|
|
|
|
+ containerName, environment, conf, mockExecutor, false,
|
|
|
|
+ nmContext);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} catch (ContainerExecutionException e) {
|
|
} catch (ContainerExecutionException e) {
|
|
@@ -1953,7 +2030,7 @@ public class TestDockerContainerRuntime {
|
|
DockerRmCommand dockerRmCommand = new DockerRmCommand(containerId);
|
|
DockerRmCommand dockerRmCommand = new DockerRmCommand(containerId);
|
|
DockerCommandExecutor
|
|
DockerCommandExecutor
|
|
.executeDockerCommand(dockerRmCommand, containerId, env, conf,
|
|
.executeDockerCommand(dockerRmCommand, containerId, env, conf,
|
|
- privilegedOperationExecutor, false);
|
|
|
|
|
|
+ privilegedOperationExecutor, false, nmContext);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|