Google pub / sub test strategy for local gae Java dev server
My team and I really want to include Google pub / sub in our application because it will solve some coupling problems
What have I done so far:
>Start the pub sub emulator and set up PubSub_ EMULATOR_ Host environment variable > launch our application in the Java dev server, which creates topics and subscriptions, and then sends some messages to the topics
I suppose I did wrong because:
>Topics and subscriptions created in the cloud (of course, they should be created in the PubSub simulator?) > When the message is pushed, we receive the message ID but do not reach the endpoint or report an error in the cloud or simulator
From this point of view, I'm pretty sure the development server didn't receive the simulator
I also have some deeper questions about the testing strategy Whether local integration testing is really feasible in today's era, more and more services have become a part of cloud computing Should we pay more attention to the integration test suite running against the cloud instance itself? If so, how to ensure that developers have confidence in their code before deploying to the cloud test environment, won't it significantly increase the feedback loop?
UPDATE
Using the Google Java API client PubSub builder class, I can inject a URL (localhost: 8010) from the local configuration and now allow me to successfully publish to the local simulator
Pubsub client = new Pubsub.Builder(httpTransport,jsonFactory,initializer) .setApplicationName(getProjectId()) .setRootUrl(rootUrl).build();
I force ports to simplify the rest of my team's setup, rather than relying on dynamically changing ports
gcloud beta emulators pubsub start --host-port localhost:8010
Now, topics, subscriptions and messages have been successfully created on the simulator Unfortunately, I still haven't pushed the message to the registered endpoint
Update 2
Gcloud version 120.0.0 0 seems to have improved something, but I now receive the following errors:
{ "code" : 400,"message" : "Payload isn't valid for request.","status" : "INVALID_ARGUMENT" }
Solution
The latest update of gcloud utility of local PubSub server will be repaired This problem solves it: https://code.google.com/p/cloud-pubsub/issues/detail?id=41