-
Notifications
You must be signed in to change notification settings - Fork 3
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
base: main
Are you sure you want to change the base?
Allow emulators #271
Conversation
…ce into allow-emulators
…ce into allow-emulators
// 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()); | ||
|
There was a problem hiding this comment.
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
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"; |
There was a problem hiding this comment.
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.
private static final String HOST_PORT = "pubsub-emulator:8681"; | ||
// private static final String HOST_PORT = "localhost:18681"; |
There was a problem hiding this comment.
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
|
||
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); | ||
} |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
**IN PROGRESS, PLEASE DO NOT DELETE !!! **
What and why?
ras-rm-docker
POC