YARN-7723. Avoid using docker volume --format option to run against to older docker releases. Contributed by Wangda Tan
This commit is contained in:
parent
f666e7c43d
commit
6463e10c72
@ -437,7 +437,6 @@ private void checkDockerVolumeCreated(
|
||||
throws ContainerExecutionException {
|
||||
DockerVolumeCommand dockerVolumeInspectCommand = new DockerVolumeCommand(
|
||||
DockerVolumeCommand.VOLUME_LS_SUB_COMMAND);
|
||||
dockerVolumeInspectCommand.setFormat("{{.Name}},{{.Driver}}");
|
||||
String output = runDockerVolumeCommand(dockerVolumeInspectCommand,
|
||||
container);
|
||||
|
||||
@ -450,13 +449,7 @@ private void checkDockerVolumeCreated(
|
||||
|
||||
for (String line : output.split("\n")) {
|
||||
line = line.trim();
|
||||
String[] arr = line.split(",");
|
||||
String v = arr[0].trim();
|
||||
String d = null;
|
||||
if (arr.length > 1) {
|
||||
d = arr[1].trim();
|
||||
}
|
||||
if (d != null && volumeName.equals(v) && driverName.equals(d)) {
|
||||
if (line.contains(volumeName) && line.contains(driverName)) {
|
||||
// Good we found it.
|
||||
LOG.info(
|
||||
"Docker volume-name=" + volumeName + " driver-name=" + driverName
|
||||
|
@ -1473,9 +1473,9 @@ private void checkVolumeCreateCommand()
|
||||
commandFile = new File(StringUtils.join(",", op.getArguments()));
|
||||
fileInputStream = new FileInputStream(commandFile);
|
||||
fileContent = new String(IOUtils.toByteArray(fileInputStream));
|
||||
Assert.assertEquals("[docker-command-execution]\n"
|
||||
+ " docker-command=volume\n" + " format={{.Name}},{{.Driver}}\n"
|
||||
+ " sub-command=ls\n", fileContent);
|
||||
Assert.assertEquals(
|
||||
"[docker-command-execution]\n" + " docker-command=volume\n"
|
||||
+ " sub-command=ls\n", fileContent);
|
||||
fileInputStream.close();
|
||||
}
|
||||
|
||||
@ -1577,16 +1577,33 @@ public void testDockerCommandPluginCheckVolumeAfterCreation()
|
||||
// For following tests, we expect to have volume1,local in output
|
||||
|
||||
// Failure cases
|
||||
testDockerCommandPluginWithVolumesOutput(
|
||||
"DRIVER VOLUME NAME\n", true);
|
||||
testDockerCommandPluginWithVolumesOutput("", true);
|
||||
testDockerCommandPluginWithVolumesOutput("volume1", true);
|
||||
testDockerCommandPluginWithVolumesOutput(
|
||||
"DRIVER VOLUME NAME\n" +
|
||||
"nvidia-docker nvidia_driver_375.66\n", true);
|
||||
testDockerCommandPluginWithVolumesOutput(
|
||||
"DRIVER VOLUME NAME\n" +
|
||||
" volume1\n", true);
|
||||
testDockerCommandPluginWithVolumesOutput("local", true);
|
||||
testDockerCommandPluginWithVolumesOutput("volume2,local", true);
|
||||
testDockerCommandPluginWithVolumesOutput(
|
||||
"DRIVER VOLUME NAME\n" +
|
||||
"local volume2\n", true);
|
||||
testDockerCommandPluginWithVolumesOutput("volum1,something", true);
|
||||
testDockerCommandPluginWithVolumesOutput(
|
||||
"DRIVER VOLUME NAME\n" +
|
||||
"something volume1\n", true);
|
||||
testDockerCommandPluginWithVolumesOutput("volum1,something\nvolum2,local",
|
||||
true);
|
||||
|
||||
// Success case
|
||||
testDockerCommandPluginWithVolumesOutput("volume1,local\n", false);
|
||||
testDockerCommandPluginWithVolumesOutput(
|
||||
"DRIVER VOLUME NAME\n" +
|
||||
"nvidia-docker nvidia_driver_375.66\n" +
|
||||
"local volume1\n", false);
|
||||
testDockerCommandPluginWithVolumesOutput(
|
||||
"volume_xyz,nvidia\nvolume1,local\n\n", false);
|
||||
testDockerCommandPluginWithVolumesOutput(" volume1, local \n", false);
|
||||
|
Loading…
Reference in New Issue
Block a user