Skip to content

Commit d568126

Browse files
committed
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.
1 parent 2473530 commit d568126

File tree

7 files changed

+43
-6
lines changed

7 files changed

+43
-6
lines changed

src/main/java/org/utplsql/cli/RunAction.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ TestRunner newTestRunner(List<Reporter> reporterList) {
166166
.randomTestOrder(config.isRandomTestOrder())
167167
.randomTestOrderSeed(config.getRandomTestOrderSeed())
168168
.addTags(Arrays.asList(config.getTags()))
169-
.addCoverageSchemes(Arrays.asList(config.getCoverageSchemes()));
169+
.addCoverageSchemes(Arrays.asList(config.getCoverageSchemes()))
170+
.catchOraStuck(config.isCatchOraStuck());
170171
}
171172

172173
private void outputMainInformation() {

src/main/java/org/utplsql/cli/RunPicocliCommand.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ FileMapperConfig toFileMapperConfig() {
183183
@Option(names = "-h", usageHelp = true, description = "display this help and exit")
184184
boolean help;
185185

186+
@Option(names = "--catch-ora-stuck", description = "Sets a timeout around Reporter creation and retries when not ready after a while")
187+
boolean catchOraStuck = false;
188+
186189
private RunAction runAction;
187190

188191
private String[] splitOrEmpty(String value) {
@@ -245,6 +248,7 @@ public RunCommandConfig getRunCommandConfig() {
245248
.randomTestOrderSeed(randomTestOrderSeed)
246249
.tags(tags.toArray(new String[0]))
247250
.coverageSchemes(coverageSchemes.toArray(new String[0]))
251+
.catchOraStuck(catchOraStuck)
248252
.create();
249253
}
250254

src/main/java/org/utplsql/cli/config/RunCommandConfig.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ public class RunCommandConfig extends ConnectionConfig {
2323
private final Integer randomTestOrderSeed;
2424
private final String[] tags;
2525
private final String[] coverageSchemes;
26+
private final boolean catchOraStuck;
2627

27-
@ConstructorProperties({"connectString", "suitePaths", "reporters", "outputAnsiColor", "failureExitCode", "skipCompatibilityCheck", "includePackages", "excludePackages", "sourceMapping", "testMapping", "logConfigLevel", "timeoutInMinutes", "dbmsOutput", "randomTestOrder", "randomTestOrderSeed", "tags", "coverageSchemes"})
28-
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) {
28+
@ConstructorProperties({"connectString", "suitePaths", "reporters", "outputAnsiColor", "failureExitCode", "skipCompatibilityCheck", "includePackages", "excludePackages", "sourceMapping", "testMapping", "logConfigLevel", "timeoutInMinutes", "dbmsOutput", "randomTestOrder", "randomTestOrderSeed", "tags", "coverageSchemes", "catchOraStuck"})
29+
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) {
2930
super(connectString);
3031
this.suitePaths = suitePaths;
3132
this.reporters = reporters;
@@ -43,6 +44,7 @@ public RunCommandConfig(String connectString, String[] suitePaths, ReporterConfi
4344
this.randomTestOrderSeed = randomTestOrderSeed;
4445
this.tags = tags;
4546
this.coverageSchemes = coverageSchemes;
47+
this.catchOraStuck = catchOraStuck;
4648
}
4749

4850
public String[] getSuitePaths() {
@@ -109,6 +111,8 @@ public String[] getCoverageSchemes() {
109111
return coverageSchemes;
110112
}
111113

114+
public boolean isCatchOraStuck() { return catchOraStuck; }
115+
112116
public static class Builder {
113117

114118
private String connectString;
@@ -128,6 +132,7 @@ public static class Builder {
128132
private Integer randomTestOrderSeed;
129133
private String[] tags = new String[0];
130134
private String[] coverageSchemes = new String[0];
135+
private boolean catchOraStuck;
131136

132137
public Builder connectString(String connectString) {
133138
this.connectString = connectString;
@@ -214,8 +219,13 @@ public Builder coverageSchemes(String[] coverageSchemes) {
214219
return this;
215220
}
216221

222+
public Builder catchOraStuck(boolean catchOraStuck) {
223+
this.catchOraStuck = catchOraStuck;
224+
return this;
225+
}
226+
217227
public RunCommandConfig create() {
218-
return new RunCommandConfig(connectString, suitePaths, reporters, outputAnsiColor, failureExitCode, skipCompatibilityCheck, includePackages, excludePackages, sourceMapping, testMapping, logConfigLevel, timeoutInMinutes, dbmsOutput, randomTestOrder, randomTestOrderSeed, tags, coverageSchemes);
228+
return new RunCommandConfig(connectString, suitePaths, reporters, outputAnsiColor, failureExitCode, skipCompatibilityCheck, includePackages, excludePackages, sourceMapping, testMapping, logConfigLevel, timeoutInMinutes, dbmsOutput, randomTestOrder, randomTestOrderSeed, tags, coverageSchemes, catchOraStuck);
219229
}
220230
}
221231
}

src/test/java/org/utplsql/cli/RunCommandArgumentsTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ public void allArgumentsAreRecognized() {
4141
"-type_mapping=\"sql=PACKAGE BODY\"",
4242
"-owner_subexpression=0",
4343
"-type_subexpression=0",
44-
"-name_subexpression=0"
44+
"-name_subexpression=0",
45+
"--catch-ora-stuck"
4546
);
4647

4748
TestRunner testRunner = runCmd.newTestRunner(new ArrayList<>());

src/test/java/org/utplsql/cli/RunCommandConfigParamsArePassedToTestRunnerTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import static org.hamcrest.MatcherAssert.assertThat;
1010
import static org.hamcrest.Matchers.contains;
11+
import static org.junit.jupiter.api.Assertions.assertTrue;
1112

1213
public class RunCommandConfigParamsArePassedToTestRunnerTest {
1314

@@ -28,4 +29,13 @@ void coverageSchemes() {
2829
TestRunner testRunner = new RunAction(config).newTestRunner(new ArrayList<>());
2930
assertThat( testRunner.getOptions().coverageSchemes, contains("schema1", "another_schema", "and-another-one") );
3031
}
32+
33+
@Test
34+
void catchOraStuck() {
35+
RunCommandConfig config = new RunCommandConfig.Builder()
36+
.catchOraStuck(true)
37+
.create();
38+
TestRunner testRunner = new RunAction(config).newTestRunner(new ArrayList<>());
39+
assertTrue( testRunner.getOptions().catchOraStuck );
40+
}
3141
}

src/test/java/org/utplsql/cli/RunCommandIT.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,14 @@ void run_withOutputButNoReporterDefined() throws Exception {
8989

9090
assertValidReturnCode(result);
9191
}
92+
93+
@Test
94+
void run_withCatchOraStuck() throws Exception {
95+
int result = TestHelper.runApp("run",
96+
TestHelper.getConnectionString(),
97+
"--catch-ora-stuck",
98+
"--failure-exit-code=2");
99+
100+
assertValidReturnCode(result);
101+
}
92102
}

src/test/java/org/utplsql/cli/RunCommandIssue20IT.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ void runLoop() {
2424
IRunCommand runCmd = TestHelper.createRunCommand(
2525
TestHelper.getConnectionString(),
2626
"-p=TEST_BETWNSTR.normal_case",
27-
"-f=ut_documentation_reporter");
27+
"-f=ut_documentation_reporter",
28+
"--catch-ora-stuck");
2829
List<ReporterOptions> reporterOptionsList = runCmd.getReporterOptionsList();
2930
ReporterOptions reporterOptions1 = reporterOptionsList.get(0);
3031
assertEquals(CoreReporters.UT_DOCUMENTATION_REPORTER.name(), reporterOptions1.getReporterName());

0 commit comments

Comments
 (0)