|
| 1 | +name: Java Layer Integration Test |
| 2 | +on: |
| 3 | + workflow_call: |
| 4 | + inputs: |
| 5 | + caller-workflow-name: |
| 6 | + required: true |
| 7 | + type: string |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +concurrency: |
| 11 | + group: main-build-java-${{ github.ref_name }} |
| 12 | + cancel-in-progress: true |
| 13 | + |
| 14 | +permissions: |
| 15 | + id-token: write |
| 16 | + contents: read |
| 17 | + |
| 18 | +jobs: |
| 19 | + integration-test: |
| 20 | + runs-on: ubuntu-20.04 |
| 21 | + name: java-${{ matrix.sample-app }}-${{ matrix.instrumentation-type }}-${{ matrix.architecture }}-${{matrix.confmap}} |
| 22 | + strategy: |
| 23 | + fail-fast: false |
| 24 | + matrix: |
| 25 | + architecture: [ amd64, arm64 ] |
| 26 | + runtime: [java17, java11, java8.al2] |
| 27 | + sample-app: [ aws-sdk, okhttp ] |
| 28 | + instrumentation-type: [ wrapper ] |
| 29 | + confmap: [ "noop" ] |
| 30 | + include: |
| 31 | + - sample-app: aws-sdk |
| 32 | + instrumentation-type: agent |
| 33 | + architecture: amd64 |
| 34 | + confmap: noop |
| 35 | + runtime: java17 |
| 36 | + - sample-app: aws-sdk |
| 37 | + instrumentation-type: agent |
| 38 | + architecture: amd64 |
| 39 | + confmap: noop |
| 40 | + runtime: java11 |
| 41 | + - sample-app: aws-sdk |
| 42 | + instrumentation-type: agent |
| 43 | + architecture: amd64 |
| 44 | + confmap: noop |
| 45 | + runtime: java8.al2 |
| 46 | + - sample-app: aws-sdk |
| 47 | + instrumentation-type: agent |
| 48 | + architecture: arm64 |
| 49 | + confmap: noop |
| 50 | + runtime: java17 |
| 51 | + - sample-app: aws-sdk |
| 52 | + instrumentation-type: agent |
| 53 | + architecture: arm64 |
| 54 | + confmap: noop |
| 55 | + runtime: java11 |
| 56 | + - sample-app: aws-sdk |
| 57 | + instrumentation-type: agent |
| 58 | + architecture: arm64 |
| 59 | + confmap: noop |
| 60 | + runtime: java8.al2 |
| 61 | + - sample-app: aws-sdk |
| 62 | + instrumentation-type: agent-confmap |
| 63 | + architecture: amd64 |
| 64 | + confmap: s3 |
| 65 | + runtime: java11 |
| 66 | + - sample-app: aws-sdk |
| 67 | + instrumentation-type: agent-confmap |
| 68 | + architecture: arm64 |
| 69 | + confmap: s3 |
| 70 | + runtime: java11 |
| 71 | + - sample-app: aws-sdk |
| 72 | + instrumentation-type: agent-confmap |
| 73 | + architecture: amd64 |
| 74 | + confmap: http |
| 75 | + runtime: java11 |
| 76 | + - sample-app: aws-sdk |
| 77 | + instrumentation-type: agent-confmap |
| 78 | + architecture: arm64 |
| 79 | + confmap: http |
| 80 | + runtime: java11 |
| 81 | + - sample-app: aws-sdk |
| 82 | + instrumentation-type: agent-confmap |
| 83 | + architecture: amd64 |
| 84 | + confmap: https |
| 85 | + runtime: java11 |
| 86 | + - sample-app: aws-sdk |
| 87 | + instrumentation-type: agent-confmap |
| 88 | + architecture: arm64 |
| 89 | + confmap: https |
| 90 | + runtime: java11 |
| 91 | + |
| 92 | + steps: |
| 93 | + - uses: actions/checkout@v4 |
| 94 | + with: |
| 95 | + submodules: recursive |
| 96 | + - uses: actions/setup-go@v5 |
| 97 | + with: |
| 98 | + go-version: '~1.21.10' |
| 99 | + check-latest: true |
| 100 | + - uses: actions/setup-java@v4 |
| 101 | + with: |
| 102 | + distribution: corretto |
| 103 | + java-version: '17' |
| 104 | + - name: Cache (Java) |
| 105 | + uses: actions/cache@v3 |
| 106 | + with: |
| 107 | + path: | |
| 108 | + ~/go/pkg/mod |
| 109 | + ~/.gradle/caches |
| 110 | + ~/.gradle/wrapper |
| 111 | + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}-go-${{ hashFiles('**/go.sum') }} |
| 112 | + restore-keys: | |
| 113 | + ${{ runner.os }}-gradle- |
| 114 | +
|
| 115 | + - uses: aws-actions/[email protected] |
| 116 | + with: |
| 117 | + role-to-assume: ${{ secrets.INTEG_TEST_LAMBDA_ROLE_ARN }} |
| 118 | + role-duration-seconds: 7200 |
| 119 | + aws-region: us-east-1 |
| 120 | + - name: Generate UUID |
| 121 | + id: generate-uuid |
| 122 | + run: | |
| 123 | + UUID=$(uuidgen | cut -c1-4) |
| 124 | + echo "uuid=$UUID" >> $GITHUB_OUTPUT |
| 125 | + - name: Patch ADOT |
| 126 | + run: ./patch-upstream.sh |
| 127 | + - name: Build layers / functions |
| 128 | + run: GOARCH=${{ matrix.architecture }} ./build.sh ${{ matrix.architecture }} |
| 129 | + working-directory: java |
| 130 | + - name: Get Lambda Layer amd64 architecture value |
| 131 | + if: ${{ matrix.architecture == 'amd64' }} |
| 132 | + run: echo LAMBDA_FUNCTION_ARCH=x86_64 | tee --append $GITHUB_ENV |
| 133 | + - name: Get Lambda Layer arm64 architecture value |
| 134 | + if: ${{ matrix.architecture == 'arm64' }} |
| 135 | + run: echo LAMBDA_FUNCTION_ARCH=arm64 | tee --append $GITHUB_ENV |
| 136 | + - name: Get terraform directory |
| 137 | + run: | |
| 138 | + echo TERRAFORM_DIRECTORY=java/integration-tests/${{ matrix.sample-app }}/${{ matrix.instrumentation-type }} | |
| 139 | + tee --append $GITHUB_ENV |
| 140 | + - uses: hashicorp/setup-terraform@v2 |
| 141 | + - name: Initialize terraform |
| 142 | + run: terraform init |
| 143 | + working-directory: ${{ env.TERRAFORM_DIRECTORY }} |
| 144 | + - name: Get terraform Lambda function name |
| 145 | + run: | |
| 146 | + echo TERRAFORM_LAMBDA_FUNCTION_NAME=lambda-java-${{ matrix.sample-app }}-${{ matrix.instrumentation-type }}-${{ matrix.confmap }}-${{ matrix.architecture }}-${{ steps.generate-uuid.outputs.uuid }} | |
| 147 | + tee --append $GITHUB_ENV |
| 148 | + - name: Apply terraform |
| 149 | + run: terraform apply -auto-approve |
| 150 | + working-directory: ${{ env.TERRAFORM_DIRECTORY }} |
| 151 | + env: |
| 152 | + TF_VAR_sdk_layer_name: opentelemetry-java-${{ matrix.sample-app }}-${{ matrix.instrumentation-type }}-${{ matrix.architecture }}-${{ github.run_id }} |
| 153 | + TF_VAR_function_name: ${{ env.TERRAFORM_LAMBDA_FUNCTION_NAME }} |
| 154 | + TF_VAR_architecture: ${{ env.LAMBDA_FUNCTION_ARCH }} |
| 155 | + TF_VAR_configuration_source: ${{ matrix.confmap }} |
| 156 | + TF_VAR_runtime: ${{ matrix.runtime }} |
| 157 | + - name: Extract endpoint |
| 158 | + id: extract-endpoint |
| 159 | + run: terraform output -raw api-gateway-url |
| 160 | + working-directory: ${{ env.TERRAFORM_DIRECTORY }} |
| 161 | + - name: Extract AMP endpoint |
| 162 | + id: extract-amp-endpoint |
| 163 | + if: ${{ matrix.sample-app == 'aws-sdk' && startsWith(matrix.instrumentation-type, 'agent') }} |
| 164 | + run: terraform output -raw amp_endpoint |
| 165 | + working-directory: ${{ env.TERRAFORM_DIRECTORY }} |
| 166 | + - name: Extract SDK layer arn |
| 167 | + id: extract-sdk-layer-arn |
| 168 | + run: terraform output -raw sdk_layer_arn |
| 169 | + working-directory: ${{ env.TERRAFORM_DIRECTORY }} |
| 170 | + - name: Output annotations |
| 171 | + run: | |
| 172 | + echo "::warning::Function: ${{ env.TERRAFORM_LAMBDA_FUNCTION_NAME }}" |
| 173 | + echo "::warning::SDK Layer ARN: ${{ steps.extract-sdk-layer-arn.outputs.stdout }}" |
| 174 | + - name: Send request to endpoint |
| 175 | + run: curl -sS ${{ steps.extract-endpoint.outputs.stdout }} |
| 176 | + - name: Checkout test framework |
| 177 | + uses: actions/checkout@v4 |
| 178 | + with: |
| 179 | + repository: aws-observability/aws-otel-test-framework |
| 180 | + path: test-framework |
| 181 | + - name: validate trace sample |
| 182 | + run: | |
| 183 | + cp adot/utils/expected-templates/java-${{ matrix.sample-app }}-${{ matrix.instrumentation-type }}.json \ |
| 184 | + test-framework/validator/src/main/resources/expected-data-template/lambdaExpectedTrace.mustache |
| 185 | + cd test-framework |
| 186 | + ./gradlew :validator:run --args="-c default-lambda-validation.yml --endpoint ${{ steps.extract-endpoint.outputs.stdout }} --region $AWS_REGION" |
| 187 | + - name: validate java agent metric sample |
| 188 | + if: ${{ matrix.sample-app == 'aws-sdk' && startsWith(matrix.instrumentation-type, 'agent') }} |
| 189 | + run: | |
| 190 | + cp adot/utils/expected-templates/java-${{ matrix.sample-app }}-${{ matrix.instrumentation-type }}-metric.json \ |
| 191 | + test-framework/validator/src/main/resources/expected-data-template/ampExpectedMetric.mustache |
| 192 | + cd test-framework |
| 193 | + ./gradlew :validator:run --args="-c prometheus-static-metric-validation.yml --cortex-instance-endpoint ${{ steps.extract-amp-endpoint.outputs.stdout }} --region $AWS_REGION" |
| 194 | + - name: Destroy terraform |
| 195 | + if: always() |
| 196 | + run: terraform destroy -auto-approve |
| 197 | + working-directory: ${{ env.TERRAFORM_DIRECTORY }} |
| 198 | + env: |
| 199 | + TF_VAR_architecture: ${{ env.LAMBDA_FUNCTION_ARCH }} |
0 commit comments