Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding userdata test #1

Closed
wants to merge 13 commits into from
80 changes: 79 additions & 1 deletion .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ jobs:
ec2_mac_matrix: ${{ steps.set-matrix.outputs.ec2_mac_matrix }}
ec2_performance_matrix: ${{steps.set-matrix.outputs.ec2_performance_matrix}}
ec2_stress_matrix: ${{steps.set-matrix.outputs.ec2_stress_matrix}}
ec2_userdata_matrix: ${{ steps.set-matrix.outputs.ec2_userdata_matrix }}
ecs_ec2_launch_daemon_matrix: ${{ steps.set-matrix.outputs.ecs_ec2_launch_daemon_matrix }}
ecs_fargate_matrix: ${{ steps.set-matrix.outputs.ecs_fargate_matrix }}
steps:
Expand All @@ -166,6 +167,7 @@ jobs:
echo "::set-output name=ec2_mac_matrix::$(echo $(cat generator/resources/ec2_mac_complete_test_matrix.json))"
echo "::set-output name=ec2_performance_matrix::$(echo $(cat generator/resources/ec2_performance_complete_test_matrix.json))"
echo "::set-output name=ec2_stress_matrix::$(echo $(cat generator/resources/ec2_stress_complete_test_matrix.json))"
echo "::set-output name=ec2_userdata_matrix::$(echo $(cat generator/resources/ec2_userdata_complete_test_matrix.json))"
echo "::set-output name=ecs_ec2_launch_daemon_matrix::$(echo $(cat generator/resources/ecs_ec2_daemon_complete_test_matrix.json))"
echo "::set-output name=ecs_fargate_matrix::$(echo $(cat generator/resources/ecs_fargate_complete_test_matrix.json))"

Expand All @@ -177,6 +179,7 @@ jobs:
echo "ec2_mac_matrix: ${{ steps.set-matrix.outputs.ec2_mac_matrix }}"
echo "ec2_performance_matrix: ${{ steps.set-matrix.outputs.ec2_performance_matrix}}"
echo "ec2_stress_matrix: ${{ steps.set-matrix.outputs.ec2_stress_matrix}}"
echo "ec2_userdata_matrix: ${{ steps.set-matrix.outputs.ec2_userdata_matrix}}"
echo "ecs_ec2_launch_daemon_matrix${{ steps.set-matrix.outputs.ecs_ec2_launch_daemon_matrix }}"
echo "ecs_fargate_matrix${{ steps.set-matrix.outputs.ecs_fargate_matrix }}"

Expand Down Expand Up @@ -548,7 +551,7 @@ jobs:

EC2LinuxIntegrationTest:
needs: [MakeBinary, StartLocalStack, GenerateTestMatrix]
name: 'Test'
name: 'EC2LinuxIntegrationTest'
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand Down Expand Up @@ -621,6 +624,81 @@ jobs:
retry_wait_seconds: 5
command: cd terraform/ec2/linux && terraform destroy --auto-approve

EC2UserDataIntegrationTest:
needs: [MakeBinary, StartLocalStack, GenerateTestMatrix]
name: 'EC2UserDataIntegrationTest'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
arrays: ${{ fromJson(needs.GenerateTestMatrix.outputs.ec2_userdata_matrix) }}
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v3
with:
repository: ${{env.CWA_GITHUB_TEST_REPO_NAME}}
ref: ${{env.CWA_GITHUB_TEST_REPO_BRANCH}}

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ env.TERRAFORM_AWS_ASSUME_ROLE }}
aws-region: us-west-2

- name: Cache if success
id: ec2-userdata-integration-test
uses: actions/cache@v3
with:
path: go.mod
key: ec2-userdata-integration-test-${{ github.sha }}-${{ matrix.arrays.os }}-${{ matrix.arrays.arc }}-${{ matrix.arrays.test_dir }}

- name: Echo Test Info
run: echo run on ec2 instance os ${{ matrix.arrays.os }} arc ${{ matrix.arrays.arc }} test dir ${{ matrix.arrays.test_dir }}

- name: Verify Terraform version
run: terraform --version

# nick-fields/retry@v2 starts at base dir
- name: Terraform apply
if: steps.ec2-userdata-integration-test.outputs.cache-hit != 'true'
uses: nick-fields/retry@v2
with:
max_attempts: 1
timeout_minutes: 60
retry_wait_seconds: 5
command: |
cd terraform/ec2/userdata
terraform init
if terraform apply --auto-approve \
-var="ssh_key_value=${PRIVATE_KEY}" -var="github_test_repo=${{env.CWA_GITHUB_TEST_REPO_URL}}" \
-var="cwa_github_sha=${GITHUB_SHA}" -var="install_agent=${{ matrix.arrays.installAgentCommand }}" \
-var="github_test_repo_branch=${{env.CWA_GITHUB_TEST_REPO_BRANCH}}" \
-var="ec2_instance_type=${{ matrix.arrays.instanceType }}" \
-var="user=${{ matrix.arrays.username }}" \
-var="ami=${{ matrix.arrays.ami }}" \
-var="ca_cert_path=${{ matrix.arrays.caCertPath }}" \
-var="arc=${{ matrix.arrays.arc }}" \
-var="binary_name=${{ matrix.arrays.binaryName }}" \
-var="local_stack_host_name=${{ needs.StartLocalStack.outputs.local_stack_host_name }}" \
-var="s3_bucket=${S3_INTEGRATION_BUCKET}" \
-var="plugin_tests='${{ github.event.inputs.plugins }}'" \
-var="ssh_key_name=${KEY_NAME}" \
-var="test_dir=${{ matrix.arrays.test_dir }}" ; then terraform destroy -auto-approve
else
terraform destroy -auto-approve && exit 1
fi
#This is here just in case workflow cancel
- name: Terraform destroy
if: ${{ cancelled() && steps.ec2-linux-integration-test.outputs.cache-hit != 'true' }}
uses: nick-fields/retry@v2
with:
max_attempts: 3
timeout_minutes: 8
retry_wait_seconds: 5
command: cd terraform/ec2/linux && terraform destroy --auto-approve

EC2WinIntegrationTest:
needs: [BuildMSI, GenerateTestMatrix]
name: 'EC2WinIntegrationTest'
Expand Down