PROFESSIONAL-CLOUD-DEVELOPER · Question #233
Your team is developing unit tests for Cloud Function code. The code is stored in a Cloud Source Repositories repository. You are responsible for implementing the tests. Only a specific service accoun
The correct answer is D. Configure Cloud Build to run the unit tests, using the specific service account as the build agent. If. The requirement has two parts: (1) tests must gate deployments, and (2) only the specific service account can deploy. Configuring Cloud Build to run tests using the specific service account as the build agent satisfies both. Because only that service account has deployment permis
Question
Your team is developing unit tests for Cloud Function code. The code is stored in a Cloud Source Repositories repository. You are responsible for implementing the tests. Only a specific service account has the necessary permissions to deploy the code to Cloud Functions. You want to ensure that the code cannot be deployed without first passing the tests. How should you configure the unit testing process?
Options
- AConfigure Cloud Build to deploy the Cloud Function. If the code passes the tests, a deployment
- BConfigure Cloud Build to deploy the Cloud Function, using the specific service account as the
- CConfigure Cloud Build to run the unit tests. If the code passes the tests, the developer deploys the
- DConfigure Cloud Build to run the unit tests, using the specific service account as the build agent. If
How the community answered
(48 responses)- A8% (4)
- B13% (6)
- C2% (1)
- D77% (37)
Explanation
The requirement has two parts: (1) tests must gate deployments, and (2) only the specific service account can deploy. Configuring Cloud Build to run tests using the specific service account as the build agent satisfies both. Because only that service account has deployment permissions, developers cannot deploy manually - they must go through the Cloud Build pipeline. Cloud Build then runs the tests, and only if they pass does it proceed with deployment. Option A uses the service account for deployment but not as the build agent running tests, so it may not enforce the account-level restriction correctly. Option C allows developers to deploy manually after tests pass, bypassing the enforcement. Option B does not specify running tests before deployment, missing the gating requirement.
Topics
Community Discussion
No community discussion yet for this question.