Add a Test workaround for certain Linux distro (#552)

On Arch Linux, DumpGoldenSchemaCommandTest failed due to the follow
error:

java.lang.RuntimeException: Container.ExecResult(exitCode=1, stdout=, stderr=pg_dump: [archiver] could not open output file "/tmp/pg_dump.out": Is a directory)

However I cannot figure out why this permission error happens, as the
docker command is executed as root. Saving the pg_dump output to a
temporary file and copy it over the mapped file works, so I don't
know...
This commit is contained in:
Lai Jiang 2020-04-10 12:44:36 -04:00 committed by GitHub
parent 69b8f00b4b
commit 4dfe7f34dc

View file

@ -36,6 +36,9 @@ public class DumpGoldenSchemaCommand extends PostgresqlCommand {
// The mount point in the container.
private static final String CONTAINER_MOUNT_POINT = "/tmp/pg_dump.out";
// Temporary workaround to fix permission issues on certain Linux distro (e. g. Arch Linux).
private static final String CONTAINER_MOUNT_POINT_TMP = "/tmp/pg_dump.tmp";
@Parameter(
names = {"--output", "-o"},
description = "Output file",
@ -61,6 +64,11 @@ public class DumpGoldenSchemaCommand extends PostgresqlCommand {
if (result.getExitCode() != 0) {
throw new RuntimeException(result.toString());
}
result = postgresContainer.execInContainer(
"cp", CONTAINER_MOUNT_POINT_TMP, CONTAINER_MOUNT_POINT);
if (result.getExitCode() != 0) {
throw new RuntimeException(result.toString());
}
}
@Override
@ -79,7 +87,7 @@ public class DumpGoldenSchemaCommand extends PostgresqlCommand {
"-U",
username,
"-f",
CONTAINER_MOUNT_POINT,
CONTAINER_MOUNT_POINT_TMP,
"--schema-only",
"--no-owner",
"--no-privileges",