8
votes

my team and I are really keen to include Google Pub/Sub in our application as it will solve some coupling issues. The problem we are having is how to do local integration tests in conjunction the java appengine dev server.

What I've done so far:

  1. start the pub sub emulator and set the PUBSUB_EMULATOR_HOST environment variable
  2. start our application in the java dev server which creates topics and subscriptions and then sends some messages to the topics.

I'm assuming I'm doing something wrong because:

  • the topics and subscriptions as created in the cloud (surely they should have created in the pubsub emulator?)
  • messages are pushed and we receive message Ids back but no endpoint is reached or errors reported either in the cloud or the emulator.

From this I am pretty sure that the emulator is not being picked up by the dev server.

I also have some deeper questions regarding our testing strategy. Is local integration testing really feasible in this day and age with more and more services becoming bound to the cloud. Should we be focusing more on integration test suites running against cloud instances themselves? If so how would one ensure that developers have the confidence in their code before deploying to a cloud test environment, and wouldn't this increase the feedback loop significantly?

UPDATE

Using the Google Java API Client PubSub builder class I was able to inject a url (localhost:8010) from a local configuration which now allows me to successfully publish to the local emulator.

Pubsub client = new Pubsub.Builder(httpTransport, jsonFactory, initializer)
.setApplicationName(getProjectId())
.setRootUrl(rootUrl).build();

I forced the port used to simplify setup for the rest of my team rather than having to depend on a dynamically changing port.

gcloud beta emulators pubsub start --host-port localhost:8010

Now topic, subscription and messages are being created successfully on the emulator. Unfortunately I'm still not getting the messages pushed to the endpoints registered.

UPDATE 2

gcloud version 120.0.0 seems to improve things but I'm now getting the following error:

{
  "code" : 400,
  "message" : "Payload isn't valid for request.",
  "status" : "INVALID_ARGUMENT"
}
1
I've submitted a bug report to google: code.google.com/p/cloud-pubsub/issues/detail?id=39james percy

1 Answers

1
votes

Will the latest update of the gcloud utility the local pubsub server has been fixed. This issue resolved it: https://code.google.com/p/cloud-pubsub/issues/detail?id=41