A cloud architecture team is refactoring an event-driven data pipeline that processes real-time transaction events via Cloud Pub/Sub and persists aggregated records into Cloud Bigtable. To cut cloud costs and accelerate CI/CD build execution, the team must run unit and integration tests completely offline without interacting with real Google Cloud API endpoints. Which TWO configuration steps must be implemented to ensure the client SDKs route all network requests to the locally running emulators? (Select TWO.)
- Export the environment variable PUBSUB_EMULATOR_HOST set to the host and port of the running Pub/Sub emulator before initializing the application client.Answer
- BGrant the roles/owner primitive IAM role to the local emulator container's service account to bypass Cloud IAM API authentication during test execution.
- Export the environment variable BIGTABLE_EMULATOR_HOST pointing to the socket of the local Bigtable emulator prior to invoking the test runner.Answer
- DProvision an isolated Google Kubernetes Engine (GKE) cluster in a development GCP project to run emulator containers for each CI build stage.
Answer
To route client SDK requests to local emulators offline, developers must export the PUBSUB_EMULATOR_HOST environment variable for Cloud Pub/Sub and the BIGTABLE_EMULATOR_HOST environment variable for Cloud Bigtable.
Google Cloud client SDKs for Cloud Pub/Sub and Cloud Bigtable automatically detect the PUBSUB_EMULATOR_HOST and BIGTABLE_EMULATOR_HOST environment variables. When set, client libraries automatically redirect API calls to local emulator sockets and disable network calls to production Google Cloud endpoints.
Step-by-Step Solution
Key Concept
Google Cloud Client Library emulator auto-discovery via host environment variables