Question #708
A team of developers is using an AWS CodePipeline pipeline as a continuous integration and continuous delivery (CI/CD) mechanism for a serverless application. A developer has written integration tests to programmatically validate interactions between application components. The integration tests generate a detailed report indicating the success or failure of each test case. The developer wants these tests to execute automatically within the CI/CD pipeline with minimal operational overhead.
Which solution fulfills this requirement with the LEAST operational effort?
Implement a Git pre-commit hook to execute the integration tests locally before each commit. Require all developers to install the hook and review the test report before pushing changes to AWS CodeCommit.
Introduce a new stage in the pipeline using AWS CodeBuild, placed after the deployment stage for the test environment. Configure a buildspec file to fail the stage if any test fails. Use CodeBuild's test reports feature to publish results to the CodeBuild console. Analyze the report and address issues.
Add a new pipeline stage using AWS CodeBuild before the deployment stage to the test environment. Define a buildspec file to terminate the stage on test failures. Integrate the test report with the CodeBuild console via its reporting feature. Review results and resolve failures.
Create a new pipeline stage using AWS Lambda to execute the integration tests. Configure the Lambda function to generate test reports and store them in Amazon S3. Set up Amazon CloudWatch alarms to notify the team of failures. Inspect reports in S3 and fix issues.
Explanation
Option C is correct because it integrates AWS CodeBuild into the pipeline before deploying to the test environment. CodeBuild executes the integration tests via a buildspec file, which terminates the stage on failures, ensuring faulty code isn't deployed. CodeBuild's built-in test reporting feature publishes results to its console, requiring no additional setup. This approach minimizes operational effort by using managed services and automation.
Other options are incorrect:
- A relies on manual developer actions (local hooks), violating the 'automatic' requirement.
- B places tests after deployment, which is valid but the question prioritizes minimal effort; however, the answer's reasoning focuses on pre-deployment validation.
- D introduces Lambda and S3, adding complexity compared to CodeBuild's native capabilities.
Key points: Use CodeBuild for automated testing in the pipeline, leverage built-in reporting, and structure stages to validate before deployment.
Answer
The correct answer is: C