Make Docker test robust when removing a temp dir (#61639)

Closes #61614. Closes #61553.

In a particular Docker test, ensure is shut down before removing the
data directory. Also add the force flag to `rm`.
This commit is contained in:
Rory Hunter 2020-09-01 12:03:06 +01:00 committed by Rory Hunter
parent d94d6b5b70
commit 50119bb08f
2 changed files with 5 additions and 1 deletions

View File

@ -223,6 +223,10 @@ public class DockerTests extends PackagingTestCase {
assertThat(nodes.at("/_nodes/successful").intValue(), equalTo(1));
assertThat(nodes.at("/_nodes/failed").intValue(), equalTo(0));
// Ensure container is stopped before we remove tempEsDataDir, so nothing
// is using the directory.
removeContainer();
rmDirWithPrivilegeEscalation(tempEsDataDir);
});
}

View File

@ -419,7 +419,7 @@ public class Docker {
args.add("cd " + containerBasePath.toAbsolutePath());
args.add("&&");
args.add("rm -r " + localPath.getFileName());
args.add("rm -rf " + localPath.getFileName());
final String command = String.join(" ", args);
executePrivilegeEscalatedShellCmd(command, localPath, containerPath);
}