Skip to content

Commit 635c19c

Browse files
Benjamin CAVYMatthieuMAIF
authored andcommitted
fix: fix tkc tests
Tests were not working since connection timeout was not setup on Postgres connection. Default timeout is infinite therefore test that shutdown BDD hangs.
1 parent f6c6ed9 commit 635c19c

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

project/Dependencies.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ object Dependencies {
44
val akkaVersion = "2.6.14"
55
val vavrVersion = "0.10.3"
66
val jooqVersion = "3.14.3"
7-
val jooqAsyncVersion = "1.1.0"
7+
val jooqAsyncVersion = "1.1.2"
88
val functionalJsonVersion = "1.0.3"
99
}

thoth-jooq-async/src/test/java/fr/maif/eventsourcing/JooqAsyncKafkaTCKImplementation.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import org.testcontainers.containers.PostgreSQLContainer;
4242
import org.testcontainers.utility.DockerImageName;
4343
import org.testng.annotations.AfterClass;
44+
import org.testng.annotations.AfterMethod;
4445
import org.testng.annotations.BeforeClass;
4546
import org.testng.annotations.BeforeMethod;
4647

@@ -148,8 +149,6 @@ public void initClass() {
148149

149150
kafka = new KafkaContainer(DEFAULT_KAFKA_IMAGE_NAME.withTag(DEFAULT_KAFKA_TAG));
150151
kafka.start();
151-
consistentProjection = new TestConsistentProjection(actorSystem, kafka.getBootstrapServers(), eventFormat, dataSource);
152-
this.pgAsyncPool = pgAsyncPool(postgres);
153152
}
154153

155154
@BeforeMethod(alwaysRun = true)
@@ -165,9 +164,8 @@ public void init() throws SQLException {
165164
dataSource.getConnection().prepareStatement(SCHEMA).execute();
166165
dataSource.getConnection().prepareStatement(INIT_TABLE_QUERY).execute();
167166

168-
169-
170-
167+
this.pgAsyncPool = pgAsyncPool(postgres);
168+
consistentProjection = new TestConsistentProjection(actorSystem, kafka.getBootstrapServers(), eventFormat, dataSource);
171169
}
172170

173171
private PgAsyncPool pgAsyncPool(PostgreSQLContainer server) {
@@ -176,12 +174,14 @@ private PgAsyncPool pgAsyncPool(PostgreSQLContainer server) {
176174
jooqConfig.setSQLDialect(SQLDialect.POSTGRES);
177175

178176
final PgConnectOptions options = new PgConnectOptions()
177+
.setConnectTimeout(10)
179178
.setPort(server.getMappedPort(PostgreSQLContainer.POSTGRESQL_PORT))
180179
.setHost(server.getContainerIpAddress())
181180
.setDatabase(server.getDatabaseName())
182181
.setUser(server.getUsername())
183182
.setPassword(server.getPassword());
184-
PoolOptions poolOptions = new PoolOptions().setMaxSize(50);
183+
PoolOptions poolOptions = new PoolOptions()
184+
.setMaxSize(50);
185185
this.pgPool = PgPool.pool(vertx, options, poolOptions);
186186

187187
return new ReactivePgAsyncPool(pgPool, jooqConfig);

thoth-tck/src/main/java/fr/maif/eventsourcing/datastore/DataStoreVerification.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public void required_eventShouldBePublishedEventIfBrokerIsDownAtFirst() {
159159
}
160160

161161
@Override
162-
// @Test
162+
@Test
163163
public void required_commandSubmissionShouldFailIfDatabaseIsNotAvailable() {
164164
String topic = randomKafkaTopic();
165165
EventProcessor<String, TestState, TestCommand, TestEvent, TxCtx, Tuple0, Tuple0, Tuple0> eventProcessor = eventProcessor(topic);

thoth-tck/src/main/java/fr/maif/eventsourcing/datastore/DataStoreVerificationRules.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package fr.maif.eventsourcing.datastore;
22

3+
import java.util.List;
4+
35
import fr.maif.eventsourcing.Event;
46
import fr.maif.eventsourcing.EventEnvelope;
57
import fr.maif.eventsourcing.EventProcessor;
@@ -10,8 +12,6 @@
1012
import io.vavr.control.Either;
1113
import io.vavr.control.Option;
1214

13-
import java.util.List;
14-
1515
public interface DataStoreVerificationRules<Ste extends State, Evt extends Event, Meta, Context, TxCtx> {
1616
Either<String, ProcessingSuccess<TestState, TestEvent, Tuple0, Tuple0, Tuple0>> submitValidCommand(EventProcessor<String, TestState, TestCommand, TestEvent, TxCtx, Tuple0, Tuple0, Tuple0> eventProcessor, String id);
1717
void submitInvalidCommand(EventProcessor<String, TestState, TestCommand, TestEvent, TxCtx, Tuple0, Tuple0, Tuple0> eventProcessor, String id);

0 commit comments

Comments
 (0)