Soru

Zorluk: ZorCloud Emulators and Development Testing Frameworks

An application development team is establishing an automated local integration testing suite for a microservice that reads and writes documents using Cloud Datastore / Firestore in Native mode. To prevent test suites from interacting with live production or staging GCP resources and to avoid cloud usage costs, the team launches the local emulator within a CI pipeline container using the command `gcloud emulators firestore start --host-port=127.0.0.1:8080`. Which configuration step must be executed in the test execution container to ensure Google Cloud client SDKs automatically route all database requests to the local emulator without modifying application source code or requiring active GCP credentials?

  1. Export the environment variable FIRESTORE_EMULATOR_HOST=127.0.0.1:8080 in the test execution container shell session before running test scripts.Cevap
  2. B
    Grant the test runner pipeline service account the primitive Owner role (roles/owner) on the GCP project to enable emulator endpoint redirection permissions.
  3. C
    Deploy a dedicated Google Kubernetes Engine (GKE) cluster in a sandbox GCP project to act as a localized protocol translation proxy for database requests.
  4. D
    Store and persist emulator database state inside an unversioned local directory instead of relying on environment variable configuration.

Cevap

Export the environment variable FIRESTORE_EMULATOR_HOST=127.0.0.1:8080 in the test execution container shell session before running test scripts.
Exporting FIRESTORE_EMULATOR_HOST=127.0.0.1:8080 sets the standardized environment variable that Google Cloud SDK client libraries automatically detect. When populated, client libraries redirect calls to the local emulator address instead of live GCP endpoints and disable production authentication requirement.

Adım Adım Çözüm

1
Identify how Google Cloud client libraries discover local emulators.
Google Cloud client SDKs check standard environment variables (such as FIRESTORE_EMULATOR_HOST, PUBSUB_EMULATOR_HOST, or BIGTABLE_EMULATOR_HOST) upon initialization.
Client libraries are engineered to automatically bypass production authentication and TLS endpoints when host environment variables are set.
2
Configure the container execution environment.
Export FIRESTORE_EMULATOR_HOST matching the host and port defined during `gcloud emulators firestore start`.
This guarantees zero application source code changes while keeping testing completely localized and isolated from GCP.

Anahtar Kavram

Cloud Emulators and SDK Environment Variables
Tahmini Süre:2m 0s
Bu soruyu puanla