QuestionQ207

Building and testing applications

Your team has detected an error spike in an application running on Cloud Run in your production project. The application is configured to read messages from Pub/Sub topic A, process those messages, and write them to topic B. You want to run tests to identify the cause of the errors. You can use a set of mock messages for testing. What should you do?

  • A Deploy the Pub/Sub and Cloud Run emulators on your local machine. Deploy the application locally, and change the logging level in the application to DEBUG or INFO. Write mock messages to topic A, and then analyze the logs.
  • B Use the gcloud CLI to write mock messages to topic A. Change the logging level in the application to DEBUG or INFO, and then analyze the logs.
  • C Deploy the Pub/Sub emulator on your local machine. Point the production application to your local Pub/Sub topics. Write mock messages to topic A, and then analyze the logs.
  • D Use the Google Cloud console to write mock messages to topic A. Change the logging level in the application to DEBUG or INFO, and then analyze the logs.
Explanation

A local Pub/Sub emulator can provide a local stand-in for Pub/Sub, and the application must be configured to communicate with that emulator rather than the production Pub/Sub service. Running the application locally in a Cloud Run-compatible development environment allows mock messages to be processed and debug or informational logs to be analyzed without injecting test traffic into production or changing the production application to use a local endpoint.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!