Skip to content

Commit

Permalink
Debug log command during RoundTrip test
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-skovenborg authored and hmiguim committed Feb 22, 2024
1 parent ee023ed commit 945c47d
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public boolean testFile(Path populate_file) throws IOException, InterruptedExcep
private boolean roundtrip(Path populate_file) throws IOException, InterruptedException {
boolean returnValue = false;

ProcessBuilder sql = new ProcessBuilder("bash", "-c", populate_command);
ProcessBuilder sql = bashCommandProcessBuilder(populate_command);
sql.redirectOutput(processSTDOUT);
sql.redirectError(processSTDERR);
sql.redirectInput(populate_file.toFile());
Expand All @@ -154,7 +154,7 @@ private boolean roundtrip(Path populate_file) throws IOException, InterruptedExc
LOGGER.trace("SQL src dump: " + dump_source.toString());
LOGGER.trace("SQL tgt dump: " + dump_target.toString());

ProcessBuilder dump = new ProcessBuilder("bash", "-c", dump_source_command);
ProcessBuilder dump = bashCommandProcessBuilder(dump_source_command);
dump.redirectOutput(dump_source.toFile());
dump.redirectError(processSTDERR);
for (Entry<String, String> entry : environment_variables_source.entrySet()) {
Expand All @@ -168,7 +168,7 @@ private boolean roundtrip(Path populate_file) throws IOException, InterruptedExc
// and if that succeeded, convert back to the database
if (Main.internalMainUsedOnlyByTestClasses(reviewArguments(backward_conversion_arguments)) == 0) {
// both conversions succeeded. going to compare the database dumps
dump = new ProcessBuilder("bash", "-c", dump_target_command);
dump = bashCommandProcessBuilder(dump_target_command);
dump.redirectOutput(dump_target.toFile());
dump.redirectError(processSTDERR);
for (Entry<String, String> entry : environment_variables_target.entrySet()) {
Expand Down Expand Up @@ -199,7 +199,7 @@ private boolean roundtrip(Path populate_file) throws IOException, InterruptedExc

private int setup() throws IOException, InterruptedException {
// clean up before setting up
ProcessBuilder teardown = new ProcessBuilder("bash", "-c", teardown_command);
ProcessBuilder teardown = bashCommandProcessBuilder(teardown_command);
teardown.redirectOutput(processSTDOUT);
teardown.redirectError(processSTDERR);
Process p = teardown.start();
Expand All @@ -211,7 +211,7 @@ private int setup() throws IOException, InterruptedException {
LOGGER.trace("SIARD file: " + tmpFileSIARD.toString());

// create user, database and give permissions to the user
ProcessBuilder setup = new ProcessBuilder("bash", "-c", setup_command);
ProcessBuilder setup = bashCommandProcessBuilder(setup_command);
setup.redirectOutput(processSTDOUT);
setup.redirectError(processSTDERR);
p = setup.start();
Expand All @@ -225,7 +225,7 @@ private int teardown() throws IOException, InterruptedException {
Files.deleteIfExists(tmpFileSIARD);

// clean up script
ProcessBuilder teardown = new ProcessBuilder("bash", "-c", teardown_command);
ProcessBuilder teardown = bashCommandProcessBuilder(teardown_command);
teardown.redirectOutput(processSTDOUT);
teardown.redirectError(processSTDERR);

Expand All @@ -246,6 +246,11 @@ private String[] reviewArguments(String[] args) {
return copy;
}

private ProcessBuilder bashCommandProcessBuilder(String command) {
LOGGER.debug("Command: {}", command);
return new ProcessBuilder("bash", "-c", command);
}

private void waitAndPrintTmpFileOnError(Process p, long timeoutSeconds, File... files_to_print)
throws IOException, InterruptedException {

Expand Down

0 comments on commit 945c47d

Please sign in to comment.