Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import io.dapr.testcontainers.Component;
import io.dapr.testcontainers.DaprContainer;
import io.dapr.testcontainers.DaprLogLevel;
import io.dapr.testcontainers.wait.strategy.DaprWait;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
Expand All @@ -30,7 +31,6 @@
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
import org.testcontainers.containers.Network;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;

Expand All @@ -54,10 +54,10 @@ public class DaprSpringMessagingIT {

private static final Logger logger = LoggerFactory.getLogger(DaprSpringMessagingIT.class);

private static final String PUBSUB_NAME = "pubsub";
private static final String TOPIC = "mockTopic";
private static final Network DAPR_NETWORK = Network.newNetwork();
private static final int APP_PORT = 8080;
private static final String SUBSCRIPTION_MESSAGE_PATTERN = ".*app is subscribed to the following topics.*";

@Container
@ServiceConnection
Expand All @@ -84,8 +84,7 @@ public static void beforeAll(){

@BeforeEach
public void beforeEach() {
// Ensure the subscriptions are registered
Wait.forLogMessage(SUBSCRIPTION_MESSAGE_PATTERN, 1).waitUntilReady(DAPR_CONTAINER);
DaprWait.forSubscription(PUBSUB_NAME, TOPIC).waitUntilReady(DAPR_CONTAINER);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
import io.dapr.testcontainers.internal.DaprContainerFactory;
import io.dapr.testcontainers.internal.DaprSidecarContainer;
import io.dapr.testcontainers.internal.spring.DaprSpringBootTest;
import io.dapr.testcontainers.wait.strategy.DaprWait;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.testcontainers.containers.wait.strategy.Wait;

import java.util.Map;
import java.util.UUID;
Expand All @@ -38,8 +38,6 @@
@Tag("testcontainers")
public class DaprActorsIT {

private static final String ACTORS_MESSAGE_PATTERN = ".*Actor runtime started.*";

@DaprSidecarContainer
private static final DaprContainer DAPR_CONTAINER = DaprContainerFactory.createForSpringBootTest("actor-dapr-app")
.withComponent(new Component("kvstore", "state.in-memory", "v1",
Expand All @@ -57,9 +55,7 @@ public class DaprActorsIT {
public void setUp() {
org.testcontainers.Testcontainers.exposeHostPorts(DAPR_CONTAINER.getAppPort());
daprActorRuntime.registerActor(TestActorImpl.class);

// Wait for actor runtime to start.
Wait.forLogMessage(ACTORS_MESSAGE_PATTERN, 1).waitUntilReady(DAPR_CONTAINER);
DaprWait.forActors().waitUntilReady(DAPR_CONTAINER);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.dapr.testcontainers.Component;
import io.dapr.testcontainers.DaprContainer;
import io.dapr.testcontainers.DaprLogLevel;
import io.dapr.testcontainers.wait.strategy.DaprWait;
import org.assertj.core.api.Assertions;
import org.awaitility.Awaitility;
import org.junit.jupiter.api.BeforeAll;
Expand All @@ -35,7 +36,6 @@
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
import org.testcontainers.containers.Network;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;

Expand All @@ -62,7 +62,6 @@ public class DaprPubSubOutboxIT {
private static final Network DAPR_NETWORK = Network.newNetwork();
private static final Random RANDOM = new Random();
private static final int PORT = RANDOM.nextInt(1000) + 8000;
private static final String APP_FOUND_MESSAGE_PATTERN = ".*application discovered on port.*";

private static final String PUBSUB_APP_ID = "pubsub-dapr-app";
private static final String PUBSUB_NAME = "pubsub";
Expand Down Expand Up @@ -107,7 +106,7 @@ public static void beforeAll(){

@BeforeEach
public void beforeEach() {
Wait.forLogMessage(APP_FOUND_MESSAGE_PATTERN, 1).waitUntilReady(DAPR_CONTAINER);
DaprWait.forSubscription(PUBSUB_NAME, TOPIC_PRODUCT_CREATED).waitUntilReady(DAPR_CONTAINER);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
import io.dapr.springboot.examples.producer.workflow.CustomerWorkflow;
import io.dapr.springboot.examples.producer.workflow.RegisterCustomerActivity;
import io.dapr.testcontainers.DaprContainer;
import io.dapr.testcontainers.wait.strategy.DaprWait;
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.testcontainers.containers.wait.strategy.Wait;

import java.io.IOException;
import java.time.Duration;
Expand All @@ -43,8 +43,6 @@
webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
class ProducerAppIT {

private static final String SUBSCRIPTION_MESSAGE_PATTERN = ".*app is subscribed to the following topics.*";

@Autowired
private TestSubscriberRestController controller;

Expand All @@ -62,10 +60,9 @@ class ProducerAppIT {
@BeforeEach
void setUp() {
RestAssured.baseURI = "http://localhost:" + 8080;
org.testcontainers.Testcontainers.exposeHostPorts(8080);
// Ensure the subscriptions are registered
Wait.forLogMessage(SUBSCRIPTION_MESSAGE_PATTERN, 1).waitUntilReady(daprContainer);

org.testcontainers.Testcontainers.exposeHostPorts(8080);
DaprWait.forSubscription("pubsub", "topic").waitUntilReady(daprContainer);
}

@AfterEach
Expand Down