8269403: Fix jpackage tests to gracefully handle jpackage app launcher crashes

Reviewed-by: almatvee, herrick
This commit is contained in:
Alexey Semenyuk 2021-06-28 16:55:20 +00:00
parent 8d09596f27
commit efe8423d8c
2 changed files with 9 additions and 4 deletions
test/jdk/tools/jpackage/helpers/jdk/jpackage/test

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -249,7 +249,9 @@ public final class Executor extends CommandArguments<Executor> {
try {
Thread.sleep(wait * 1000);
} catch (Exception ex) {} // Ignore
} catch (InterruptedException ex) {
throw new RuntimeException(ex);
}
count++;
} while (count < max);

@ -399,8 +399,11 @@ public final class HelloApp {
public void executeAndVerifyOutput(boolean removePath,
List<String> launcherArgs, List<String> appArgs) {
getExecutor(launcherArgs.toArray(new String[0])).dumpOutput()
.setRemovePath(removePath).execute();
final int attempts = 3;
final int waitBetweenAttemptsSeconds = 5;
getExecutor(launcherArgs.toArray(new String[0])).dumpOutput().setRemovePath(
removePath).executeAndRepeatUntilExitCode(0, attempts,
waitBetweenAttemptsSeconds);
Path outputFile = TKit.workDir().resolve(OUTPUT_FILENAME);
verifyOutputFile(outputFile, appArgs, params);
}