Skip to content

Commit

Permalink
fix: fix tkc tests
Browse files Browse the repository at this point in the history
Tests were not working since connection timeout was not setup
on Postgres connection. Default timeout is infinite therefore
test that shutdown BDD hangs.
  • Loading branch information
Benjamin CAVY authored and MatthieuMAIF committed Jul 27, 2021
1 parent f6c6ed9 commit 635c19c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ object Dependencies {
val akkaVersion = "2.6.14"
val vavrVersion = "0.10.3"
val jooqVersion = "3.14.3"
val jooqAsyncVersion = "1.1.0"
val jooqAsyncVersion = "1.1.2"
val functionalJsonVersion = "1.0.3"
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.testcontainers.containers.PostgreSQLContainer;
import org.testcontainers.utility.DockerImageName;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;

Expand Down Expand Up @@ -148,8 +149,6 @@ public void initClass() {

kafka = new KafkaContainer(DEFAULT_KAFKA_IMAGE_NAME.withTag(DEFAULT_KAFKA_TAG));
kafka.start();
consistentProjection = new TestConsistentProjection(actorSystem, kafka.getBootstrapServers(), eventFormat, dataSource);
this.pgAsyncPool = pgAsyncPool(postgres);
}

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




this.pgAsyncPool = pgAsyncPool(postgres);
consistentProjection = new TestConsistentProjection(actorSystem, kafka.getBootstrapServers(), eventFormat, dataSource);
}

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

final PgConnectOptions options = new PgConnectOptions()
.setConnectTimeout(10)
.setPort(server.getMappedPort(PostgreSQLContainer.POSTGRESQL_PORT))
.setHost(server.getContainerIpAddress())
.setDatabase(server.getDatabaseName())
.setUser(server.getUsername())
.setPassword(server.getPassword());
PoolOptions poolOptions = new PoolOptions().setMaxSize(50);
PoolOptions poolOptions = new PoolOptions()
.setMaxSize(50);
this.pgPool = PgPool.pool(vertx, options, poolOptions);

return new ReactivePgAsyncPool(pgPool, jooqConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public void required_eventShouldBePublishedEventIfBrokerIsDownAtFirst() {
}

@Override
// @Test
@Test
public void required_commandSubmissionShouldFailIfDatabaseIsNotAvailable() {
String topic = randomKafkaTopic();
EventProcessor<String, TestState, TestCommand, TestEvent, TxCtx, Tuple0, Tuple0, Tuple0> eventProcessor = eventProcessor(topic);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package fr.maif.eventsourcing.datastore;

import java.util.List;

import fr.maif.eventsourcing.Event;
import fr.maif.eventsourcing.EventEnvelope;
import fr.maif.eventsourcing.EventProcessor;
Expand All @@ -10,8 +12,6 @@
import io.vavr.control.Either;
import io.vavr.control.Option;

import java.util.List;

public interface DataStoreVerificationRules<Ste extends State, Evt extends Event, Meta, Context, TxCtx> {
Either<String, ProcessingSuccess<TestState, TestEvent, Tuple0, Tuple0, Tuple0>> submitValidCommand(EventProcessor<String, TestState, TestCommand, TestEvent, TxCtx, Tuple0, Tuple0, Tuple0> eventProcessor, String id);
void submitInvalidCommand(EventProcessor<String, TestState, TestCommand, TestEvent, TxCtx, Tuple0, Tuple0, Tuple0> eventProcessor, String id);
Expand Down

0 comments on commit 635c19c

Please sign in to comment.