|
@@ -57,6 +57,8 @@ import org.junit.Before;
|
|
import org.junit.Rule;
|
|
import org.junit.Rule;
|
|
import org.junit.Test;
|
|
import org.junit.Test;
|
|
import org.junit.rules.TemporaryFolder;
|
|
import org.junit.rules.TemporaryFolder;
|
|
|
|
+import org.junit.runner.RunWith;
|
|
|
|
+import org.junit.runners.Parameterized;
|
|
import org.mockito.ArgumentCaptor;
|
|
import org.mockito.ArgumentCaptor;
|
|
import org.mockito.Mockito;
|
|
import org.mockito.Mockito;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
@@ -75,6 +77,8 @@ import java.nio.file.attribute.FileAttribute;
|
|
import java.nio.file.attribute.PosixFilePermission;
|
|
import java.nio.file.attribute.PosixFilePermission;
|
|
import java.nio.file.attribute.PosixFilePermissions;
|
|
import java.nio.file.attribute.PosixFilePermissions;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.Arrays;
|
|
|
|
+import java.util.Collection;
|
|
import java.util.Collections;
|
|
import java.util.Collections;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.Iterator;
|
|
import java.util.Iterator;
|
|
@@ -98,7 +102,9 @@ import static org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.r
|
|
import static org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.LinuxContainerRuntimeConstants.LOCAL_DIRS;
|
|
import static org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.LinuxContainerRuntimeConstants.LOCAL_DIRS;
|
|
import static org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.LinuxContainerRuntimeConstants.LOG_DIRS;
|
|
import static org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.LinuxContainerRuntimeConstants.LOG_DIRS;
|
|
import static org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.LinuxContainerRuntimeConstants.NM_PRIVATE_CONTAINER_SCRIPT_PATH;
|
|
import static org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.LinuxContainerRuntimeConstants.NM_PRIVATE_CONTAINER_SCRIPT_PATH;
|
|
|
|
+import static org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.LinuxContainerRuntimeConstants.NM_PRIVATE_KEYSTORE_PATH;
|
|
import static org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.LinuxContainerRuntimeConstants.NM_PRIVATE_TOKENS_PATH;
|
|
import static org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.LinuxContainerRuntimeConstants.NM_PRIVATE_TOKENS_PATH;
|
|
|
|
+import static org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.LinuxContainerRuntimeConstants.NM_PRIVATE_TRUSTSTORE_PATH;
|
|
import static org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.LinuxContainerRuntimeConstants.PID;
|
|
import static org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.LinuxContainerRuntimeConstants.PID;
|
|
import static org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.LinuxContainerRuntimeConstants.PID_FILE_PATH;
|
|
import static org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.LinuxContainerRuntimeConstants.PID_FILE_PATH;
|
|
import static org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.LinuxContainerRuntimeConstants.PROCFS;
|
|
import static org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.LinuxContainerRuntimeConstants.PROCFS;
|
|
@@ -118,6 +124,7 @@ import static org.mockito.Mockito.times;
|
|
import static org.mockito.Mockito.verify;
|
|
import static org.mockito.Mockito.verify;
|
|
import static org.mockito.Mockito.when;
|
|
import static org.mockito.Mockito.when;
|
|
|
|
|
|
|
|
+@RunWith(Parameterized.class)
|
|
public class TestDockerContainerRuntime {
|
|
public class TestDockerContainerRuntime {
|
|
private static final Logger LOG =
|
|
private static final Logger LOG =
|
|
LoggerFactory.getLogger(TestDockerContainerRuntime.class);
|
|
LoggerFactory.getLogger(TestDockerContainerRuntime.class);
|
|
@@ -141,6 +148,8 @@ public class TestDockerContainerRuntime {
|
|
private Path containerWorkDir;
|
|
private Path containerWorkDir;
|
|
private Path nmPrivateContainerScriptPath;
|
|
private Path nmPrivateContainerScriptPath;
|
|
private Path nmPrivateTokensPath;
|
|
private Path nmPrivateTokensPath;
|
|
|
|
+ private Path nmPrivateKeystorePath;
|
|
|
|
+ private Path nmPrivateTruststorePath;
|
|
private Path pidFilePath;
|
|
private Path pidFilePath;
|
|
private List<String> localDirs;
|
|
private List<String> localDirs;
|
|
private List<String> logDirs;
|
|
private List<String> logDirs;
|
|
@@ -159,6 +168,16 @@ public class TestDockerContainerRuntime {
|
|
@Rule
|
|
@Rule
|
|
public TemporaryFolder tempDir = new TemporaryFolder();
|
|
public TemporaryFolder tempDir = new TemporaryFolder();
|
|
|
|
|
|
|
|
+ @Parameterized.Parameters(name = "https={0}")
|
|
|
|
+ public static Collection<Object[]> data() {
|
|
|
|
+ return Arrays.asList(new Object[][] {
|
|
|
|
+ {true}, {false}
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Parameterized.Parameter
|
|
|
|
+ public boolean https;
|
|
|
|
+
|
|
@Before
|
|
@Before
|
|
public void setup() {
|
|
public void setup() {
|
|
String tmpPath = new StringBuffer(System.getProperty("test.build.data"))
|
|
String tmpPath = new StringBuffer(System.getProperty("test.build.data"))
|
|
@@ -227,6 +246,13 @@ public class TestDockerContainerRuntime {
|
|
containerWorkDir = new Path("/test_container_work_dir");
|
|
containerWorkDir = new Path("/test_container_work_dir");
|
|
nmPrivateContainerScriptPath = new Path("/test_script_path");
|
|
nmPrivateContainerScriptPath = new Path("/test_script_path");
|
|
nmPrivateTokensPath = new Path("/test_private_tokens_path");
|
|
nmPrivateTokensPath = new Path("/test_private_tokens_path");
|
|
|
|
+ if (https) {
|
|
|
|
+ nmPrivateKeystorePath = new Path("/test_private_keystore_path");
|
|
|
|
+ nmPrivateTruststorePath = new Path("/test_private_truststore_path");
|
|
|
|
+ } else {
|
|
|
|
+ nmPrivateKeystorePath = null;
|
|
|
|
+ nmPrivateTruststorePath = null;
|
|
|
|
+ }
|
|
pidFilePath = new Path("/test_pid_file_path");
|
|
pidFilePath = new Path("/test_pid_file_path");
|
|
localDirs = new ArrayList<>();
|
|
localDirs = new ArrayList<>();
|
|
logDirs = new ArrayList<>();
|
|
logDirs = new ArrayList<>();
|
|
@@ -261,6 +287,9 @@ public class TestDockerContainerRuntime {
|
|
.setExecutionAttribute(NM_PRIVATE_CONTAINER_SCRIPT_PATH,
|
|
.setExecutionAttribute(NM_PRIVATE_CONTAINER_SCRIPT_PATH,
|
|
nmPrivateContainerScriptPath)
|
|
nmPrivateContainerScriptPath)
|
|
.setExecutionAttribute(NM_PRIVATE_TOKENS_PATH, nmPrivateTokensPath)
|
|
.setExecutionAttribute(NM_PRIVATE_TOKENS_PATH, nmPrivateTokensPath)
|
|
|
|
+ .setExecutionAttribute(NM_PRIVATE_KEYSTORE_PATH, nmPrivateKeystorePath)
|
|
|
|
+ .setExecutionAttribute(NM_PRIVATE_TRUSTSTORE_PATH,
|
|
|
|
+ nmPrivateTruststorePath)
|
|
.setExecutionAttribute(PID_FILE_PATH, pidFilePath)
|
|
.setExecutionAttribute(PID_FILE_PATH, pidFilePath)
|
|
.setExecutionAttribute(LOCAL_DIRS, localDirs)
|
|
.setExecutionAttribute(LOCAL_DIRS, localDirs)
|
|
.setExecutionAttribute(LOG_DIRS, logDirs)
|
|
.setExecutionAttribute(LOG_DIRS, logDirs)
|
|
@@ -385,9 +414,9 @@ public class TestDockerContainerRuntime {
|
|
|
|
|
|
List<String> args = op.getArguments();
|
|
List<String> args = op.getArguments();
|
|
|
|
|
|
- //This invocation of container-executor should use 12 arguments in a
|
|
|
|
|
|
+ //This invocation of container-executor should use 15 or 13 arguments in a
|
|
// specific order
|
|
// specific order
|
|
- int expected = 12;
|
|
|
|
|
|
+ int expected = (https) ? 15 : 13;
|
|
int counter = 1;
|
|
int counter = 1;
|
|
Assert.assertEquals(expected, args.size());
|
|
Assert.assertEquals(expected, args.size());
|
|
Assert.assertEquals(user, args.get(counter++));
|
|
Assert.assertEquals(user, args.get(counter++));
|
|
@@ -396,10 +425,19 @@ public class TestDockerContainerRuntime {
|
|
Assert.assertEquals(appId, args.get(counter++));
|
|
Assert.assertEquals(appId, args.get(counter++));
|
|
Assert.assertEquals(containerId, args.get(counter++));
|
|
Assert.assertEquals(containerId, args.get(counter++));
|
|
Assert.assertEquals(containerWorkDir.toString(), args.get(counter++));
|
|
Assert.assertEquals(containerWorkDir.toString(), args.get(counter++));
|
|
- Assert.assertEquals(nmPrivateContainerScriptPath.toUri()
|
|
|
|
- .toString(), args.get(counter++));
|
|
|
|
|
|
+ Assert.assertEquals(nmPrivateContainerScriptPath.toUri().toString(),
|
|
|
|
+ args.get(counter++));
|
|
Assert.assertEquals(nmPrivateTokensPath.toUri().getPath(),
|
|
Assert.assertEquals(nmPrivateTokensPath.toUri().getPath(),
|
|
args.get(counter++));
|
|
args.get(counter++));
|
|
|
|
+ if (https) {
|
|
|
|
+ Assert.assertEquals("--https", args.get(counter++));
|
|
|
|
+ Assert.assertEquals(nmPrivateKeystorePath.toUri().toString(),
|
|
|
|
+ args.get(counter++));
|
|
|
|
+ Assert.assertEquals(nmPrivateTruststorePath.toUri().toString(),
|
|
|
|
+ args.get(counter++));
|
|
|
|
+ } else {
|
|
|
|
+ Assert.assertEquals("--http", args.get(counter++));
|
|
|
|
+ }
|
|
Assert.assertEquals(pidFilePath.toString(), args.get(counter++));
|
|
Assert.assertEquals(pidFilePath.toString(), args.get(counter++));
|
|
Assert.assertEquals(localDirs.get(0), args.get(counter++));
|
|
Assert.assertEquals(localDirs.get(0), args.get(counter++));
|
|
Assert.assertEquals(logDirs.get(0), args.get(counter++));
|
|
Assert.assertEquals(logDirs.get(0), args.get(counter++));
|
|
@@ -415,13 +453,7 @@ public class TestDockerContainerRuntime {
|
|
mockExecutor, mockCGroupsHandler);
|
|
mockExecutor, mockCGroupsHandler);
|
|
runtime.initialize(conf, nmContext);
|
|
runtime.initialize(conf, nmContext);
|
|
runtime.launchContainer(builder.build());
|
|
runtime.launchContainer(builder.build());
|
|
-
|
|
|
|
- PrivilegedOperation op = capturePrivilegedOperationAndVerifyArgs();
|
|
|
|
- List<String> args = op.getArguments();
|
|
|
|
- String dockerCommandFile = args.get(11);
|
|
|
|
-
|
|
|
|
- List<String> dockerCommands = Files.readAllLines(Paths.get
|
|
|
|
- (dockerCommandFile), Charset.forName("UTF-8"));
|
|
|
|
|
|
+ List<String> dockerCommands = readDockerCommands();
|
|
|
|
|
|
int expected = 13;
|
|
int expected = 13;
|
|
int counter = 0;
|
|
int counter = 0;
|
|
@@ -467,12 +499,7 @@ public class TestDockerContainerRuntime {
|
|
runtime.initialize(conf, nmContext);
|
|
runtime.initialize(conf, nmContext);
|
|
runtime.launchContainer(builder.build());
|
|
runtime.launchContainer(builder.build());
|
|
|
|
|
|
- PrivilegedOperation op = capturePrivilegedOperationAndVerifyArgs();
|
|
|
|
- List<String> args = op.getArguments();
|
|
|
|
- String dockerCommandFile = args.get(11);
|
|
|
|
-
|
|
|
|
- List<String> dockerCommands = Files.readAllLines(Paths.get(
|
|
|
|
- dockerCommandFile), Charset.forName("UTF-8"));
|
|
|
|
|
|
+ List<String> dockerCommands = readDockerCommands();
|
|
|
|
|
|
int expected = 13;
|
|
int expected = 13;
|
|
int counter = 0;
|
|
int counter = 0;
|
|
@@ -516,13 +543,7 @@ public class TestDockerContainerRuntime {
|
|
mockExecutor, mockCGroupsHandler);
|
|
mockExecutor, mockCGroupsHandler);
|
|
runtime.initialize(conf, nmContext);
|
|
runtime.initialize(conf, nmContext);
|
|
runtime.launchContainer(builder.build());
|
|
runtime.launchContainer(builder.build());
|
|
-
|
|
|
|
- PrivilegedOperation op = capturePrivilegedOperationAndVerifyArgs();
|
|
|
|
- List<String> args = op.getArguments();
|
|
|
|
- String dockerCommandFile = args.get(11);
|
|
|
|
-
|
|
|
|
- List<String> dockerCommands = Files.readAllLines(
|
|
|
|
- Paths.get(dockerCommandFile), Charset.forName("UTF-8"));
|
|
|
|
|
|
+ List<String> dockerCommands = readDockerCommands();
|
|
|
|
|
|
Assert.assertEquals(13, dockerCommands.size());
|
|
Assert.assertEquals(13, dockerCommands.size());
|
|
int counter = 0;
|
|
int counter = 0;
|
|
@@ -631,13 +652,9 @@ public class TestDockerContainerRuntime {
|
|
//this should cause no failures.
|
|
//this should cause no failures.
|
|
|
|
|
|
runtime.launchContainer(builder.build());
|
|
runtime.launchContainer(builder.build());
|
|
- PrivilegedOperation op = capturePrivilegedOperationAndVerifyArgs();
|
|
|
|
- List<String> args = op.getArguments();
|
|
|
|
- String dockerCommandFile = args.get(11);
|
|
|
|
|
|
+ List<String> dockerCommands = readDockerCommands();
|
|
|
|
|
|
//This is the expected docker invocation for this case
|
|
//This is the expected docker invocation for this case
|
|
- List<String> dockerCommands = Files
|
|
|
|
- .readAllLines(Paths.get(dockerCommandFile), Charset.forName("UTF-8"));
|
|
|
|
int expected = 14;
|
|
int expected = 14;
|
|
int counter = 0;
|
|
int counter = 0;
|
|
Assert.assertEquals(expected, dockerCommands.size());
|
|
Assert.assertEquals(expected, dockerCommands.size());
|
|
@@ -690,13 +707,9 @@ public class TestDockerContainerRuntime {
|
|
expectedHostname);
|
|
expectedHostname);
|
|
|
|
|
|
runtime.launchContainer(builder.build());
|
|
runtime.launchContainer(builder.build());
|
|
- PrivilegedOperation op = capturePrivilegedOperationAndVerifyArgs();
|
|
|
|
- List<String> args = op.getArguments();
|
|
|
|
- String dockerCommandFile = args.get(11);
|
|
|
|
|
|
+ List<String> dockerCommands = readDockerCommands();
|
|
|
|
|
|
//This is the expected docker invocation for this case
|
|
//This is the expected docker invocation for this case
|
|
- List<String> dockerCommands = Files
|
|
|
|
- .readAllLines(Paths.get(dockerCommandFile), Charset.forName("UTF-8"));
|
|
|
|
int expected = 14;
|
|
int expected = 14;
|
|
int counter = 0;
|
|
int counter = 0;
|
|
Assert.assertEquals(expected, dockerCommands.size());
|
|
Assert.assertEquals(expected, dockerCommands.size());
|
|
@@ -757,15 +770,10 @@ public class TestDockerContainerRuntime {
|
|
//this should cause no failures.
|
|
//this should cause no failures.
|
|
runtime.initialize(conf, nmContext);
|
|
runtime.initialize(conf, nmContext);
|
|
runtime.launchContainer(builder.build());
|
|
runtime.launchContainer(builder.build());
|
|
- PrivilegedOperation op = capturePrivilegedOperationAndVerifyArgs();
|
|
|
|
- List<String> args = op.getArguments();
|
|
|
|
- String dockerCommandFile = args.get(11);
|
|
|
|
|
|
+ List<String> dockerCommands = readDockerCommands();
|
|
|
|
|
|
//This is the expected docker invocation for this case. customNetwork1
|
|
//This is the expected docker invocation for this case. customNetwork1
|
|
// ("sdn1") is the expected network to be used in this case
|
|
// ("sdn1") is the expected network to be used in this case
|
|
- List<String> dockerCommands = Files
|
|
|
|
- .readAllLines(Paths.get(dockerCommandFile), Charset.forName("UTF-8"));
|
|
|
|
-
|
|
|
|
int expected = 14;
|
|
int expected = 14;
|
|
int counter = 0;
|
|
int counter = 0;
|
|
Assert.assertEquals(expected, dockerCommands.size());
|
|
Assert.assertEquals(expected, dockerCommands.size());
|
|
@@ -807,15 +815,10 @@ public class TestDockerContainerRuntime {
|
|
env.put(DockerLinuxContainerRuntime.ENV_DOCKER_CONTAINER_NETWORK,
|
|
env.put(DockerLinuxContainerRuntime.ENV_DOCKER_CONTAINER_NETWORK,
|
|
customNetwork2);
|
|
customNetwork2);
|
|
runtime.launchContainer(builder.build());
|
|
runtime.launchContainer(builder.build());
|
|
-
|
|
|
|
- op = capturePrivilegedOperationAndVerifyArgs();
|
|
|
|
- args = op.getArguments();
|
|
|
|
- dockerCommandFile = args.get(11);
|
|
|
|
|
|
+ dockerCommands = readDockerCommands();
|
|
|
|
|
|
//This is the expected docker invocation for this case. customNetwork2
|
|
//This is the expected docker invocation for this case. customNetwork2
|
|
// ("sdn2") is the expected network to be used in this case
|
|
// ("sdn2") is the expected network to be used in this case
|
|
- dockerCommands = Files
|
|
|
|
- .readAllLines(Paths.get(dockerCommandFile), Charset.forName("UTF-8"));
|
|
|
|
counter = 0;
|
|
counter = 0;
|
|
Assert.assertEquals(expected, dockerCommands.size());
|
|
Assert.assertEquals(expected, dockerCommands.size());
|
|
Assert.assertEquals("[docker-command-execution]",
|
|
Assert.assertEquals("[docker-command-execution]",
|
|
@@ -874,13 +877,7 @@ public class TestDockerContainerRuntime {
|
|
env.put(DockerLinuxContainerRuntime
|
|
env.put(DockerLinuxContainerRuntime
|
|
.ENV_DOCKER_CONTAINER_PID_NAMESPACE, "invalid-value");
|
|
.ENV_DOCKER_CONTAINER_PID_NAMESPACE, "invalid-value");
|
|
runtime.launchContainer(builder.build());
|
|
runtime.launchContainer(builder.build());
|
|
-
|
|
|
|
- PrivilegedOperation op = capturePrivilegedOperationAndVerifyArgs();
|
|
|
|
- List<String> args = op.getArguments();
|
|
|
|
- String dockerCommandFile = args.get(11);
|
|
|
|
-
|
|
|
|
- List<String> dockerCommands = Files.readAllLines(Paths.get
|
|
|
|
- (dockerCommandFile), Charset.forName("UTF-8"));
|
|
|
|
|
|
+ List<String> dockerCommands = readDockerCommands();
|
|
|
|
|
|
int expected = 13;
|
|
int expected = 13;
|
|
Assert.assertEquals(expected, dockerCommands.size());
|
|
Assert.assertEquals(expected, dockerCommands.size());
|
|
@@ -926,12 +923,7 @@ public class TestDockerContainerRuntime {
|
|
.ENV_DOCKER_CONTAINER_PID_NAMESPACE, "host");
|
|
.ENV_DOCKER_CONTAINER_PID_NAMESPACE, "host");
|
|
|
|
|
|
runtime.launchContainer(builder.build());
|
|
runtime.launchContainer(builder.build());
|
|
- PrivilegedOperation op = capturePrivilegedOperationAndVerifyArgs();
|
|
|
|
- List<String> args = op.getArguments();
|
|
|
|
- String dockerCommandFile = args.get(11);
|
|
|
|
-
|
|
|
|
- List<String> dockerCommands = Files.readAllLines(
|
|
|
|
- Paths.get(dockerCommandFile), Charset.forName("UTF-8"));
|
|
|
|
|
|
+ List<String> dockerCommands = readDockerCommands();
|
|
|
|
|
|
int expected = 14;
|
|
int expected = 14;
|
|
int counter = 0;
|
|
int counter = 0;
|
|
@@ -977,13 +969,7 @@ public class TestDockerContainerRuntime {
|
|
env.put(DockerLinuxContainerRuntime
|
|
env.put(DockerLinuxContainerRuntime
|
|
.ENV_DOCKER_CONTAINER_RUN_PRIVILEGED_CONTAINER, "invalid-value");
|
|
.ENV_DOCKER_CONTAINER_RUN_PRIVILEGED_CONTAINER, "invalid-value");
|
|
runtime.launchContainer(builder.build());
|
|
runtime.launchContainer(builder.build());
|
|
-
|
|
|
|
- PrivilegedOperation op = capturePrivilegedOperationAndVerifyArgs();
|
|
|
|
- List<String> args = op.getArguments();
|
|
|
|
- String dockerCommandFile = args.get(11);
|
|
|
|
-
|
|
|
|
- List<String> dockerCommands = Files.readAllLines(
|
|
|
|
- Paths.get(dockerCommandFile), Charset.forName("UTF-8"));
|
|
|
|
|
|
+ List<String> dockerCommands = readDockerCommands();
|
|
|
|
|
|
int expected = 13;
|
|
int expected = 13;
|
|
Assert.assertEquals(expected, dockerCommands.size());
|
|
Assert.assertEquals(expected, dockerCommands.size());
|
|
@@ -1087,12 +1073,7 @@ public class TestDockerContainerRuntime {
|
|
.ENV_DOCKER_CONTAINER_RUN_PRIVILEGED_CONTAINER, "true");
|
|
.ENV_DOCKER_CONTAINER_RUN_PRIVILEGED_CONTAINER, "true");
|
|
|
|
|
|
runtime.launchContainer(builder.build());
|
|
runtime.launchContainer(builder.build());
|
|
- PrivilegedOperation op = capturePrivilegedOperationAndVerifyArgs();
|
|
|
|
- List<String> args = op.getArguments();
|
|
|
|
- String dockerCommandFile = args.get(11);
|
|
|
|
-
|
|
|
|
- List<String> dockerCommands = Files.readAllLines(Paths.get
|
|
|
|
- (dockerCommandFile), Charset.forName("UTF-8"));
|
|
|
|
|
|
+ List<String> dockerCommands = readDockerCommands();
|
|
|
|
|
|
int expected = 13;
|
|
int expected = 13;
|
|
int counter = 0;
|
|
int counter = 0;
|
|
@@ -1203,12 +1184,7 @@ public class TestDockerContainerRuntime {
|
|
"test_dir/test_resource_file:test_mount:ro");
|
|
"test_dir/test_resource_file:test_mount:ro");
|
|
|
|
|
|
runtime.launchContainer(builder.build());
|
|
runtime.launchContainer(builder.build());
|
|
- PrivilegedOperation op = capturePrivilegedOperationAndVerifyArgs();
|
|
|
|
- List<String> args = op.getArguments();
|
|
|
|
- String dockerCommandFile = args.get(11);
|
|
|
|
-
|
|
|
|
- List<String> dockerCommands = Files.readAllLines(Paths.get
|
|
|
|
- (dockerCommandFile), Charset.forName("UTF-8"));
|
|
|
|
|
|
+ List<String> dockerCommands = readDockerCommands();
|
|
|
|
|
|
int expected = 13;
|
|
int expected = 13;
|
|
int counter = 0;
|
|
int counter = 0;
|
|
@@ -1257,12 +1233,7 @@ public class TestDockerContainerRuntime {
|
|
"test_dir/test_resource_file:test_mount2:ro");
|
|
"test_dir/test_resource_file:test_mount2:ro");
|
|
|
|
|
|
runtime.launchContainer(builder.build());
|
|
runtime.launchContainer(builder.build());
|
|
- PrivilegedOperation op = capturePrivilegedOperationAndVerifyArgs();
|
|
|
|
- List<String> args = op.getArguments();
|
|
|
|
- String dockerCommandFile = args.get(11);
|
|
|
|
-
|
|
|
|
- List<String> dockerCommands = Files.readAllLines(Paths.get
|
|
|
|
- (dockerCommandFile), Charset.forName("UTF-8"));
|
|
|
|
|
|
+ List<String> dockerCommands = readDockerCommands();
|
|
|
|
|
|
int expected = 13;
|
|
int expected = 13;
|
|
int counter = 0;
|
|
int counter = 0;
|
|
@@ -1312,12 +1283,7 @@ public class TestDockerContainerRuntime {
|
|
"/a:/a:shared,/b:/b:ro+shared,/c:/c:rw+rshared,/d:/d:private");
|
|
"/a:/a:shared,/b:/b:ro+shared,/c:/c:rw+rshared,/d:/d:private");
|
|
|
|
|
|
runtime.launchContainer(builder.build());
|
|
runtime.launchContainer(builder.build());
|
|
- PrivilegedOperation op = capturePrivilegedOperationAndVerifyArgs();
|
|
|
|
- List<String> args = op.getArguments();
|
|
|
|
- String dockerCommandFile = args.get(11);
|
|
|
|
-
|
|
|
|
- List<String> dockerCommands = Files.readAllLines(
|
|
|
|
- Paths.get(dockerCommandFile), Charset.forName("UTF-8"));
|
|
|
|
|
|
+ List<String> dockerCommands = readDockerCommands();
|
|
|
|
|
|
int expected = 13;
|
|
int expected = 13;
|
|
int counter = 0;
|
|
int counter = 0;
|
|
@@ -1421,12 +1387,7 @@ public class TestDockerContainerRuntime {
|
|
"/run");
|
|
"/run");
|
|
|
|
|
|
runtime.launchContainer(builder.build());
|
|
runtime.launchContainer(builder.build());
|
|
- PrivilegedOperation op = capturePrivilegedOperationAndVerifyArgs();
|
|
|
|
- List<String> args = op.getArguments();
|
|
|
|
- String dockerCommandFile = args.get(11);
|
|
|
|
-
|
|
|
|
- List<String> dockerCommands = Files.readAllLines(
|
|
|
|
- Paths.get(dockerCommandFile), Charset.forName("UTF-8"));
|
|
|
|
|
|
+ List<String> dockerCommands = readDockerCommands();
|
|
|
|
|
|
Assert.assertTrue(dockerCommands.contains(" tmpfs=/run"));
|
|
Assert.assertTrue(dockerCommands.contains(" tmpfs=/run"));
|
|
}
|
|
}
|
|
@@ -1444,12 +1405,7 @@ public class TestDockerContainerRuntime {
|
|
"/run,/tmp");
|
|
"/run,/tmp");
|
|
|
|
|
|
runtime.launchContainer(builder.build());
|
|
runtime.launchContainer(builder.build());
|
|
- PrivilegedOperation op = capturePrivilegedOperationAndVerifyArgs();
|
|
|
|
- List<String> args = op.getArguments();
|
|
|
|
- String dockerCommandFile = args.get(11);
|
|
|
|
-
|
|
|
|
- List<String> dockerCommands = Files.readAllLines(
|
|
|
|
- Paths.get(dockerCommandFile), Charset.forName("UTF-8"));
|
|
|
|
|
|
+ List<String> dockerCommands = readDockerCommands();
|
|
|
|
|
|
Assert.assertTrue(dockerCommands.contains(" tmpfs=/run,/tmp"));
|
|
Assert.assertTrue(dockerCommands.contains(" tmpfs=/run,/tmp"));
|
|
}
|
|
}
|
|
@@ -1468,12 +1424,7 @@ public class TestDockerContainerRuntime {
|
|
"/tmpfs");
|
|
"/tmpfs");
|
|
|
|
|
|
runtime.launchContainer(builder.build());
|
|
runtime.launchContainer(builder.build());
|
|
- PrivilegedOperation op = capturePrivilegedOperationAndVerifyArgs();
|
|
|
|
- List<String> args = op.getArguments();
|
|
|
|
- String dockerCommandFile = args.get(11);
|
|
|
|
-
|
|
|
|
- List<String> dockerCommands = Files.readAllLines(
|
|
|
|
- Paths.get(dockerCommandFile), Charset.forName("UTF-8"));
|
|
|
|
|
|
+ List<String> dockerCommands = readDockerCommands();
|
|
|
|
|
|
Assert.assertTrue(dockerCommands.contains(" tmpfs=/tmpfs,/run,/var/run"));
|
|
Assert.assertTrue(dockerCommands.contains(" tmpfs=/tmpfs,/run,/var/run"));
|
|
}
|
|
}
|
|
@@ -1567,12 +1518,7 @@ public class TestDockerContainerRuntime {
|
|
runtime.initialize(conf, nmContext);
|
|
runtime.initialize(conf, nmContext);
|
|
|
|
|
|
runtime.launchContainer(builder.build());
|
|
runtime.launchContainer(builder.build());
|
|
- PrivilegedOperation op = capturePrivilegedOperationAndVerifyArgs();
|
|
|
|
- List<String> args = op.getArguments();
|
|
|
|
- String dockerCommandFile = args.get(11);
|
|
|
|
-
|
|
|
|
- List<String> dockerCommands = Files.readAllLines(
|
|
|
|
- Paths.get(dockerCommandFile), Charset.forName("UTF-8"));
|
|
|
|
|
|
+ List<String> dockerCommands = readDockerCommands();
|
|
|
|
|
|
int expected = 13;
|
|
int expected = 13;
|
|
int counter = 0;
|
|
int counter = 0;
|
|
@@ -1634,12 +1580,7 @@ public class TestDockerContainerRuntime {
|
|
runtime.initialize(conf, nmContext);
|
|
runtime.initialize(conf, nmContext);
|
|
|
|
|
|
runtime.launchContainer(builder.build());
|
|
runtime.launchContainer(builder.build());
|
|
- PrivilegedOperation op = capturePrivilegedOperationAndVerifyArgs();
|
|
|
|
- List<String> args = op.getArguments();
|
|
|
|
- String dockerCommandFile = args.get(11);
|
|
|
|
-
|
|
|
|
- List<String> dockerCommands = Files.readAllLines(
|
|
|
|
- Paths.get(dockerCommandFile), Charset.forName("UTF-8"));
|
|
|
|
|
|
+ List<String> dockerCommands = readDockerCommands();
|
|
|
|
|
|
int expected = 13;
|
|
int expected = 13;
|
|
int counter = 0;
|
|
int counter = 0;
|
|
@@ -2224,12 +2165,7 @@ public class TestDockerContainerRuntime {
|
|
checkVolumeCreateCommand();
|
|
checkVolumeCreateCommand();
|
|
|
|
|
|
runtime.launchContainer(containerRuntimeContext);
|
|
runtime.launchContainer(containerRuntimeContext);
|
|
- PrivilegedOperation op = capturePrivilegedOperationAndVerifyArgs();
|
|
|
|
- List<String> args = op.getArguments();
|
|
|
|
- String dockerCommandFile = args.get(11);
|
|
|
|
-
|
|
|
|
- List<String> dockerCommands = Files.readAllLines(Paths.get
|
|
|
|
- (dockerCommandFile), Charset.forName("UTF-8"));
|
|
|
|
|
|
+ List<String> dockerCommands = readDockerCommands();
|
|
|
|
|
|
int expected = 14;
|
|
int expected = 14;
|
|
int counter = 0;
|
|
int counter = 0;
|
|
@@ -2348,7 +2284,7 @@ public class TestDockerContainerRuntime {
|
|
|
|
|
|
List<String> args = op.getArguments();
|
|
List<String> args = op.getArguments();
|
|
|
|
|
|
- int expectedArgs = 12;
|
|
|
|
|
|
+ int expectedArgs = (https) ? 15 : 13;
|
|
int argsCounter = 0;
|
|
int argsCounter = 0;
|
|
Assert.assertEquals(expectedArgs, args.size());
|
|
Assert.assertEquals(expectedArgs, args.size());
|
|
Assert.assertEquals(runAsUser, args.get(argsCounter++));
|
|
Assert.assertEquals(runAsUser, args.get(argsCounter++));
|
|
@@ -2362,6 +2298,15 @@ public class TestDockerContainerRuntime {
|
|
Assert.assertEquals(outDir.toUri().getPath(), args.get(argsCounter++));
|
|
Assert.assertEquals(outDir.toUri().getPath(), args.get(argsCounter++));
|
|
Assert.assertEquals(nmPrivateTokensPath.toUri().getPath(),
|
|
Assert.assertEquals(nmPrivateTokensPath.toUri().getPath(),
|
|
args.get(argsCounter++));
|
|
args.get(argsCounter++));
|
|
|
|
+ if (https) {
|
|
|
|
+ Assert.assertEquals("--https", args.get(argsCounter++));
|
|
|
|
+ Assert.assertEquals(nmPrivateKeystorePath.toUri().toString(),
|
|
|
|
+ args.get(argsCounter++));
|
|
|
|
+ Assert.assertEquals(nmPrivateTruststorePath.toUri().toString(),
|
|
|
|
+ args.get(argsCounter++));
|
|
|
|
+ } else {
|
|
|
|
+ Assert.assertEquals("--http", args.get(argsCounter++));
|
|
|
|
+ }
|
|
Assert.assertEquals(pidFilePath.toString(), args.get(argsCounter++));
|
|
Assert.assertEquals(pidFilePath.toString(), args.get(argsCounter++));
|
|
Assert.assertEquals(localDirs.get(0), args.get(argsCounter++));
|
|
Assert.assertEquals(localDirs.get(0), args.get(argsCounter++));
|
|
Assert.assertEquals(logDirs.get(0), args.get(argsCounter++));
|
|
Assert.assertEquals(logDirs.get(0), args.get(argsCounter++));
|
|
@@ -2416,13 +2361,7 @@ public class TestDockerContainerRuntime {
|
|
DockerCommandExecutor.DockerContainerStatus.STOPPED.getName());
|
|
DockerCommandExecutor.DockerContainerStatus.STOPPED.getName());
|
|
runtime.initialize(conf, nmContext);
|
|
runtime.initialize(conf, nmContext);
|
|
runtime.relaunchContainer(builder.build());
|
|
runtime.relaunchContainer(builder.build());
|
|
-
|
|
|
|
- PrivilegedOperation op = capturePrivilegedOperation(2);
|
|
|
|
- List<String> args = op.getArguments();
|
|
|
|
- String dockerCommandFile = args.get(11);
|
|
|
|
-
|
|
|
|
- List<String> dockerCommands = Files.readAllLines(
|
|
|
|
- Paths.get(dockerCommandFile), Charset.forName("UTF-8"));
|
|
|
|
|
|
+ List<String> dockerCommands = readDockerCommands(2);
|
|
|
|
|
|
int expected = 3;
|
|
int expected = 3;
|
|
int counter = 0;
|
|
int counter = 0;
|
|
@@ -2445,4 +2384,22 @@ public class TestDockerContainerRuntime {
|
|
dockerCommands.get(2));
|
|
dockerCommands.get(2));
|
|
Assert.assertEquals(" signal=" + signal, dockerCommands.get(3));
|
|
Assert.assertEquals(" signal=" + signal, dockerCommands.get(3));
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private List<String> readDockerCommands() throws IOException,
|
|
|
|
+ PrivilegedOperationException {
|
|
|
|
+ return readDockerCommands(1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private List<String> readDockerCommands(int invocations) throws IOException,
|
|
|
|
+ PrivilegedOperationException {
|
|
|
|
+ PrivilegedOperation op = (invocations == 1)
|
|
|
|
+ ? capturePrivilegedOperationAndVerifyArgs()
|
|
|
|
+ : capturePrivilegedOperation(invocations);
|
|
|
|
+ List<String> args = op.getArguments();
|
|
|
|
+ String dockerCommandFile = args.get((https) ? 14 : 12);
|
|
|
|
+
|
|
|
|
+ List<String> dockerCommands = Files.readAllLines(
|
|
|
|
+ Paths.get(dockerCommandFile), Charset.forName("UTF-8"));
|
|
|
|
+ return dockerCommands;
|
|
|
|
+ }
|
|
}
|
|
}
|