Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add new --catch-ora-stuck parameter
Reson for this that I have the assumption that catch is too greedy, leading to more abort- and retries than necessary.
  • Loading branch information
pesse committed Jun 10, 2021
commit d56812632858833da896f4cdc278d3a6aea73805
3 changes: 2 additions & 1 deletion src/main/java/org/utplsql/cli/RunAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ TestRunner newTestRunner(List<Reporter> reporterList) {
.randomTestOrder(config.isRandomTestOrder())
.randomTestOrderSeed(config.getRandomTestOrderSeed())
.addTags(Arrays.asList(config.getTags()))
.addCoverageSchemes(Arrays.asList(config.getCoverageSchemes()));
.addCoverageSchemes(Arrays.asList(config.getCoverageSchemes()))
.catchOraStuck(config.isCatchOraStuck());
}

private void outputMainInformation() {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/utplsql/cli/RunPicocliCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ FileMapperConfig toFileMapperConfig() {
@Option(names = "-h", usageHelp = true, description = "display this help and exit")
boolean help;

@Option(names = "--catch-ora-stuck", description = "Sets a timeout around Reporter creation and retries when not ready after a while")
boolean catchOraStuck = false;

private RunAction runAction;

private String[] splitOrEmpty(String value) {
Expand Down Expand Up @@ -245,6 +248,7 @@ public RunCommandConfig getRunCommandConfig() {
.randomTestOrderSeed(randomTestOrderSeed)
.tags(tags.toArray(new String[0]))
.coverageSchemes(coverageSchemes.toArray(new String[0]))
.catchOraStuck(catchOraStuck)
.create();
}

Expand Down
16 changes: 13 additions & 3 deletions src/main/java/org/utplsql/cli/config/RunCommandConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ public class RunCommandConfig extends ConnectionConfig {
private final Integer randomTestOrderSeed;
private final String[] tags;
private final String[] coverageSchemes;
private final boolean catchOraStuck;

@ConstructorProperties({"connectString", "suitePaths", "reporters", "outputAnsiColor", "failureExitCode", "skipCompatibilityCheck", "includePackages", "excludePackages", "sourceMapping", "testMapping", "logConfigLevel", "timeoutInMinutes", "dbmsOutput", "randomTestOrder", "randomTestOrderSeed", "tags", "coverageSchemes"})
public RunCommandConfig(String connectString, String[] suitePaths, ReporterConfig[] reporters, boolean outputAnsiColor, Integer failureExitCode, boolean skipCompatibilityCheck, String[] includePackages, String[] excludePackages, FileMapperConfig sourceMapping, FileMapperConfig testMapping, ConfigLevel logConfigLevel, Integer timeoutInMinutes, boolean dbmsOutput, boolean randomTestOrder, Integer randomTestOrderSeed, String[] tags, String[] coverageSchemes) {
@ConstructorProperties({"connectString", "suitePaths", "reporters", "outputAnsiColor", "failureExitCode", "skipCompatibilityCheck", "includePackages", "excludePackages", "sourceMapping", "testMapping", "logConfigLevel", "timeoutInMinutes", "dbmsOutput", "randomTestOrder", "randomTestOrderSeed", "tags", "coverageSchemes", "catchOraStuck"})
public RunCommandConfig(String connectString, String[] suitePaths, ReporterConfig[] reporters, boolean outputAnsiColor, Integer failureExitCode, boolean skipCompatibilityCheck, String[] includePackages, String[] excludePackages, FileMapperConfig sourceMapping, FileMapperConfig testMapping, ConfigLevel logConfigLevel, Integer timeoutInMinutes, boolean dbmsOutput, boolean randomTestOrder, Integer randomTestOrderSeed, String[] tags, String[] coverageSchemes, boolean catchOraStuck) {
super(connectString);
this.suitePaths = suitePaths;
this.reporters = reporters;
Expand All @@ -43,6 +44,7 @@ public RunCommandConfig(String connectString, String[] suitePaths, ReporterConfi
this.randomTestOrderSeed = randomTestOrderSeed;
this.tags = tags;
this.coverageSchemes = coverageSchemes;
this.catchOraStuck = catchOraStuck;
}

public String[] getSuitePaths() {
Expand Down Expand Up @@ -109,6 +111,8 @@ public String[] getCoverageSchemes() {
return coverageSchemes;
}

public boolean isCatchOraStuck() { return catchOraStuck; }

public static class Builder {

private String connectString;
Expand All @@ -128,6 +132,7 @@ public static class Builder {
private Integer randomTestOrderSeed;
private String[] tags = new String[0];
private String[] coverageSchemes = new String[0];
private boolean catchOraStuck;

public Builder connectString(String connectString) {
this.connectString = connectString;
Expand Down Expand Up @@ -214,8 +219,13 @@ public Builder coverageSchemes(String[] coverageSchemes) {
return this;
}

public Builder catchOraStuck(boolean catchOraStuck) {
this.catchOraStuck = catchOraStuck;
return this;
}

public RunCommandConfig create() {
return new RunCommandConfig(connectString, suitePaths, reporters, outputAnsiColor, failureExitCode, skipCompatibilityCheck, includePackages, excludePackages, sourceMapping, testMapping, logConfigLevel, timeoutInMinutes, dbmsOutput, randomTestOrder, randomTestOrderSeed, tags, coverageSchemes);
return new RunCommandConfig(connectString, suitePaths, reporters, outputAnsiColor, failureExitCode, skipCompatibilityCheck, includePackages, excludePackages, sourceMapping, testMapping, logConfigLevel, timeoutInMinutes, dbmsOutput, randomTestOrder, randomTestOrderSeed, tags, coverageSchemes, catchOraStuck);
}
}
}
3 changes: 2 additions & 1 deletion src/test/java/org/utplsql/cli/RunCommandArgumentsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public void allArgumentsAreRecognized() {
"-type_mapping=\"sql=PACKAGE BODY\"",
"-owner_subexpression=0",
"-type_subexpression=0",
"-name_subexpression=0"
"-name_subexpression=0",
"--catch-ora-stuck"
);

TestRunner testRunner = runCmd.newTestRunner(new ArrayList<>());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class RunCommandConfigParamsArePassedToTestRunnerTest {

Expand All @@ -28,4 +29,13 @@ void coverageSchemes() {
TestRunner testRunner = new RunAction(config).newTestRunner(new ArrayList<>());
assertThat( testRunner.getOptions().coverageSchemes, contains("schema1", "another_schema", "and-another-one") );
}

@Test
void catchOraStuck() {
RunCommandConfig config = new RunCommandConfig.Builder()
.catchOraStuck(true)
.create();
TestRunner testRunner = new RunAction(config).newTestRunner(new ArrayList<>());
assertTrue( testRunner.getOptions().catchOraStuck );
}
}
10 changes: 10 additions & 0 deletions src/test/java/org/utplsql/cli/RunCommandIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,14 @@ void run_withOutputButNoReporterDefined() throws Exception {

assertValidReturnCode(result);
}

@Test
void run_withCatchOraStuck() throws Exception {
int result = TestHelper.runApp("run",
TestHelper.getConnectionString(),
"--catch-ora-stuck",
"--failure-exit-code=2");

assertValidReturnCode(result);
}
}
3 changes: 2 additions & 1 deletion src/test/java/org/utplsql/cli/RunCommandIssue20IT.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ void runLoop() {
IRunCommand runCmd = TestHelper.createRunCommand(
TestHelper.getConnectionString(),
"-p=TEST_BETWNSTR.normal_case",
"-f=ut_documentation_reporter");
"-f=ut_documentation_reporter",
"--catch-ora-stuck");
List<ReporterOptions> reporterOptionsList = runCmd.getReporterOptionsList();
ReporterOptions reporterOptions1 = reporterOptionsList.get(0);
assertEquals(CoreReporters.UT_DOCUMENTATION_REPORTER.name(), reporterOptions1.getReporterName());
Expand Down