Exam DOP-C02 All QuestionsBrowse all questions from this exam
Question 54

A development team uses AWS CodeCommit for version control for applications. The development team uses AWS CodePipeline, AWS CodeBuild. and AWS CodeDeploy for CI/CD infrastructure. In CodeCommit, the development team recently merged pull requests that did not pass long-running tests in the code base. The development team needed to perform rollbacks to branches in the codebase, resulting in lost time and wasted effort.

A DevOps engineer must automate testing of pull requests in CodeCommit to ensure that reviewers more easily see the results of automated tests as part of the pull request review.

What should the DevOps engineer do to meet this requirement?

    Correct Answer: C

    To ensure that automated tests are run whenever a pull request is created or the source branch of a pull request is updated, the correct approach is to use an Amazon EventBridge rule that reacts to pullRequestCreated and pullRequestSourceBranchUpdated events. This ensures that tests are triggered not only when the pull request is initially created but also whenever new commits are pushed to the source branch, capturing any subsequent changes. Programming the AWS Lambda function to invoke a CodePipeline pipeline with a CodeBuild action that runs the tests and posts the CodeBuild badge as a comment on the pull request helps developers see the test results directly in the context of their code review.

Discussion
MarDog

C. Look at #3 in the below. https://container-devsecops.awssecworkshops.com/04-testing/

Gomer

Link is dead

madperroOption: B

B, we need to run tests only when pull request is created and we need to publish test results, not only badge.

RVivekOption: C

https://aws.amazon.com/blogs/devops/automated-code-review-on-pull-requests-using-aws-codecommit-and-aws-codebuild/

tartarus23Option: C

This approach allows testing whenever a pull request is created or the source branch of a pull request is updated. When the tests are complete, the AWS Lambda function posts the test status badge as a comment on the pull request, providing visual feedback to reviewers directly in the context of the pull request review. It's important to note that CodeBuild creates a build badge that provides status about the last build, which might not directly reflect the test results of the specific pull request. Posting the test results would provide more accurate and relevant information but doing so might require additional scripting or tooling not described in the available options.

bcxOption: C

C is the correct IMHO. A pull request is just a branch that the requestor is asking to be merged in master/main. When you create a pull request you set the branch, that is the start, you have to use the current contents of the branch to execute the tests. When time passes developers add commits to that branch or force-push it, changing the contents of the PR's branch. That is the moment in which you have to trigger the tests. The PR comments and discussions may change, but that does not change the code so no need to perform new tests. You only test when the PR is created and every time the branch is pushed (updated).

zijo

C is the answer to ensure code reviewers more easily see the results of automated tests as part of the pull request review pullRequestStatusChanged event is triggered whenever the status of a pull request changes. This could include transitions like: Open to Closed (pull request is merged or marked as closed) Closed to Open (pull request is reopened) pullRequestCreated event is triggered whenever a new pull request is created in a CodeCommit repository. pullRequestSourceBranchUpdated event is triggered whenever there are updates (new commits) pushed to the source branch of an open pull request

thanhnv142

B is correct: we need to react when there is merge request (pullRequestCreated event) A: we need to react when there is merge request, not when the status of merge request is changed (pullRequestStatusChanged event) C: we only need to react when there is merge request, not when a sourcebranch is updated (pullRequestSourceBranchUpdated events) D: we need to react when there is merge request, not when the status of merge request is changed (pullRequestStatusChanged event)

gg_robin

If the source is updated after the PR is created, you don't run any tests against those changes.

DucSiu

Why not B?

zolthar_z

Answer is C: the pullRequestStatusChanged only has two values (OPEN|CLOSED) so If there is any update in the code the tests will not run. https://docs.aws.amazon.com/codecommit/latest/APIReference/API_PullRequestStatusChangedEventMetadata.html

DZ_BenOption: C

I'll go for C. Tbh, I don't think we will need a lambda here as the event rule can definitely trigger the code pipeline & code build.

ggrodskiy

Correct C.

vhermanOption: C

С run tests on pull requests created and when source branch receives new commits to re-run tests

luntOption: C

Not sure why so much discussion. Triggers Rule: A CloudWatch Event Rule is triggered based on the following events: pullRequestSourceBranchUpdated or pullRequestCreated. C is only viable option. I mean it even tells you the answer in the question "development team needed to perform rollbacks to branches in the codebase". Ans is C.

youonebe

Why not B?

qan1257Option: C

D is incorrect. pullRequestStatusChanged event In this example event, a user who assumed a role named Admin with a session name of Mary_Major closed a pull request with the ID of 1. The pull request was not merged. https://docs.aws.amazon.com/codecommit/latest/userguide/monitoring-events.html#pullRequestMergeStatusUpdated

GomerOption: C

"Automated Code Review on Pull Requests using AWS CodeCommit and AWS CodeBuild" "The solution comprises of the following components:" "Amazon EventBridge: AWS service to receive pullRequestCreated and pullRequestSourceBranchUpdated events and trigger Amazon EventBridge rule." https://aws.amazon.com/blogs/devops/automated-code-review-on-pull-requests-using-aws-codecommit-and-aws-codebuild/

seetptOption: C

i go with C