Skip to content

Commit fd208c7

Browse files
authored
Merge pull request #764 from mspruc/main
Fix failing build on test race condition
2 parents 36768bf + 43c359b commit fd208c7

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

wayang-platforms/wayang-jdbc-template/src/test/java/org/apache/wayang/jdbc/operators/JdbcGlobalReduceOperatorTest.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ void testWithHsqldb() throws SQLException {
6262
final ExecutionStage sqlStage = mock(ExecutionStage.class);
6363

6464
final JdbcTableSource tableSourceA = new HsqldbTableSource("testA");
65-
65+
6666
final ExecutionTask tableSourceATask = new ExecutionTask(tableSourceA);
6767
tableSourceATask.setOutputChannel(0, new SqlQueryChannel(sqlChannelDescriptor, tableSourceA.getOutput(0)));
6868
tableSourceATask.setStage(sqlStage);
@@ -86,14 +86,23 @@ void testWithHsqldb() throws SQLException {
8686
globalReduceTask.getOutputChannel(0).addConsumer(sqlToStreamTask, 0);
8787
sqlToStreamTask.setStage(nextStage);
8888

89+
90+
final HsqldbPlatform hsqldbPlatform = new HsqldbPlatform();
91+
92+
try (Connection jdbcConnection = hsqldbPlatform.createDatabaseDescriptor(configuration).createJdbcConnection()) {
93+
final Statement statement = jdbcConnection.createStatement();
94+
statement.execute("CREATE TABLE IF NOT EXISTS testA (a INT, b VARCHAR(6));");
95+
statement.execute("INSERT INTO testA VALUES (0, 'zero');");
96+
statement.execute("CREATE TABLE IF NOT EXISTS testB (a INT, b INT);");
97+
statement.execute("INSERT INTO testB VALUES (0, 100);");
98+
}
99+
89100
final JdbcExecutor executor = new JdbcExecutor(HsqldbPlatform.getInstance(), job);
90101
executor.execute(sqlStage, new DefaultOptimizationContext(job), job.getCrossPlatformExecutor());
91102

92103
final SqlQueryChannel.Instance sqlQueryChannelInstance = (SqlQueryChannel.Instance) job.getCrossPlatformExecutor()
93104
.getChannelInstance(sqlToStreamTask.getInputChannel(0));
94105

95-
final HsqldbPlatform hsqldbPlatform = new HsqldbPlatform();
96-
97106
try (Connection jdbcConnection = hsqldbPlatform.createDatabaseDescriptor(configuration).createJdbcConnection()) {
98107
final Statement statement = jdbcConnection.createStatement();
99108
final java.sql.ResultSet resultSet = statement.executeQuery(sqlQueryChannelInstance.getSqlQuery());

0 commit comments

Comments
 (0)