DOP-C02 Exam QuestionsBrowse all questions from this exam

DOP-C02 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?

Show Answer
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

17 comments
Sign in to comment
MarDog
Jun 29, 2023

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

Gomer
Jun 6, 2024

Link is dead

madperroOption: B
Jun 20, 2023

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

bcxOption: C
May 31, 2023

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).

tartarus23Option: C
Jun 19, 2023

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.

RVivekOption: C
Sep 11, 2023

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

qan1257Option: C
May 29, 2023

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

youonebe
May 29, 2023

Why not B?

luntOption: C
Jul 29, 2023

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.

vhermanOption: C
Aug 2, 2023

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

ggrodskiy
Aug 14, 2023

Correct C.

DZ_BenOption: C
Nov 2, 2023

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.

zolthar_z
Nov 21, 2023

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

DucSiu
Dec 20, 2023

Why not B?

thanhnv142
Jan 31, 2024

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
Jul 5, 2024

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

zijo
Mar 22, 2024

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

seetptOption: C
May 1, 2024

i go with C

GomerOption: C
Jun 6, 2024

"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/