Soru

Zorluk: OrtaCloud Emulators and Development Testing Frameworks

A backend engineering team is configuring an automated integration testing pipeline inside a CI/CD container for a microservice that interacts with Cloud Pub/Sub and Cloud Firestore. They want to execute tests locally against Google Cloud emulators without making live GCP API calls or supplying actual cloud credentials. Which TWO configuration actions must the team take to ensure the client libraries automatically route traffic to the emulators? (Select TWO)

  1. Export the PUBSUB_EMULATOR_HOST environment variable set to the host and port where the Pub/Sub emulator is listening.Cevap
  2. Export the FIRESTORE_EMULATOR_HOST environment variable set to the host and port where the Firestore emulator is listening.Cevap
  3. C
    Mount a JSON service account key file assigned the primitive roles/owner role into the test container environment.
  4. D
    Provision a dedicated Google Kubernetes Engine (GKE) cluster in GCP to execute the emulator process and proxy API calls.

Cevap

To configure Google Cloud client libraries to communicate with local emulators, the team must set the specific host environment variables `PUBSUB_EMULATOR_HOST` and `FIRESTORE_EMULATOR_HOST`. When these environment variables are detected in the execution environment, GCP client libraries automatically disable standard IAM authentication checks and route all network traffic to the designated local host and port endpoints.
Google Cloud client libraries automatically check for specific environment variables upon initialization. When `PUBSUB_EMULATOR_HOST` and `FIRESTORE_EMULATOR_HOST` are present in the runtime environment, the SDKs route all request payloads to the specified local endpoints and bypass authentication requirements. This allows fast, cost-free, isolated integration testing within CI/CD pipelines.

Adım Adım Çözüm

1
Identify the standard mechanism used by Google Cloud client SDKs to detect local emulators.
Google Cloud client libraries look for specific service emulator host environment variables at initialization time.
Setting service-specific host variables allows zero-code-change switching between local emulation and production cloud backends.
2
Configure environment variables for Cloud Pub/Sub and Cloud Firestore.
Define `PUBSUB_EMULATOR_HOST` and `FIRESTORE_EMULATOR_HOST` inside the test container execution environment.
These environment variables direct Pub/Sub and Firestore client calls to local container ports (e.g., `localhost:8085` and `localhost:8080`).
3
Evaluate authentication requirements for emulator testing.
Confirm that credentials and service account keys are completely bypassed by the client libraries when emulator variables are set.
Emulators run locally and emulate API behavior without verifying real GCP credentials or IAM role bindings.

Anahtar Kavram

Configuring service-specific environment variables for local GCP emulators in automated test pipelines
Bu soruyu puanla