diff --git a/.github/workflows/run-e2e-tests.yaml b/.github/workflows/run-e2e-tests.yaml index 64bc02c..22823de 100644 --- a/.github/workflows/run-e2e-tests.yaml +++ b/.github/workflows/run-e2e-tests.yaml @@ -4,69 +4,14 @@ on: pull_request_review: types: - submitted - schedule: - - cron: '0 0 1 * *' jobs: - build-templates: + delete-stacks: if: github.event.review.state == 'approved' runs-on: ubuntu-latest permissions: id-token: write contents: write - strategy: - matrix: - TEMPLATE_FILE: [lambda-template, logging-lambda-firehose-template, logging-lambda-metric-polling, logging-lambda-metric-stream, logging-firehose-metric-polling, logging-firehose-metric-stream, logging-lambda-firehose-metric-polling, logging-lambda-firehose-metric-stream] - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version: '1.22' - - - name: Install AWS SAM CLI - run: | - pip install aws-sam-cli - - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v3 - with: - role-to-assume: ${{ secrets.AWS_E2E_ROLE }} - aws-region: us-east-1 - - - name: Build SAM Application - env: - S3_BUCKET: unified-lambda-e2e-test-templates - run: | - sam build -u --template-file "${{ matrix.TEMPLATE_FILE }}.yaml" --build-dir ".aws-sam/build/${{ matrix.TEMPLATE_FILE }}" - sam package --s3-bucket "$S3_BUCKET" --template-file ".aws-sam/build/${{ matrix.TEMPLATE_FILE }}/template.yaml" --output-template-file ".aws-sam/build/${{ matrix.TEMPLATE_FILE }}/${{ matrix.TEMPLATE_FILE }}.yaml" - - - name: Upload Artifact - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.TEMPLATE_FILE }}.yaml - path: .aws-sam/build/${{ matrix.TEMPLATE_FILE }}/${{ matrix.TEMPLATE_FILE }}.yaml - - - name: Send failure notification to Slack - if: always() - uses: ravsamhq/notify-slack-action@v1 - with: - status: ${{ job.status }} - notify_when: 'failure' - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - - run-e2e-tests-cloudwatch: - needs: [build-templates] - runs-on: ubuntu-latest - permissions: - id-token: write - contents: write - strategy: - matrix: - test-case: [test_logs_with_filter_pattern, test_logs_for_secret_manager, test_logs_for_invalid_log_group] steps: - name: Checkout code uses: actions/checkout@v4 @@ -97,145 +42,5 @@ jobs: NEW_RELIC_LICENSE_KEY: ${{ secrets.NEW_RELIC_LICENSE_KEY }} run: | cd e2e-tests - ./lambda-cloudwatch-trigger.sh ${{ matrix.test-case }} - - - name: Send failure notification to Slack - if: always() - uses: ravsamhq/notify-slack-action@v1 - with: - status: ${{ job.status }} - notify_when: 'failure' - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - - run-e2e-tests-s3: - needs: [build-templates] - runs-on: ubuntu-latest - permissions: - id-token: write - contents: write - strategy: - matrix: - test-case: [test_logs_for_prefix, test_logs_for_secret_manager, test_logs_for_invalid_bucket_name] - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Download Artifact - uses: actions/download-artifact@v4 - with: - path: build-artifacts - - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version: '1.22' - - - name: Install AWS SAM CLI - run: | - pip install aws-sam-cli - - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v3 - with: - role-to-assume: ${{ secrets.AWS_E2E_ROLE }} - aws-region: us-east-1 - - - name: Run e2e tests for s3 - env: - NEW_RELIC_USER_KEY: ${{ secrets.NEW_RELIC_USER_KEY }} - NEW_RELIC_LICENSE_KEY: ${{ secrets.NEW_RELIC_LICENSE_KEY }} - run: | - cd e2e-tests - ./lambda-s3-trigger.sh ${{ matrix.test-case }} - - - name: Send failure notification to Slack - if: always() - uses: ravsamhq/notify-slack-action@v1 - with: - status: ${{ job.status }} - notify_when: 'failure' - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - - run-e2e-tests-lambda-firehose-metrics: - needs: [build-templates] - runs-on: ubuntu-latest - permissions: - id-token: write - contents: write - strategy: - matrix: - test-case: [test_for_lambda_firehose_stack, test_for_firehose_metric_polling_stack, test_for_firehose_metric_streaming_stack, test_for_lambda_metrics_polling_stack, test_for_lambda_metrics_streaming_stack, test_for_lambda_firehose_metric_polling_stack, test_for_lambda_firehose_metric_streaming_stack] - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Download Artifact - uses: actions/download-artifact@v4 - with: - path: build-artifacts - - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version: '1.22' - - - name: Install AWS SAM CLI - run: | - pip install aws-sam-cli - - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v3 - with: - role-to-assume: ${{ secrets.AWS_E2E_ROLE }} - aws-region: us-east-1 - - - name: Run e2e tests for lambda and metrics stack - env: - NEW_RELIC_USER_KEY: ${{ secrets.NEW_RELIC_USER_KEY }} - NEW_RELIC_LICENSE_KEY: ${{ secrets.NEW_RELIC_LICENSE_KEY }} - run: | - cd e2e-tests/ - ./lambda-with-metrics-test.sh ${{ matrix.test-case }} - - - name: Send failure notification to Slack - if: always() - uses: ravsamhq/notify-slack-action@v1 - with: - status: ${{ job.status }} - notify_when: 'failure' - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - - clean-up: - needs: [run-e2e-tests-cloudwatch, run-e2e-tests-s3, run-e2e-tests-lambda-firehose-metrics] - runs-on: ubuntu-latest - permissions: - id-token: write - contents: write - steps: - - name: Install AWS SAM CLI - run: | - pip install aws-sam-cli - - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v3 - with: - role-to-assume: ${{ secrets.AWS_E2E_ROLE }} - aws-region: us-east-1 - - - name: Delete Resources - env: - S3_BUCKET: unified-lambda-e2e-test-templates - run: - aws s3 rm "s3://$S3_BUCKET" --recursive - - - name: Send failure notification to Slack - if: always() - uses: ravsamhq/notify-slack-action@v1 - with: - status: ${{ job.status }} - notify_when: 'failure' - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} \ No newline at end of file + chmod +x delete-stacks.sh + ./delete-stacks.sh \ No newline at end of file diff --git a/e2e-tests/delete-stacks.sh b/e2e-tests/delete-stacks.sh new file mode 100644 index 0000000..8e59f5d --- /dev/null +++ b/e2e-tests/delete-stacks.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +source common-scripts/stack-scripts.sh +source common-scripts/resource-scripts.sh +source common-scripts/logs-scripts.sh +source common-scripts/test-configs.cfg + +delete_stack "$LAMBDA_FIREHOSE_CASE" +delete_stack "$LAMBDA_METRIC_POLLING_CASE" +delete_stack "$LAMBDA_METRIC_STREAMING_CASE" +delete_stack "$FIREHOSE_METRIC_POLLING_CASE" +delete_stack "$FIREHOSE_METRIC_STREAMING_CASE" +delete_stack "$LAMBDA_FIREHOSE_METRIC_POLLING_CASE" +delete_stack "$LAMBDA_FIREHOSE_METRIC_STREAMING_CASE" +delete_stack "$S3_SECRET_MANAGER_CASE" +delete_stack "$S3_PREFIX_CASE" +delete_stack "$S3_INVALID_BUCKET_CASE" +delete_stack "$CLOUDWATCH_FILTER_PATTERN_CASE" +delete_stack "$CLOUDWATCH_SECRET_MANAGER_CASE" +delete_stack "$CLOUDWATCH_INVALID_LOG_GROUP_CASE" \ No newline at end of file