Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow emulators #271

Draft
wants to merge 30 commits into
base: main
Choose a base branch
from
Draft

Allow emulators #271

wants to merge 30 commits into from

Conversation

pricem14pc
Copy link
Contributor

@pricem14pc pricem14pc commented Apr 16, 2023

**IN PROGRESS, PLEASE DO NOT DELETE !!! **

What and why?

  • introduces storage emulator (currently POC only hence do not merge)
  • refactors pubsub emulator to separate tests from run-time
  • currently being used in the ras-rm-docker POC

Comment on lines +36 to +47
// Override the wired Google Storage object (GCS) to use a local emulator
Storage storage =
StorageOptions.newBuilder()
.setCredentials(NoCredentials.getInstance())
.setProjectId("local")
.setHost("http://storage-emulator:9023")
.build()
.getService();
System.out.println(
"Storage Client initialized with storage-emulator endpoint "
+ storage.getOptions().getHost());

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need to only create this storage object configured for the emulator when running integration tests or running in a local Docker network. This POC branch will only work outside of GCP as the above explicitly uses the emulator

Comment on lines +34 to +38
private static final String PROJECT_ID = "local";
private static final String TOPIC_ID = "ras-rm-notify-local";
private static final String CASE_CREATION_TOPIC_ID = "case-notification-local";
private static final String SUBSCRIPTION_ID = "sdx-receipt-local";
private static final String CASE_CREATION_SUBSCRIPTION_ID = "case-notification-local";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this POC branch this PubSubEmulator class has been re-appropriated for use in the Docker network run-time (as opposed to the integration tests). An equivalent PubSubTestEmulator has been re-created in thetest package for use with the integration tests. This would need rationalising before being delivered as an appropriate solution.

Comment on lines +27 to +28
private static final String HOST_PORT = "pubsub-emulator:8681";
// private static final String HOST_PORT = "localhost:18681";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment below re: Docker network vs integration tests

Comment on lines -122 to -135

public void testInit() {
Topic topic = topicClient.createTopic(topicName);
System.out.println("Created topic: " + topic.getName());
Subscription subscription =
subscriptionAdminClient.createSubscription(
subscriptionName, topicName, PushConfig.getDefaultInstance(), 10);
System.out.println("Created pull subscription: " + subscription.getName());
}

public void testTeardown() {
subscriptionAdminClient.deleteSubscription(subscriptionName);
topicClient.deleteTopic(topicName);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the non-integration test emulator, the Docker network version of RASRM has the topics and subscriptions created during the docker-compose up config.

import java.util.concurrent.ExecutionException;

/** * This is a PubSub Emulator class which is used for testing pubsub function */
public class PubSubTestEmulator {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class was in originally in the run-time packages. Its been moved here to the test packages as that's what it's purpose/config is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants