GCP Professional Cloud Architect Practice Question
Your team maintains a Go microservice that writes data to Cloud Spanner and publishes events to Pub/Sub. For every commit, a Cloud Build pipeline must run integration tests that verify real SQL transactions and message publishing. The private Cloud Build pool has no external network egress, and management wants to avoid additional GCP charges while keeping test execution under one minute. Which testing approach best satisfies these constraints?
Provision a non-production GCP project in Terraform, create Spanner and Pub/Sub resources on each pipeline run, and point the tests to that project using service-account impersonation.
Within the test step, launch the Spanner and Pub/Sub emulators using the Cloud SDK (for example, gcloud beta emulators spanner start and gcloud beta emulators pubsub start), set the SPANNER_EMULATOR_HOST and PUBSUB_EMULATOR_HOST environment variables, then run the integration tests against those emulated endpoints.
Replace Spanner calls with an in-memory SQLite database and substitute Pub/Sub with a local mock library; run unit-level tests that assert method invocations.
Deploy the microservice to a staging GKE cluster inside the same VPC and execute the test suite through internal load-balancer endpoints that connect to real Spanner and Pub/Sub instances.
Starting the Cloud Spanner and Pub/Sub emulators inside the Cloud Build step lets the tests use fully featured, in-memory replicas of both managed services. Because the emulators run locally inside the build VM, they require no external network access, incur no Google Cloud charges, and start in seconds. Exporting the SPANNER_EMULATOR_HOST and PUBSUB_EMULATOR_HOST variables ensures the standard client libraries connect to the emulators using Application Default Credentials, so the same production code paths are exercised. The other options either rely on real cloud resources (incurring cost and requiring egress), replace the services with mocks (failing to meet the requirement to verify actual behavior), or deploy to an external staging environment (slow, costly, and blocked by the egress restriction).
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 are Cloud Spanner and Pub/Sub emulators used for?
Open an interactive chat with Bash
How do SPANNER_EMULATOR_HOST and PUBSUB_EMULATOR_HOST variables work?
Open an interactive chat with Bash
Why is integration testing important for the described microservice?
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 .