Skip to content

Commit

Permalink
wip use test container for pubsub emulator
Browse files Browse the repository at this point in the history
  • Loading branch information
testower committed May 15, 2024
1 parent 330ef67 commit 7cc222b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/test/java/no/entur/uttu/UttuIntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
classes = UttuTestApp.class
)
@ActiveProfiles({ "google-pubsub-emulator", "test" })
@ActiveProfiles({ "test" })
@EnableAspectJAutoProxy(proxyTargetClass = true)
public abstract class UttuIntegrationTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@
import org.entur.pubsub.base.EnturGooglePubSubAdmin;
import org.junit.Assert;
import org.junit.Test;
import org.junit.After;
import org.junit.Before;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.utility.DockerImageName;

public class MessagingServiceTest extends UttuIntegrationTest {

public static final String TEST_CODESPACE = "rut";

public static final String TEST_EXPORT_FILE_NAME = "netex.zip";
Expand All @@ -45,6 +48,21 @@ public class MessagingServiceTest extends UttuIntegrationTest {
@Value("${export.notify.queue.name:FlexibleLinesExportQueue}")
private String queueName;

static GenericContainer<?> pubsubEmulator = new GenericContainer<>(DockerImageName.parse("gcr.io/google.com/cloudsdktool/google-cloud-cli:latest"))
.withCommand("gcloud beta emulators pubsub start --project=test")
.withExposedPorts(8085);

@Before
public void setUp() {
pubsubEmulator.start();
}

@After
public void tearDown() {
pubsubEmulator.stop();
}


@Test
public void testNotifyExport() {
enturGooglePubSubAdmin.createSubscriptionIfMissing(queueName);
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/application-test.properties
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ spring.cloud.gcp.pubsub.project-id=test
# Path to credential for accessing the Google Cloud project, using the Spring resource syntax (prefixed with file:)
#spring.cloud.gcp.pubsub.credentials.location=file:/path/to/json/file
# if this property is present then the client library connects to the PubSub emulator instead of Google Cloud
spring.cloud.gcp.pubsub.emulatorHost=localhost:8088
spring.cloud.gcp.pubsub.emulatorHost=localhost:8085
# number of parallel pullers for a given Subscriber. Constrained by the number of threads in the executor.
spring.cloud.gcp.pubsub.subscriber.parallel-pull-count=1
# number of executor threads (shared by all subscribers)
Expand Down

0 comments on commit 7cc222b

Please sign in to comment.