GCP Professional Cloud Architect Practice Question
Your team maintains a Java microservice that publishes to and consumes from Cloud Pub/Sub using the official Java client libraries. You need to introduce unit tests that will run inside your Cloud Build CI pipeline and must meet these constraints:
Execute quickly with no outbound network connectivity
Avoid all Google Cloud charges
Require no changes to the production code path that constructs the Pub/Sub client
Which approach best satisfies these requirements?
Replace the Pub/Sub client with Mockito stubs that instantly acknowledge publish and pull operations.
Start the Cloud Pub/Sub emulator in the CI job and, in test setup code, build Pub/Sub clients whose endpoint is set to the emulator's localhost address.
Run the tests against a dedicated Cloud Pub/Sub instance in a separate project and delete topics and subscriptions after each build.
Create a single-node GKE cluster during the build and access managed Cloud Pub/Sub through Private Google Access.
Launching the Cloud Pub/Sub emulator inside the build job and, in the test setup code, constructing Publisher and Subscriber instances that set their endpoint to the emulator host (for example, localhost:8681) sends all Pub/Sub calls to the local process. This keeps production construction logic untouched, eliminates external traffic, and incurs no Cloud Pub/Sub charges.
Running against the managed service-whether from a test project, over Private Google Access, or from a transient GKE cluster-still generates network egress and billable usage. Replacing the client with Mockito stubs removes network dependence but also bypasses real Pub/Sub serialization and flow-control logic, so it does not provide realistic coverage.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is the Cloud Pub/Sub emulator?
Open an interactive chat with Bash
How do you configure the Pub/Sub client to use the emulator?
Open an interactive chat with Bash
Why should Mockito stubs not replace the Pub/Sub client in tests?
Open an interactive chat with Bash
What is the Cloud Pub/Sub emulator?
Open an interactive chat with Bash
How can you set up the Pub/Sub emulator in your CI pipeline?
Open an interactive chat with Bash
Why is using Mockito stubs incorrect for realistic Pub/Sub testing?
Open an interactive chat with Bash
GCP Professional Cloud Architect
Managing implementation
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
Pass with Confidence.
IT & Cybersecurity Package
You have hit the limits of our free tier, become a Premium Member today for unlimited access.
Military, Healthcare worker, Gov. employee or Teacher? See if you qualify for a Community Discount.
Monthly
$19.99
$19.99/mo
Billed monthly, Cancel any time.
3 Month Pass
$44.99
$14.99/mo
One time purchase of $44.99, Does not auto-renew.
MOST POPULAR
Annual Pass
$119.99
$9.99/mo
One time purchase of $119.99, Does not auto-renew.
BEST DEAL
Lifetime Pass
$189.99
One time purchase, Good for life.
What You Get
All IT & Cybersecurity Package plans include the following perks and exams .