diff --git a/.github/workflows/build-and-push-image-with-cpUtility-test.yml b/.github/workflows/build-and-push-image-with-cpUtility-test.yml new file mode 100644 index 0000000000..c0e7912411 --- /dev/null +++ b/.github/workflows/build-and-push-image-with-cpUtility-test.yml @@ -0,0 +1,78 @@ +name: Build and Push Java-Agent Image after CPUtility Test # non-Appsignals Testing +on: + workflow_call: + inputs: + aws-region: + required: true + type: string + image_uri_with_tag: + required: true + type: string + image_registry: + required: true + type: string + adot-java-version: + required: true + tpe: string + +env: + AWS_DEFAULT_REGION: ${{ inputs.aws-region }} + +permissions: + id-token: write + contents: read + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: temurin + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets.JAVA_INSTRUMENTATION_SNAPSHOT_ECR }} + aws-region: {{ env.AWS_DEFAULT_REGION }} + + - name: Login to private staging ecr + uses: docker/login-action@v3 + with: + registry: ${{ inputs.image_registry }} + env: + AWS_REGION: {{ env.AWS_DEFAULT_REGION }} + + - name: Build image for testing + uses: docker/build-push-action@v5 + with: + push: false + build-args: "ADOT_JAVA_VERSION=${{ inputs.adot-java-version }}" + context: . + platforms: linux/amd64 + tags: ${{ inputs.image_uri_with_tag }} + load: true + + - name: Test docker image + shell: bash + run: .github/scripts/test-adot-javaagent-image.sh "${{ inputs.image_uri_with_tag }}" "${{ inputs.adot-java-version }}" + + - name: Build and push image + uses: docker/build-push-action@v5 + with: + push: true + build-args: "ADOT_JAVA_VERSION=${{ inputs.adot-java-version }}" + context: . + platforms: linux/amd64,linux/arm64 + tags: ${{ inputs.image_uri_with_tag }} \ No newline at end of file diff --git a/.github/workflows/contract-tests.yml b/.github/workflows/contract-tests.yml new file mode 100644 index 0000000000..7ce9ffe0d4 --- /dev/null +++ b/.github/workflows/contract-tests.yml @@ -0,0 +1,80 @@ +name: End to End Tests with Operator # Appsignals Contract Testing +on: + workflow_call: + inputs: + aws-region: + required: true + type: string + caller-workflow-name: + required: true + type: string +env: + AWS_DEFAULT_REGION: ${{ inputs.aws-region }} + +permissions: + id-token: write + contents: read + +jobs: + # AppSignals specific contract tests + contract-tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-java@v3 + with: + java-version: 17 + distribution: 'temurin' + - uses: gradle/wrapper-validation-action@v1 + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + + - name: Log in to AWS ECR + uses: docker/login-action@v3 + with: + registry: public.ecr.aws + + # cache local patch outputs + - name: Cache local Maven repository + id: cache-local-maven-repo + uses: actions/cache@v3 + with: + path: | + ~/.m2/repository/io/opentelemetry/ + key: ${{ runner.os }}-maven-local-${{ hashFiles('.github/patches/opentelemetry-java*.patch') }} + + - name: Publish patched dependencies to maven local + uses: ./.github/actions/patch-dependencies + if: steps.cache-local-maven-repo.outputs.cache-hit != 'true' + with: + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + gpg_password: ${{ secrets.GPG_PASSPHRASE }} + + - name: Pull base image of Contract Tests Sample Apps + run: docker pull public.ecr.aws/docker/library/amazoncorretto:17-alpine + + - name: Build snapshot with Gradle + uses: gradle/gradle-build-action@v2 + with: + arguments: contractTests --stacktrace -PenableCoverage=true -PtestUpstreamSnapshots=true -PlocalDocker=true + + # publish status + publish-build-status: + needs: [ contract-tests ] + if: ${{ always() }} + uses: ./.github/workflows/publish-status.yml + with: + namespace: 'ADOT/GitHubActions' + repository: ${{ github.repository }} + branch: ${{ github.ref_name }} + workflow: ${{ inputs.caller-workflow-name }} + success: ${{ needs.contract-tests.result == 'success' }} + region: us-west-2 + secrets: + roleArn: ${{ secrets.METRICS_ROLE_ARN }} \ No newline at end of file diff --git a/.github/workflows/e2e-tests-app-with-java-agent.yml b/.github/workflows/e2e-tests-app-with-java-agent.yml new file mode 100644 index 0000000000..985a65c303 --- /dev/null +++ b/.github/workflows/e2e-tests-app-with-java-agent.yml @@ -0,0 +1,183 @@ +name: End to End Tests with Java Agent in Sample App +on: + workflow_call: + inputs: + aws-region: + required: true + type: string + image_tag: + required: true + type: string + caller-workflow-name: + required: true + type: string + +env: + AWS_DEFAULT_REGION: ${{ inputs.aws-region }} + +permissions: + id-token: write + contents: read + +jobs: + build_Images_For_Testing_Sample_App_With_Java_Agent: + runs-on: ubuntu-latest + steps: + - name: Checkout Java Instrumentation repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: temurin + + # cache local patch outputs + - name: Cache local Maven repository + id: cache-local-maven-repo + uses: actions/cache@v3 + with: + path: | + ~/.m2/repository/io/opentelemetry/ + key: ${{ runner.os }}-maven-local-${{ hashFiles('.github/patches/opentelemetry-java*.patch') }} + + - name: Publish patched dependencies to maven local + uses: ./.github/actions/patch-dependencies + if: steps.cache-local-maven-repo.outputs.cache-hit != 'true' + with: + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + gpg_password: ${{ secrets.GPG_PASSPHRASE }} + + - name: Validate the checksums of Gradle Wrapper + uses: gradle/wrapper-validation-action@v1 + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + + - name: Log in to AWS ECR + uses: docker/login-action@v3 + with: + registry: public.ecr.aws + + - name: Build and push agent and testing docker images with Gradle + uses: gradle/gradle-build-action@v2 + with: + arguments: jib + env: + COMMIT_HASH: ${{ inputs.image_tag }} + + - uses: codecov/codecov-action@v3 + + test_Spring_App_With_Java_Agent: + name: Test Spring App with AWS OTel Java agent + needs: [ build_Images_For_Testing_Sample_App_With_Java_Agent ] + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: 'temurin' + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: Log in to AWS ECR + uses: docker/login-action@v3 + with: + registry: public.ecr.aws + + - name: Run test containers + run: docker-compose up --abort-on-container-exit + working-directory: .github/collector + env: + INSTANCE_ID: ${{ github.run_id }}-${{ github.run_number }} + LISTEN_ADDRESS: 0.0.0.0:8080 + APP_IMAGE: public.ecr.aws/aws-otel-test/aws-otel-java-springboot:${{ inputs.image_tag }} + VALIDATOR_COMMAND: -c springboot-otel-trace-metric-validation.yml --endpoint http://app:8080 --metric-namespace aws-otel-integ-test -t ${{ github.run_id }}-${{ github.run_number }} + + test_Spark_App_With_Java_Agent: + name: Test Spark App with AWS OTel Java agent + needs: [ build_Images_For_Testing_Sample_App_With_Java_Agent ] + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: 'temurin' + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: Log in to AWS ECR + uses: docker/login-action@v3 + with: + registry: public.ecr.aws + + - name: Run test containers + run: docker-compose up --abort-on-container-exit + working-directory: .github/collector + env: + INSTANCE_ID: ${{ github.run_id }}-${{ github.run_number }} + LISTEN_ADDRESS: 0.0.0.0:4567 + APP_IMAGE: public.ecr.aws/aws-otel-test/aws-otel-java-spark:${{ inputs.image_tag }} + VALIDATOR_COMMAND: -c spark-otel-trace-metric-validation.yml --endpoint http://app:4567 --metric-namespace aws-otel-integ-test -t ${{ github.run_id }}-${{ github.run_number }} + + test_Spark_AWS_SDK_V1_App_With_Java_Agent: + name: Test Spark App (AWS SDK v1) with AWS OTel Java agent + needs: [ build_Images_For_Testing_Sample_App_With_Java_Agent ] + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: 'temurin' + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: Log in to AWS ECR + uses: docker/login-action@v3 + with: + registry: public.ecr.aws + + - name: Run test containers + run: docker-compose up --abort-on-container-exit + working-directory: .github/collector + env: + INSTANCE_ID: ${{ github.run_id }}-${{ github.run_number }} + LISTEN_ADDRESS: 0.0.0.0:4567 + APP_IMAGE: public.ecr.aws/aws-otel-test/aws-otel-java-spark-awssdkv1:${{ inputs.image_tag }} + VALIDATOR_COMMAND: -c spark-otel-trace-metric-validation.yml --endpoint http://app:4567 --metric-namespace aws-otel-integ-test -t ${{ github.run_id }}-${{ github.run_number }} + + # publish status + publish-build-status: + needs: [ test_Spring_App_With_Java_Agent, test_Spark_App_With_Java_Agent, test_Spark_AWS_SDK_V1_App_With_Java_Agent ] + if: ${{ always() }} + uses: ./.github/workflows/publish-status.yml + with: + namespace: 'ADOT/GitHubActions' + repository: ${{ github.repository }} + branch: ${{ github.ref_name }} + workflow: ${{ inputs.caller-workflow-name }} + success: ${{ needs.test_Spring_App_With_Java_Agent.result == 'success' && + needs.test_Spark_App_With_Java_Agent.result == 'success' && + needs.test_Spark_AWS_SDK_V1_App_With_Java_Agent.result == 'success' }} + region: us-west-2 + secrets: + roleArn: ${{ secrets.METRICS_ROLE_ARN }} diff --git a/.github/workflows/e2e-tests-with-operator.yml b/.github/workflows/e2e-tests-with-operator.yml new file mode 100644 index 0000000000..5267198029 --- /dev/null +++ b/.github/workflows/e2e-tests-with-operator.yml @@ -0,0 +1,211 @@ +name: End to End Tests with Operator +on: + workflow_call: + inputs: + aws-region: + required: true + type: string + image_tag: + required: true + type: string + image_uri: + required: true + type: string + test_ref: + required: true + type: string + caller-workflow-name: + required: true + type: string + +env: + AWS_DEFAULT_REGION: ${{ inputs.aws-region }} + TESTING_FRAMEWORK_REPO: aws-observability/aws-otel-test-framework + NUM_BATCHES: 2 + DDB_TABLE_NAME: BatchTestCache + +permissions: + id-token: write + contents: read + +jobs: + # job to build testbatches for e2e integration test + build-sample-app: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: temurin + + # cache local patch outputs + - name: Cache local Maven repository + id: cache-local-maven-repo + uses: actions/cache@v3 + with: + path: | + ~/.m2/repository/io/opentelemetry/ + key: ${{ runner.os }}-maven-local-${{ hashFiles('.github/patches/opentelemetry-java*.patch') }} + + - name: Publish patched dependencies to maven local + uses: ./.github/actions/patch-dependencies + if: steps.cache-local-maven-repo.outputs.cache-hit != 'true' + with: + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + gpg_password: ${{ secrets.GPG_PASSPHRASE }} + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + + - name: Log in to AWS ECR + uses: docker/login-action@v3 + with: + registry: public.ecr.aws + + - name: Build and push Sample-Apps without Auto-Instrumentation Agent + uses: gradle/gradle-build-action@v2 + with: + arguments: jibBuildWithoutAgent + env: + COMMIT_HASH: ${{ inputs.image_tag }} + + get-testing-suites: + runs-on: ubuntu-latest + outputs: + test-case-batch-key: ${{ steps.set-batches.outputs.batch-keys }} + test-case-batch-value: ${{ steps.set-batches.outputs.batch-values }} + steps: + - name: Checkout Testing Framework repository + uses: actions/checkout@v4 + with: + repository: ${{ env.TESTING_FRAMEWORK_REPO }} + path: testing-framework + ref: ${{ inputs.test_ref }} + + - name: Checkout Java Instrumentation repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + path: aws-otel-java-instrumentation + + - name: Set up Go 1.x + uses: actions/setup-go@v4 + with: + go-version: '~1.18.9' + + - name: Create test batch key values + id: set-batches + working-directory: testing-framework/tools/batchTestGenerator + run: | + go build + ./batchTestGenerator github --testCaseFilePath=$GITHUB_WORKSPACE/aws-otel-java-instrumentation/.github/workflows/testcases.json --maxBatch=${{ env.NUM_BATCHES }} \ + --include=EKS_ADOT_OPERATOR,EKS_ADOT_OPERATOR_ARM64 + + - name: List testing suites + run: | + echo ${{ steps.set-batches.outputs.batch-keys }} + echo ${{ steps.set-batches.outputs.batch-values }} + + + # job to run the e2e integration tests + run-batch-job: + runs-on: ubuntu-latest + needs: [ build-sample-app, get-testing-suites ] + strategy: + fail-fast: false + matrix: ${{ fromJson(needs.get-testing-suites.outputs.test-case-batch-key) }} + + steps: + # required for versioning + - name: Checkout Java Instrumentation repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + path: aws-otel-java-instrumentation + + - name: Set up JDK 11 + uses: actions/setup-java@v4 + with: + distribution: 'zulu' + java-version: '11' + + - name: Set up terraform + uses: hashicorp/setup-terraform@v3 + with: + terraform_version: "~1.5" + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets.JAVA_INSTRUMENTATION_INTEG_TEST_ARN}} + aws-region: us-west-2 + # 4 hours + role-duration-seconds: 14400 + + - name: Checkout Testing Framework repository + uses: actions/checkout@v4 + with: + repository: ${{ env.TESTING_FRAMEWORK_REPO }} + path: testing-framework + ref: ${{ inputs.test_ref }} + + - name: create test-case-batch file + run: | + jsonStr='${{ needs.get-testing-suites.outputs.test-case-batch-value }}' + jsonStr="$(jq -r '.${{ matrix.BatchKey }} | join("\n")' <<< "${jsonStr}")" + echo "$jsonStr" >> testing-framework/terraform/test-case-batch + cat testing-framework/terraform/test-case-batch + + - name: Get TTL_DATE for cache + id: date + run: echo "ttldate=$(date -u -d "+7 days" +%s)" >> $GITHUB_OUTPUT + + - name: run tests + working-directory: testing-framework/terraform + run: | + export TTL_DATE=${{ steps.date.outputs.ttldate }} + export TF_VAR_java_auto_instrumentation_tag=${{ inputs.image_tag }} + export TF_VAR_java_auto_instrumentation_repository="${{ inputs.image_uri }}" + export DDB_BATCH_CACHE_SK=${{ inputs.image_tag }} + make execute-batch-test + + - name: output cache misses + if: ${{ failure() }} + working-directory: testing-framework/terraform + run: | + export DDB_BATCH_CACHE_SK=${{ inputs.image_tag }} + make checkCacheHits + + # This is here just in case workflow cancel + # We first kill terraform processes to ensure that no state + # file locks are being held from SIGTERMS dispatched in previous + # steps. + - name: Destroy resources + if: ${{ cancelled() }} + shell: bash {0} + working-directory: testing-framework/terraform + run: | + ps -ef | grep terraform | grep -v grep | awk '{print $2}' | xargs -n 1 kill + make terraformCleanup + + # publish status + publish-build-status: + needs: [ run-batch-job ] + if: ${{ always() }} + uses: ./.github/workflows/publish-status.yml + with: + namespace: 'ADOT/GitHubActions' + repository: ${{ github.repository }} + branch: ${{ github.ref_name }} + workflow: ${{ inputs.caller-workflow-name }} + success: ${{ needs.run-batch-job.result == 'success' }} + region: us-west-2 + secrets: + roleArn: ${{ secrets.METRICS_ROLE_ARN }} \ No newline at end of file diff --git a/.github/workflows/main-build.yml b/.github/workflows/main-build.yml index 805f7a3778..4e83624f06 100644 --- a/.github/workflows/main-build.yml +++ b/.github/workflows/main-build.yml @@ -6,12 +6,8 @@ on: - "release/v*" env: AWS_DEFAULT_REGION: us-east-1 - TEST_TAG: public.ecr.aws/aws-observability/adot-autoinstrumentation-java:test STAGING_ECR_REGISTRY: 611364707713.dkr.ecr.us-west-2.amazonaws.com STAGING_ECR_REPOSITORY: adot-autoinstrumentation-java-operator-staging - TESTING_FRAMEWORK_REPO: aws-observability/aws-otel-test-framework - NUM_BATCHES: 2 - DDB_TABLE_NAME: BatchTestCache concurrency: group: java-agent-main-build @@ -54,7 +50,7 @@ jobs: runs-on: ubuntu-latest outputs: java_agent_tag: ${{ steps.java_agent_versioning.outputs.STAGING_TAG}} - staging-image-name: ${{ steps.imageNameOutput.outputs.imageName }} + staging-image: ${{ steps.imageOutput.outputs.stagingImage }} steps: - uses: actions/checkout@v4 with: @@ -101,52 +97,11 @@ jobs: GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} - - name: Pull base image of Contract Tests Sample Apps - run: docker pull public.ecr.aws/docker/library/amazoncorretto:17-alpine - - - name: Run contract tests - uses: gradle/gradle-build-action@v2 - with: - arguments: contractTests -PlocalDocker=true - - name: Get current version shell: bash run: | echo "ADOT_JAVA_VERSION=$(./gradlew printVersion -q )" >> $GITHUB_ENV - - name: Build and push Sample-Apps without Auto-Instrumentation Agent - uses: gradle/gradle-build-action@v2 - with: - arguments: jibBuildWithoutAgent - env: - COMMIT_HASH: ${{ github.sha }} - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Build image for testing - uses: docker/build-push-action@v5 - with: - push: false - build-args: "ADOT_JAVA_VERSION=${{ env.ADOT_JAVA_VERSION }}" - context: . - platforms: linux/amd64 - tags: ${{ env.TEST_TAG }} - load: true - - - name: Test docker image - shell: bash - run: .github/scripts/test-adot-javaagent-image.sh "${{ env.TEST_TAG }}" "${{ env.ADOT_JAVA_VERSION }}" - - - name: Upload to GitHub Actions - uses: actions/upload-artifact@v3 - with: - name: aws-opentelemetry-agent.jar - path: otelagent/build/libs/aws-opentelemetry-agent-*.jar - - name: Get ADOT_JAVA_AGENT Image Tag id: java_agent_versioning run: | @@ -154,32 +109,24 @@ jobs: java_agent_tag=${{ env.ADOT_JAVA_VERSION }}-$shortsha echo "STAGING_TAG=$java_agent_tag" >> $GITHUB_OUTPUT - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - role-to-assume: ${{ secrets.JAVA_INSTRUMENTATION_SNAPSHOT_ECR }} - aws-region: us-west-2 + - name: Set image to output + id: imageOutput + run: echo "stagingImage=${{ env.STAGING_ECR_REGISTRY }}/${{ env.STAGING_ECR_REPOSITORY }}:${{ steps.java_agent_versioning.outputs.STAGING_TAG }}" >> $GITHUB_OUTPUT - - name: Login to private staging ecr - uses: docker/login-action@v3 + - name: Build and Push Java Agent Image and Execute cpUtility Tests + uses: ./.github/workflows/build-and-push-image-with-cpUtility-test.yml + secrets: inherit with: - registry: ${{ env.STAGING_ECR_REGISTRY }} - env: - AWS_REGION: us-west-2 + aws-region: us-west-2 + image_uri_with_tag: ${{ steps.imageOutput.outputs.stagingImage }} + image_registry: {{ env.STAGING_ECR_REGISTRY }} + adot-java-version: {{ env.ADOT_JAVA_VERSION }} - - name: Build and push staging image for e2e integration test - uses: docker/build-push-action@v5 + - name: Upload to GitHub Actions + uses: actions/upload-artifact@v3 with: - push: true - build-args: "ADOT_JAVA_VERSION=${{ env.ADOT_JAVA_VERSION }}" - context: . - platforms: linux/amd64,linux/arm64 - tags: | - ${{ env.STAGING_ECR_REGISTRY }}/${{ env.STAGING_ECR_REPOSITORY }}:${{ steps.java_agent_versioning.outputs.STAGING_TAG }} - - - name: Set image name to output - id: imageNameOutput - run: echo "imageName=${{ env.STAGING_ECR_REGISTRY }}/${{ env.STAGING_ECR_REPOSITORY }}:${{ steps.java_agent_versioning.outputs.STAGING_TAG }}" >> "$GITHUB_OUTPUT" + name: aws-opentelemetry-agent.jar + path: otelagent/build/libs/aws-opentelemetry-agent-*.jar create-test-ref: runs-on: ubuntu-latest @@ -195,264 +142,41 @@ jobs: echo "ref=terraform" >> $GITHUB_OUTPUT fi - # job to build testbatches for e2e integration test - get-testing-suites: - runs-on: ubuntu-latest - needs: [build, create-test-ref] - outputs: - test-case-batch-key: ${{ steps.set-batches.outputs.batch-keys }} - test-case-batch-value: ${{ steps.set-batches.outputs.batch-values }} - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - repository: ${{ env.TESTING_FRAMEWORK_REPO }} - path: testing-framework - ref: ${{ needs.create-test-ref.outputs.testRef }} - - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - path: aws-otel-java-instrumentation - - - name: Set up Go 1.x - uses: actions/setup-go@v4 - with: - go-version: '~1.18.9' - - - name: Create test batch key values - id: set-batches - run: | - cd testing-framework/tools/batchTestGenerator - go build - ./batchTestGenerator github --testCaseFilePath=$GITHUB_WORKSPACE/aws-otel-java-instrumentation/.github/workflows/testcases.json --maxBatch=${{ env.NUM_BATCHES }} \ - --include=EKS_ADOT_OPERATOR,EKS_ADOT_OPERATOR_ARM64 - - - name: List testing suites - run: | - echo ${{ steps.set-batches.outputs.batch-keys }} - echo ${{ steps.set-batches.outputs.batch-values }} - - # job to run the e2e integration tests - run-batch-job: - runs-on: ubuntu-latest - needs: [build, create-test-ref, get-testing-suites] - strategy: - fail-fast: false - matrix: ${{ fromJson(needs.get-testing-suites.outputs.test-case-batch-key) }} - - steps: - # required for versioning - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - path: aws-otel-java-instrumentation - - - name: Set up JDK 11 - uses: actions/setup-java@v4 - with: - distribution: 'zulu' - java-version: '11' - - - name: Set up terraform - uses: hashicorp/setup-terraform@v3 - with: - terraform_version: "~1.5" - - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - role-to-assume: ${{ secrets.JAVA_INSTRUMENTATION_INTEG_TEST_ARN}} - aws-region: us-west-2 - # 4 hours - role-duration-seconds: 14400 - - - name: Checkout testing framework - uses: actions/checkout@v4 - with: - repository: ${{ env.TESTING_FRAMEWORK_REPO }} - path: testing-framework - ref: ${{ needs.create-test-ref.outputs.testRef }} - - - name: create test-case-batch file - run: | - jsonStr='${{ needs.get-testing-suites.outputs.test-case-batch-value }}' - jsonStr="$(jq -r '.${{ matrix.BatchKey }} | join("\n")' <<< "${jsonStr}")" - echo "$jsonStr" >> testing-framework/terraform/test-case-batch - cat testing-framework/terraform/test-case-batch - - - name: Get TTL_DATE for cache - id: date - run: echo "ttldate=$(date -u -d "+7 days" +%s)" >> $GITHUB_OUTPUT - - - name: run tests - run: | - export TTL_DATE=${{ steps.date.outputs.ttldate }} - export TF_VAR_java_auto_instrumentation_tag=${{ needs.build.outputs.java_agent_tag }} - export TF_VAR_java_auto_instrumentation_repository="${{ env.STAGING_ECR_REGISTRY }}/${{ env.STAGING_ECR_REPOSITORY }}" - export DDB_BATCH_CACHE_SK=${{ needs.build.outputs.java_agent_tag }} - cd testing-framework/terraform - make execute-batch-test - - - name: output cache misses - if: ${{ failure() }} - run: | - export DDB_BATCH_CACHE_SK=${{ needs.build.outputs.java_agent_tag }} - cd testing-framework/terraform - make checkCacheHits - - # This is here just in case workflow cancel - # We first kill terraform processes to ensure that no state - # file locks are being held from SIGTERMS dispatched in previous - # steps. - - name: Destroy resources - if: ${{ cancelled() }} - shell: bash {0} - run: | - ps -ef | grep terraform | grep -v grep | awk '{print $2}' | xargs -n 1 kill - cd testing-framework/terraform - make terraformCleanup - + e2e-operator-test: + concurrency: + group: e2e-adot-agent-operator-test + cancel-in-progress: false + needs: [ build, create-test-ref ] + uses: ./.github/workflows/e2e-tests-with-operator.yml + secrets: inherit + with: + aws-region: {{ env.AWS_DEFAULT_REGION }} + image_tag: ${{ needs.build.outputs.java_agent_tag }} + image_uri: ${{ env.STAGING_ECR_REGISTRY }}/${{ env.STAGING_ECR_REPOSITORY }} + test_ref: ${{ needs.create-test-ref.outputs.testRef }} + caller-workflow-name: 'main-build' - build_Images_For_Testing_Sample_App_With_Java_Agent: - runs-on: ubuntu-latest + # E2E tests where SampleApp has Java Agent + e2e-test: needs: build - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - uses: actions/setup-java@v4 - with: - java-version: 17 - distribution: temurin - - # cache local patch outputs - - name: Cache local Maven repository - uses: actions/cache@v3 - with: - path: | - ~/.m2/repository/io/opentelemetry/ - key: ${{ runner.os }}-maven-local-${{ hashFiles('.github/patches/opentelemetry-java*.patch') }} - - - uses: gradle/wrapper-validation-action@v1 - - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - - - name: Log in to AWS ECR - uses: docker/login-action@v3 - with: - registry: public.ecr.aws - - - name: Build and push agent and testing docker images with Gradle - uses: gradle/gradle-build-action@v2 - with: - arguments: jib - env: - COMMIT_HASH: ${{ github.sha }} - - - uses: codecov/codecov-action@v3 - - test_Spring_App_With_Java_Agent: - name: Test Spring App with AWS OTel Java agent - needs: build_Images_For_Testing_Sample_App_With_Java_Agent - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-java@v4 - with: - java-version: 17 - distribution: 'temurin' - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: Log in to AWS ECR - uses: docker/login-action@v3 - with: - registry: public.ecr.aws - - - name: Run test containers - run: docker-compose up --abort-on-container-exit - working-directory: .github/collector - env: - INSTANCE_ID: ${{ github.run_id }}-${{ github.run_number }} - LISTEN_ADDRESS: 0.0.0.0:8080 - APP_IMAGE: public.ecr.aws/aws-otel-test/aws-otel-java-springboot:${{ github.sha }} - VALIDATOR_COMMAND: -c springboot-otel-trace-metric-validation.yml --endpoint http://app:8080 --metric-namespace aws-otel-integ-test -t ${{ github.run_id }}-${{ github.run_number }} - - test_Spark_App_With_Java_Agent: - name: Test Spark App with AWS OTel Java agent - needs: build_Images_For_Testing_Sample_App_With_Java_Agent - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-java@v4 - with: - java-version: 17 - distribution: 'temurin' - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: Log in to AWS ECR - uses: docker/login-action@v3 - with: - registry: public.ecr.aws - - - name: Run test containers - run: docker-compose up --abort-on-container-exit - working-directory: .github/collector - env: - INSTANCE_ID: ${{ github.run_id }}-${{ github.run_number }} - LISTEN_ADDRESS: 0.0.0.0:4567 - APP_IMAGE: public.ecr.aws/aws-otel-test/aws-otel-java-spark:${{ github.sha }} - VALIDATOR_COMMAND: -c spark-otel-trace-metric-validation.yml --endpoint http://app:4567 --metric-namespace aws-otel-integ-test -t ${{ github.run_id }}-${{ github.run_number }} - - test_Spark_AWS_SDK_V1_App_With_Java_Agent: - name: Test Spark App (AWS SDK v1) with AWS OTel Java agent - needs: build_Images_For_Testing_Sample_App_With_Java_Agent - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-java@v4 - with: - java-version: 17 - distribution: 'temurin' - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} - - name: Log in to AWS ECR - uses: docker/login-action@v3 - with: - registry: public.ecr.aws + uses: ./.github/workflows/e2e-tests-app-with-java-agent.yml + secrets: inherit + with: + aws-region: {{ env.AWS_DEFAULT_REGION }} + image_tag: ${{ github.sha }} + caller-workflow-name: 'main-build' - - name: Run test containers - run: docker-compose up --abort-on-container-exit - working-directory: .github/collector - env: - INSTANCE_ID: ${{ github.run_id }}-${{ github.run_number }} - LISTEN_ADDRESS: 0.0.0.0:4567 - APP_IMAGE: public.ecr.aws/aws-otel-test/aws-otel-java-spark-awssdkv1:${{ github.sha }} - VALIDATOR_COMMAND: -c spark-otel-trace-metric-validation.yml --endpoint http://app:4567 --metric-namespace aws-otel-integ-test -t ${{ github.run_id }}-${{ github.run_number }} + # AppSignals Contract Tests + contract-tests: + needs: build + uses: ./.github/workflows/contract-tests.yml + secrets: inherit + with: + aws-region: {{ env.AWS_DEFAULT_REGION }} + caller-workflow-name: 'main-build' - e2e-test: + # AppSignals specific e2e tests + appsignals-e2e-test: concurrency: group: e2e-adot-test cancel-in-progress: false @@ -460,13 +184,13 @@ jobs: uses: ./.github/workflows/appsignals-e2e-eks-test.yml secrets: inherit with: - aws-region: us-east-1 + aws-region: {{ env.AWS_DEFAULT_REGION }} test-cluster-name: "e2e-adot-test" - appsignals-adot-image-name: ${{ needs.build.outputs.staging-image-name }} + appsignals-adot-image-name: ${{ needs.build.outputs.staging-image }} caller-workflow-name: 'main-build' publish-build-status: - needs: [test_Spring_App_With_Java_Agent, test_Spark_App_With_Java_Agent, test_Spark_AWS_SDK_V1_App_With_Java_Agent, run-batch-job] + needs: [ build ] if: ${{ always() }} uses: ./.github/workflows/publish-status.yml with: @@ -474,10 +198,7 @@ jobs: repository: ${{ github.repository }} branch: ${{ github.ref_name }} workflow: main-build - success: ${{ needs.test_Spring_App_With_Java_Agent.result == 'success' && - needs.test_Spark_App_With_Java_Agent.result == 'success' && - needs.test_Spark_AWS_SDK_V1_App_With_Java_Agent.result == 'success' && - needs.run-batch-job.result == 'success' }} + success: ${{ needs.build.result == 'success' }} region: us-west-2 secrets: roleArn: ${{ secrets.METRICS_ROLE_ARN }} diff --git a/.github/workflows/nightly-upstream-snapshot-build.yml b/.github/workflows/nightly-upstream-snapshot-build.yml index 4f78c4135b..88a07ab715 100644 --- a/.github/workflows/nightly-upstream-snapshot-build.yml +++ b/.github/workflows/nightly-upstream-snapshot-build.yml @@ -6,7 +6,8 @@ on: env: AWS_DEFAULT_REGION: us-east-1 - IMAGE_TAG: 611364707713.dkr.ecr.us-west-2.amazonaws.com/adot-autoinstrumentation-java-nightly:nightly + IMAGE_REGISTRY: 611364707713.dkr.ecr.us-west-2.amazonaws.com + IMAGE_NAME: adot-autoinstrumentation-java-nightly permissions: id-token: write @@ -16,15 +17,18 @@ jobs: build: runs-on: ubuntu-latest outputs: - release-candidate-image: ${{ steps.imageNameOutput.outputs.imageName }} + time_stamp_tag: ${{ steps.generate_time_stamp.outputs.nowTimeTag}} + release-candidate-image: ${{ steps.imageOutput.outputs.rcImage }} steps: - uses: actions/checkout@v4 with: fetch-depth: 0 + - uses: actions/setup-java@v4 with: java-version: 17 distribution: 'temurin' + - uses: gradle/wrapper-validation-action@v1 - name: Configure AWS Credentials @@ -38,68 +42,53 @@ jobs: with: registry: public.ecr.aws - - name: Pull base image of Contract Tests Sample Apps - run: docker pull public.ecr.aws/docker/library/amazoncorretto:17-alpine + # cache local patch outputs + - name: Cache local Maven repository + id: cache-local-maven-repo + uses: actions/cache@v3 + with: + path: | + ~/.m2/repository/io/opentelemetry/ + key: ${{ runner.os }}-maven-local-${{ hashFiles('.github/patches/opentelemetry-java*.patch') }} + + - name: Publish patched dependencies to maven local + uses: ./.github/actions/patch-dependencies + if: steps.cache-local-maven-repo.outputs.cache-hit != 'true' + with: + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + gpg_password: ${{ secrets.GPG_PASSPHRASE }} - name: Build snapshot with Gradle uses: gradle/gradle-build-action@v2 with: - arguments: build contractTests --stacktrace -PenableCoverage=true -PtestUpstreamSnapshots=true -PlocalDocker=true + arguments: build --stacktrace -PenableCoverage=true -PtestUpstreamSnapshots=true env: PUBLISH_USERNAME: ${{ secrets.PUBLISH_USERNAME }} PUBLISH_PASSWORD: ${{ secrets.PUBLISH_PASSWORD }} GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - role-to-assume: ${{ secrets.JAVA_INSTRUMENTATION_SNAPSHOT_ECR }} - aws-region: us-west-2 - - - name: Login to private aws ecr - uses: docker/login-action@v3 - with: - registry: 611364707713.dkr.ecr.us-west-2.amazonaws.com - - name: Get current version shell: bash run: | echo "ADOT_JAVA_VERSION=$(./gradlew printVersion -q -PtestUpstreamSnapshots=true )" >> $GITHUB_ENV - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 + - name: Generate timestamp for image tag + id: generate_time_stamp + run: echo "nowTimeTag=$(date +'%Y-%m-%dT%H-%M-%S')" >> $$GITHUB_OUTPUT - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 + - name: Set image to output + id: imageOutput + run: echo "rcImage=${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.generate_time_stamp.outputs.nowTimeTag }}" >> $GITHUB_OUTPUT - - name: Build image for testing - uses: docker/build-push-action@v5 + - name: Build and Push Java Agent Image and Execute cpUtility Tests + uses: ./.github/workflows/build-and-push-image-with-cpUtility-test.yml + secrets: inherit with: - push: false - build-args: "ADOT_JAVA_VERSION=${{ env.ADOT_JAVA_VERSION }}" - context: . - platforms: linux/amd64 - tags: ${{ env.IMAGE_TAG }} - load: true - - - name: Test docker image - shell: bash - run: .github/scripts/test-adot-javaagent-image.sh "${{ env.IMAGE_TAG }}" "${{ env.ADOT_JAVA_VERSION }}" - - - name: Build and push image - uses: docker/build-push-action@v5 - with: - push: true - build-args: "ADOT_JAVA_VERSION=${{ env.ADOT_JAVA_VERSION }}" - context: . - platforms: linux/amd64,linux/arm64 - tags: | - ${{ env.IMAGE_TAG }} - - - name: Set image name to output - id: imageNameOutput - run: echo "imageName=${{ env.IMAGE_NAME }}" >> "$GITHUB_OUTPUT" + aws-region: us-west-2 + image_uri_with_tag: ${{ steps.imageOutput.outputs.rcImage }} + image_registry: {{ env.IMAGE_REGISTRY }} + adot-java-version: {{ env.ADOT_JAVA_VERSION }} - name: Upload to GitHub Actions uses: actions/upload-artifact@v3 @@ -107,7 +96,41 @@ jobs: name: aws-opentelemetry-agent.jar path: otelagent/build/libs/aws-opentelemetry-agent-*.jar + e2e-operator-test: + concurrency: + group: e2e-adot-agent-operator-test + cancel-in-progress: false + needs: build + uses: ./.github/workflows/e2e-tests-with-operator.yml + secrets: inherit + with: + aws-region: ${{ env.AWS_DEFAULT_REGION }} + image_tag: ${{ needs.build.outputs.time_stamp_tag }} + image_uri: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }} + test_ref: 'terraform' + caller-workflow-name: 'nightly-upstream-snapshot-build' + + # E2E tests where SampleApp has Java Agent e2e-test: + needs: build + uses: ./.github/workflows/e2e-tests-app-with-java-agent.yml + secrets: inherit + with: + aws-region: ${{ env.AWS_DEFAULT_REGION }} + image_tag: ${{ needs.build.outputs.time_stamp_tag }} + caller-workflow-name: 'nightly-upstream-snapshot-build' + + # AppSignals Contract Tests + contract-tests: + needs: build + uses: ./.github/workflows/contract-tests.yml + secrets: inherit + with: + aws-region: {{ env.AWS_DEFAULT_REGION }} + caller-workflow-name: 'nightly-upstream-snapshot-build' + + # AppSignals specific e2e tests + appsignals-e2e-test: concurrency: group: e2e-adot-test cancel-in-progress: false @@ -115,13 +138,13 @@ jobs: uses: ./.github/workflows/appsignals-e2e-eks-test.yml secrets: inherit with: - aws-region: us-east-1 + aws-region: {{ env.AWS_DEFAULT_REGION }} test-cluster-name: "e2e-adot-test" appsignals-adot-image-name: ${{ needs.build.outputs.release-candidate-image }} caller-workflow-name: 'nightly-upstream-snapshot-build' publish-build-status: - needs: [build] + needs: [ build ] if: ${{ always() }} uses: ./.github/workflows/publish-status.yml with: @@ -129,7 +152,7 @@ jobs: repository: ${{ github.repository }} branch: ${{ github.ref_name }} workflow: nightly-upstream-snapshot-build - success: ${{ needs.build.result == 'success' }} + success: ${{ needs.build.result == 'success' }} region: us-west-2 secrets: roleArn: ${{ secrets.METRICS_ROLE_ARN }}