Google Professional Cloud Developer Question 277
Select 3Google Cloud PlatformYou are working on a cloud-based e-commerce application that relies on Firestore for its database and Cloud Pub/Sub for asynchronous messaging. As part of your integration testing strategy, you want to ensure that your application works correctly with these services without incurring costs or affecting production data. Which steps should you take to achieve this?
- A
Use the Firestore emulator to simulate database operations locally during tests.
- B
Use the Cloud Pub/Sub emulator to test message publishing and subscription workflows.
- C
Deploy a test Firestore database and use it for integration testing.
- D
Run the application against the production Firestore database in a non-destructive manner.
- E
Use environment variables to configure the application to connect to emulators during testing.
Show answer and explanation
Correct answers: A, B, E
Explanation
Integration testing in Google Cloud should use emulators like the Firestore and Cloud Pub/Sub emulators to simulate cloud services locally. This approach avoids impacting production systems and keeps testing costs low. Configuring the application to connect to these emulators using environment variables further ensures isolation between test and production environments.
- A. Correct.
Correct: The Firestore emulator allows you to simulate Firestore operations locally, making it ideal for integration testing without affecting production data or incurring costs.
- B. Correct.
Correct: The Cloud Pub/Sub emulator provides a local testing environment for Pub/Sub messaging, enabling you to test publish and subscribe workflows without using the actual cloud service.
- C. Incorrect.
Incorrect: Deploying a test Firestore database incurs costs and has the potential to affect production-like data, which is not ideal for integration testing purposes.
- D. Incorrect.
Incorrect: Running tests against the production Firestore database, even in a non-destructive manner, goes against best practices since it can lead to unintended consequences and increased costs.
- E. Correct.
Correct: Using environment variables to configure the application to connect to emulators ensures that the testing environment is isolated from production and uses the emulated services.