Skip to content

OraStuck Timeout too greedy #105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 4 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ dependencies {
api("com.google.code.findbugs:jsr305:3.0.2")

// This dependency is used internally, and not exposed to consumers on their own compile classpath.
implementation("org.slf4j:slf4j-api:1.7.26")
implementation("com.oracle.ojdbc:ojdbc8:$ojdbcVersion") {
exclude(group = "com.oracle.ojdbc")
implementation("org.slf4j:slf4j-api:1.7.36")
implementation("com.oracle.database.jdbc:ojdbc8:$ojdbcVersion") {
exclude(group = "com.oracle.database.jdbc", module = "ucp")
}
implementation("com.oracle.ojdbc:orai18n:$ojdbcVersion")
implementation("com.oracle.database.nls:orai18n:$ojdbcVersion")

// Use Jupiter test framework
testImplementation("org.junit.jupiter:junit-jupiter:$junitVersion")
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/utplsql/api/TestRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ public TestRunner addTags(Collection<String> tags) {
return this;
}

public TestRunner catchOraStuck( boolean catchOraStuck ) {
this.options.catchOraStuck = catchOraStuck;
public TestRunner oraStuckTimeout(Integer oraStuckTimeout ) {
this.options.oraStuckTimeout = oraStuckTimeout;
return this;
}

Expand Down Expand Up @@ -218,7 +218,7 @@ public void run(Connection conn) throws SQLException {

TestRunnerStatement testRunnerStatement = null;
try {
testRunnerStatement = ( options.catchOraStuck ) ? initStatementWithTimeout(conn) : initStatement(conn);
testRunnerStatement = ( options.oraStuckTimeout > 0 ) ? initStatementWithTimeout(conn, options.oraStuckTimeout) : initStatement(conn);
logger.info("Running tests");
testRunnerStatement.execute();
logger.info("Running tests finished.");
Expand All @@ -236,15 +236,15 @@ private TestRunnerStatement initStatement( Connection conn ) throws SQLException
return compatibilityProxy.getTestRunnerStatement(options, conn);
}

private TestRunnerStatement initStatementWithTimeout( Connection conn ) throws OracleCreateStatmenetStuckException, SQLException {
private TestRunnerStatement initStatementWithTimeout( Connection conn, int timeout ) throws OracleCreateStatmenetStuckException, SQLException {
ExecutorService executor = Executors.newSingleThreadExecutor();
Callable<TestRunnerStatement> callable = () -> compatibilityProxy.getTestRunnerStatement(options, conn);
Future<TestRunnerStatement> future = executor.submit(callable);

// We want to leave the statement open in case of stuck scenario
TestRunnerStatement testRunnerStatement = null;
try {
testRunnerStatement = future.get(2, TimeUnit.SECONDS);
testRunnerStatement = future.get(timeout, TimeUnit.SECONDS);
} catch (TimeoutException e) {
logger.error("Detected Oracle driver stuck during Statement initialization");
executor.shutdownNow();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/utplsql/api/TestRunnerOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class TestRunnerOptions {
public boolean randomTestOrder = false;
public Integer randomTestOrderSeed;
public final Set<String> tags = new LinkedHashSet<>();
public boolean catchOraStuck = false;
public Integer oraStuckTimeout = 0;

public String getTagsAsString() {
return String.join(",", tags);
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/org/utplsql/api/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@ public class Version implements Comparable<Version> {
public final static Version V3_1_6 = new Version("3.1.6", 3, 1, 6, 2729, true);
public final static Version V3_1_7 = new Version("3.1.7", 3, 1, 7, 3085, true);
public final static Version V3_1_8 = new Version("3.1.8", 3, 1, 8, 3188, true);
public final static Version V3_1_9 = new Version("3.1.9", 3, 1, 9, 3268, true);
public final static Version V3_1_10 = new Version("3.1.10", 3, 1, 10, 3347, true);
public final static Version V3_1_11 = new Version("3.1.11", 3, 1, 11, 3557, true);
public final static Version V3_1_12 = new Version("3.1.12", 3, 1, 12, 3876, true);
private final static Map<String, Version> knownVersions =
Stream.of(V3_0_0, V3_0_1, V3_0_2, V3_0_3, V3_0_4, V3_1_0, V3_1_1, V3_1_2, V3_1_3, V3_1_4, V3_1_5, V3_1_6, V3_1_7, V3_1_8)
Stream.of(V3_0_0, V3_0_1, V3_0_2, V3_0_3, V3_0_4, V3_1_0, V3_1_1, V3_1_2, V3_1_3, V3_1_4, V3_1_5, V3_1_6, V3_1_7, V3_1_8, V3_1_9, V3_1_10, V3_1_11, V3_1_12)
.collect(toMap(Version::toString, Function.identity()));
public final static Version LATEST = V3_1_8;
public final static Version LATEST = V3_1_12;

private final String origString;
private final Integer major;
Expand Down