GCP Professional Cloud Architect Practice Question
Your team is building a CI pipeline that runs integration tests for a microservice which publishes messages to Pub/Sub topics and stores metadata in Cloud Firestore (native mode). Developers must be able to execute the same test suite on their laptops without an internet connection, and the company wants to avoid any Google Cloud billing during these tests. No application code changes are allowed between local and CI executions. What should you do?
Create a separate Google Cloud project that hosts dedicated Pub/Sub topics and Firestore databases for testing, authenticate with a least-privilege service account in the CI job, and delete the project every night to limit costs.
Replace Pub/Sub and Firestore client calls in the microservice with Mockito or similar mocks when the TEST_MODE flag is enabled, ensuring tests never reach Google Cloud endpoints.
Start the Pub/Sub and Cloud Firestore emulators in the CI job and on developer machines, expose them on fixed ports, and set the PUBSUB_EMULATOR_HOST and FIRESTORE_EMULATOR_HOST environment variables before running the tests.
Run gcloud in offline mode so that API calls are intercepted locally; the microservice will continue to use production client libraries without needing environment variables.
Running the official service emulators provides fully-featured, local implementations of Pub/Sub and Cloud Firestore that incur no Google Cloud charges. By starting the emulators as Docker containers (or with the gcloud CLI) inside both the developer workstation and CI job, and setting the environment variables PUBSUB_EMULATOR_HOST and FIRESTORE_EMULATOR_HOST, the application's client libraries automatically direct traffic to the local endpoints. Because the same environment variables can be injected in both contexts, the test suite runs unmodified everywhere. Provisioning real resources in a separate project still incurs cost, and deleting the project adds operational overhead. Offline stubs or mocks break the requirement of running the same unmodified code path; they also fail to test real client library behavior. "Offline mode" in gcloud does not emulate these managed services.
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 the Pub/Sub and Firestore emulators?
Open an interactive chat with Bash
How do environment variables PUBSUB_EMULATOR_HOST and FIRESTORE_EMULATOR_HOST work?
Open an interactive chat with Bash
Why should emulators be preferred over mocks or offline stubs?
Open an interactive chat with Bash
What are Pub/Sub and Cloud Firestore emulators?
Open an interactive chat with Bash
How do PUBSUB_EMULATOR_HOST and FIRESTORE_EMULATOR_HOST environment variables work?
Open an interactive chat with Bash
Why are service emulators preferred over mocks for local 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 .