Skip to content

Commit 57b7450

Browse files
committed
test(tdg): await data model readiness in TDGClientTest
TDGClientTest queried spaces right after cluster.start(), which only waits for the containers to come up. The TDG data model (and therefore the User/person spaces) is applied asynchronously afterwards, so on slower runners the first queries hit a not-yet-created space and failed with "attempt to index ... 'space' (a nil value)". Wait for the model in @BeforeAll by probing both spaces via retryUntilSuccess before the tests run.
1 parent 5782535 commit 57b7450

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

tarantool-client/src/test/java/io/tarantool/client/integration/tdg/TDGClientTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@
1616
import java.util.Objects;
1717
import java.util.UUID;
1818
import java.util.concurrent.CompletionException;
19+
import java.util.concurrent.TimeUnit;
1920

2021
import org.junit.jupiter.api.AfterAll;
2122
import org.junit.jupiter.api.AfterEach;
2223
import org.junit.jupiter.api.Assertions;
2324
import org.junit.jupiter.api.BeforeAll;
2425
import org.junit.jupiter.api.Test;
26+
import org.rnorth.ducttape.unreliables.Unreliables;
2527
import org.testcontainers.containers.tdg.cluster.TDGCluster;
2628
import org.testcontainers.containers.tdg.cluster.TDGClusterImpl;
2729
import org.testcontainers.containers.tdg.configuration.TDGConfigurator;
@@ -41,6 +43,8 @@ class TDGClientTest {
4143
DockerImageName.parse(
4244
System.getenv().getOrDefault("TARANTOOL_REGISTRY", "") + "tdg2:2.11.5-0-geff8adb3");
4345

46+
private static final int MODEL_READINESS_TIMEOUT_SECONDS = 60;
47+
4448
private static final Path ROOT_CONFIG_PATH;
4549

4650
private static final TDGConfigurator configurator;
@@ -73,6 +77,18 @@ static void setUp() throws Exception {
7377
.withHost(configurator.core().getValue().iprotoMappedAddress().getHostName())
7478
.withPort(configurator.core().getValue().iprotoMappedAddress().getPort())
7579
.build();
80+
awaitModelReady();
81+
}
82+
83+
private static void awaitModelReady() {
84+
Unreliables.retryUntilSuccess(
85+
MODEL_READINESS_TIMEOUT_SECONDS,
86+
TimeUnit.SECONDS,
87+
() -> {
88+
client.space("User").get(1).join();
89+
client.space("person").get(1).join();
90+
return null;
91+
});
7692
}
7793

7894
@AfterAll

0 commit comments

Comments
 (0)