diff --git a/.github/workflows/run.e2e-tests.yml b/.github/workflows/run.e2e-tests.yml index 40cdaa3..1a1c051 100644 --- a/.github/workflows/run.e2e-tests.yml +++ b/.github/workflows/run.e2e-tests.yml @@ -9,29 +9,51 @@ defaults: env: AWS_REGION: us-west-2 - AWS_PROFILE: default NAMESPACE: tftest IZE_LOG_LEVEL: debug - IZE_PREFER_RUNTIME: native IZE_PLAIN_TEXT: true - IZE_VERSION: 1.1.9 + IZE_VERSION: 0.0.0-dev + AWS_PROFILE: debug on: workflow_dispatch: pull_request: jobs: - complete-worker: + e2e: runs-on: ubuntu-latest timeout-minutes: 60 + strategy: + fail-fast: false + max-parallel: 2 # VPCs are limited + matrix: + include: + - name: complete-worker + env: e2e01 + test_name: TestExamplesCompleteWorker + - name: worker-scheduled + env: e2e02 + test_name: TestExamplesWorkerSchedule + - name: complete-web + env: e2e03 + test_name: TestExamplesCompleteWeb + - name: web-nginx-proxy + env: e2e04 + test_name: TestExamplesWebProxy + - name: worker-scheduled-autoscale + env: e2e05 + test_name: TestExamplesWorkerAutoScheduled + - name: complete-worker-ec2 + env: e2e06 + test_name: TestExamplesWorkerEc2 env: - ENV: examples1 + ENV: ${{ matrix.env }} steps: - name: Install Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v5 with: - go-version: 1.18.x + go-version: 1.22.x - name: Checkout Code uses: actions/checkout@v2 @@ -47,7 +69,7 @@ jobs: run: ssh-keygen -q -f ~/.ssh/id_rsa - name: IZE setup - uses: hazelops/action-setup-ize@0.0.1 + uses: hazelops/action-setup-ize@1.0.1 with: version: ${{ env.IZE_VERSION }} @@ -62,267 +84,46 @@ jobs: - name: Copy generated files run: | - cp -R .ize/env/${{ env.ENV }}/*.* examples/${{ github.job }}/ + cp -R .ize/env/${{ env.ENV }}/*.* examples/${{ matrix.name }}/ - name: Go TF Test + working-directory: test run: | - cd test + go install github.com/gruntwork-io/terratest/cmd/terratest_log_parser@latest go mod tidy - go test -v -timeout 60m -run TestExamplesCompleteWorker + go test -v -timeout 60m -run ${{ matrix.test_name }} -coverprofile=coverage-${{ matrix.test_name }}.out -race -covermode=atomic | tee test_output.log + terratest_log_parser -testlog test_output.log -outputdir results + ls -la - - worker-scheduled: - runs-on: ubuntu-latest - timeout-minutes: 60 - env: - ENV: examples2 - needs: - - complete-worker - - web-nginx-proxy - - steps: - - name: Install Go - uses: actions/setup-go@v2 - with: - go-version: 1.18.x - - - name: Checkout Code - uses: actions/checkout@v2 - - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_SA }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_SA }} - aws-region: ${{ env.AWS_REGION }} - - - name: Generate Test SSH Key - run: ssh-keygen -q -f ~/.ssh/id_rsa - - - name: IZE setup - uses: hazelops/action-setup-ize@0.0.1 - with: - version: ${{ env.IZE_VERSION }} - - - name: IZE init - run: ize init - - - name: IZE create AWS Profile - run: ize gen aws-profile - - - name: IZE gen tfenv - run: ize gen tfenv - - - name: Copy generated files - run: | - cp -R .ize/env/${{ env.ENV }}/*.* examples/${{ github.job }}/ - - - name: Go TF Test - run: | - cd test - go mod tidy - go test -v -timeout 60m -run TestExamplesWorkerSchedule - - - complete-web: - runs-on: ubuntu-latest - timeout-minutes: 60 - env: - ENV: examples3 - needs: - - complete-worker - - web-nginx-proxy - - steps: - - name: Install Go - uses: actions/setup-go@v2 - with: - go-version: 1.18.x - - - name: Checkout Code - uses: actions/checkout@v2 - - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_SA }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_SA }} - aws-region: ${{ env.AWS_REGION }} - - - name: Generate Test SSH Key - run: ssh-keygen -q -f ~/.ssh/id_rsa - - - name: IZE setup - uses: hazelops/action-setup-ize@0.0.1 - with: - version: ${{ env.IZE_VERSION }} - - - name: IZE init - run: ize init - - - name: IZE create AWS Profile - run: ize gen aws-profile - - - name: IZE gen tfenv - run: ize gen tfenv - - - name: Copy generated files - run: | - cp -R .ize/env/${{ env.ENV }}/*.* examples/${{ github.job }}/ - - - name: Go TF Test - run: | - cd test - go mod tidy - go test -v -timeout 60m -run TestExamplesCompleteWeb - - - web-nginx-proxy: - runs-on: ubuntu-latest - env: - ENV: examples5 - timeout-minutes: 60 - - steps: - - name: Install Go - uses: actions/setup-go@v2 - with: - go-version: 1.18.x - - - name: Checkout Code - uses: actions/checkout@v2 - - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v1 + - name: Test Summary + uses: test-summary/action@v2 with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_SA }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_SA }} - aws-region: ${{ env.AWS_REGION }} - - - name: Generate Test SSH Key - run: ssh-keygen -q -f ~/.ssh/id_rsa - - - name: IZE setup - uses: hazelops/action-setup-ize@0.0.1 - with: - version: ${{ env.IZE_VERSION }} - - - name: IZE init - run: ize init - - - name: IZE create AWS Profile - run: ize gen aws-profile - - - name: IZE gen tfenv - run: ize gen tfenv - - - name: Copy generated files - run: | - cp -R .ize/env/${{ env.ENV }}/*.* examples/${{ github.job }}/ - - - name: Go TF Test - run: | - cd test - go mod tidy - go test -v -timeout 60m -run TestExamplesWebProxy - - worker-scheduled-autoscale: - runs-on: ubuntu-latest - timeout-minutes: 60 - env: - ENV: examples4 - needs: - - worker-scheduled - - steps: - - name: Install Go - uses: actions/setup-go@v2 - with: - go-version: 1.18.x - - - name: Checkout Code - uses: actions/checkout@v2 - - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_SA }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_SA }} - aws-region: ${{ env.AWS_REGION }} - - - name: Generate Test SSH Key - run: ssh-keygen -q -f ~/.ssh/id_rsa - - - name: IZE setup - uses: hazelops/action-setup-ize@0.0.1 - with: - version: ${{ env.IZE_VERSION }} + paths: | + test/results/**/*.xml + test/results/*.xml - - name: IZE init - run: ize init - - - name: IZE create AWS Profile - run: ize gen aws-profile - - - name: IZE gen tfenv - run: ize gen tfenv - - - name: Copy generated files - run: | - cp -R .ize/env/${{ env.ENV }}/*.* examples/${{ github.job }}/ + if: always() - - name: Go TF Test - run: | - cd test - go mod tidy - go test -v -timeout 60m -run TestExamplesWorkerAutoScheduled - - complete-worker-ec2: - runs-on: ubuntu-latest - timeout-minutes: 60 - env: - ENV: examples6 - needs: - - worker-scheduled-autoscale - steps: - - name: Install Go - uses: actions/setup-go@v2 + - name: Upload test summary + uses: actions/upload-artifact@v3 with: - go-version: 1.18.x - - - name: Checkout Code - uses: actions/checkout@v2 + name: test-summary-${{ matrix.test_name }} + path: test/test-summary-${{ matrix.test_name }}.md + if: always() - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v1 + - name: Upload Go test results + uses: actions/upload-artifact@v4 with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_SA }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_SA }} - aws-region: ${{ env.AWS_REGION }} - - - name: Generate Test SSH Key - run: ssh-keygen -q -f ~/.ssh/id_rsa + name: coverage-${{ matrix.test_name }} + path: test/coverage-${{ matrix.test_name }}.out + if: always() - - name: IZE setup - uses: hazelops/action-setup-ize@0.0.1 + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4.0.1 with: - version: ${{ env.IZE_VERSION }} - - - name: IZE init - run: ize init - - - name: IZE create AWS Profile - run: ize gen aws-profile - - - name: IZE gen tfenv - run: ize gen tfenv + files: test/coverage-${{ matrix.test_name }}.out + token: ${{ secrets.CODECOV_TOKEN }} + verbose: true + name: ${{ matrix.test_name }} - - name: Copy generated files - run: | - cp -R .ize/env/${{ env.ENV }}/*.* examples/${{ github.job }}/ - - name: Go TF Test - run: | - cd test - go mod tidy - go test -v -timeout 60m -run TestExamplesCompleteWorkerEc2 diff --git a/examples/complete-worker-ec2/main.tf b/examples/complete-worker-ec2/main.tf index 99e7fc2..2291bfa 100644 --- a/examples/complete-worker-ec2/main.tf +++ b/examples/complete-worker-ec2/main.tf @@ -75,13 +75,13 @@ resource "aws_key_pair" "root" { module "ecs" { source = "registry.terraform.io/terraform-aws-modules/ecs/aws" version = "~> 4.0" - cluster_name = "${var.env}-${var.namespace}" + cluster_name = "${var.env}-${var.namespace}-worker-ec2" } module "worker_complete" { source = "../.." - name = "worker" + name = "worker-ec2" app_type = "worker" env = var.env diff --git a/test/examples_complete-web_test.go b/test/examples_complete-web_test.go index 4739d33..3d42d1e 100644 --- a/test/examples_complete-web_test.go +++ b/test/examples_complete-web_test.go @@ -128,17 +128,17 @@ func TestExamplesCompleteWeb(t *testing.T) { // Run `terraform output` to get the value of an output variable cloudWatchLogGroup := terraform.Output(t, terraformOptions, "cloudwatch_log_group") // Verify we're getting back the outputs we expect - assert.Equal(t, "examples3-app", cloudWatchLogGroup) + assert.Equal(t, "e2e03-app", cloudWatchLogGroup) // Run `terraform output` to get the value of an output variable ecsClusterName := terraform.Output(t, terraformOptions, "ecs_cluster_name") // Verify we're getting back the outputs we expect - assert.Equal(t, "examples3-tftest-app", ecsClusterName) + assert.Equal(t, "e2e03-tftest-app", ecsClusterName) // Run `terraform output` to get the value of an output variable r53AppDnsName := terraform.Output(t, terraformOptions, "r53_lb_dns_name") // Verify we're getting back the outputs we expect - assert.Equal(t, "app.examples3.nutcorp.net", r53AppDnsName) + assert.Equal(t, "app.e2e03.nutcorp.net", r53AppDnsName) /* // Run `terraform output` to get the value of an output variable proxyEndpoint := terraform.Output(t, terraformOptions, "proxy_endpoint") diff --git a/test/examples_complete-worker-ec2_test.go b/test/examples_complete-worker-ec2_test.go index 9cd989e..a489451 100644 --- a/test/examples_complete-worker-ec2_test.go +++ b/test/examples_complete-worker-ec2_test.go @@ -118,22 +118,22 @@ func TestExamplesWorkerEc2(t *testing.T) { // Run `terraform output` to get the value of an output variable vpcCidr := terraform.Output(t, terraformOptions, "vpc_cidr") // Verify we're getting back the outputs we expect - assert.Equal(t, "10.4.0.0/16", vpcCidr) + assert.Equal(t, "10.0.0.0/16", vpcCidr) // Run `terraform output` to get the value of an output variable privateSubnetCidrs := terraform.OutputList(t, terraformOptions, "private_subnet_cidrs") // Verify we're getting back the outputs we expect - assert.Equal(t, []string{"10.4.20.0/23"}, privateSubnetCidrs) + assert.Equal(t, []string{"10.0.20.0/23"}, privateSubnetCidrs) // Run `terraform output` to get the value of an output variable cloudWatchLogGroup := terraform.Output(t, terraformOptions, "cloudwatch_log_group") // Verify we're getting back the outputs we expect - assert.Equal(t, "examples2-complete-worker-ec2", cloudWatchLogGroup) + assert.Equal(t, "e2e06-worker-ec2", cloudWatchLogGroup) // Run `terraform output` to get the value of an output variable ecsClusterName := terraform.Output(t, terraformOptions, "ecs_cluster_name") // Verify we're getting back the outputs we expect - assert.Equal(t, "examples2-tftest-complete-worker-ec2", ecsClusterName) + assert.Equal(t, "e2e06-tftest-worker-ec2", ecsClusterName) /* // Run `terraform output` to get the value of an output variable diff --git a/test/examples_complete-worker-scheduled-autoscale_test.go b/test/examples_complete-worker-scheduled-autoscale_test.go index ec9dd65..6da81d3 100644 --- a/test/examples_complete-worker-scheduled-autoscale_test.go +++ b/test/examples_complete-worker-scheduled-autoscale_test.go @@ -128,12 +128,12 @@ func TestExamplesWorkerAutoScheduled(t *testing.T) { // Run `terraform output` to get the value of an output variable cloudWatchLogGroup := terraform.Output(t, terraformOptions, "cloudwatch_log_group") // Verify we're getting back the outputs we expect - assert.Equal(t, "examples4-worker-scheduled-auto", cloudWatchLogGroup) + assert.Equal(t, "e2e05-worker-scheduled-auto", cloudWatchLogGroup) // Run `terraform output` to get the value of an output variable ecsClusterName := terraform.Output(t, terraformOptions, "ecs_cluster_name") // Verify we're getting back the outputs we expect - assert.Equal(t, "examples4-tftest-worker-scheduled-auto", ecsClusterName) + assert.Equal(t, "e2e05-tftest-worker-scheduled-auto", ecsClusterName) /* // Run `terraform output` to get the value of an output variable diff --git a/test/examples_complete-worker-scheduled_test.go b/test/examples_complete-worker-scheduled_test.go index 5552334..85938ca 100644 --- a/test/examples_complete-worker-scheduled_test.go +++ b/test/examples_complete-worker-scheduled_test.go @@ -128,12 +128,12 @@ func TestExamplesWorkerSchedule(t *testing.T) { // Run `terraform output` to get the value of an output variable cloudWatchLogGroup := terraform.Output(t, terraformOptions, "cloudwatch_log_group") // Verify we're getting back the outputs we expect - assert.Equal(t, "examples2-worker-scheduled", cloudWatchLogGroup) + assert.Equal(t, "e2e02-worker-scheduled", cloudWatchLogGroup) // Run `terraform output` to get the value of an output variable ecsClusterName := terraform.Output(t, terraformOptions, "ecs_cluster_name") // Verify we're getting back the outputs we expect - assert.Equal(t, "examples2-tftest-worker-scheduled", ecsClusterName) + assert.Equal(t, "e2e02-tftest-worker-scheduled", ecsClusterName) /* // Run `terraform output` to get the value of an output variable diff --git a/test/examples_complete-worker_test.go b/test/examples_complete-worker_test.go index b943cb1..75436d3 100644 --- a/test/examples_complete-worker_test.go +++ b/test/examples_complete-worker_test.go @@ -128,12 +128,12 @@ func TestExamplesCompleteWorker(t *testing.T) { // Run `terraform output` to get the value of an output variable cloudWatchLogGroup := terraform.Output(t, terraformOptions, "cloudwatch_log_group") // Verify we're getting back the outputs we expect - assert.Equal(t, "examples1-worker", cloudWatchLogGroup) + assert.Equal(t, "e2e01-worker", cloudWatchLogGroup) // Run `terraform output` to get the value of an output variable ecsClusterName := terraform.Output(t, terraformOptions, "ecs_cluster_name") // Verify we're getting back the outputs we expect - assert.Equal(t, "examples1-tftest-worker", ecsClusterName) + assert.Equal(t, "e2e01-tftest-worker", ecsClusterName) /* // Run `terraform output` to get the value of an output variable diff --git a/test/examples_web-proxy_test.go b/test/examples_web-proxy_test.go index ac926c9..b0ef679 100644 --- a/test/examples_web-proxy_test.go +++ b/test/examples_web-proxy_test.go @@ -128,17 +128,17 @@ func TestExamplesWebProxy(t *testing.T) { // Run `terraform output` to get the value of an output variable cloudWatchLogGroup := terraform.Output(t, terraformOptions, "cloudwatch_log_group") // Verify we're getting back the outputs we expect - assert.Equal(t, "examples5-proxy", cloudWatchLogGroup) + assert.Equal(t, "e2e04-proxy", cloudWatchLogGroup) // Run `terraform output` to get the value of an output variable ecsClusterName := terraform.Output(t, terraformOptions, "ecs_cluster_name") // Verify we're getting back the outputs we expect - assert.Equal(t, "examples5-tftest-proxy", ecsClusterName) + assert.Equal(t, "e2e04-tftest-proxy", ecsClusterName) // Run `terraform output` to get the value of an output variable r53AppDnsName := terraform.Output(t, terraformOptions, "r53_lb_dns_name") // Verify we're getting back the outputs we expect - assert.Equal(t, "proxy.examples5.nutcorp.net", r53AppDnsName) + assert.Equal(t, "proxy.e2e04.nutcorp.net", r53AppDnsName) /* // Run `terraform output` to get the value of an output variable proxyEndpoint := terraform.Output(t, terraformOptions, "proxy_endpoint")