diff --git a/.github/actions/codebuild-authorize-runner-ip/action.yml b/.github/actions/codebuild-authorize-runner-ip/action.yml new file mode 100644 index 000000000..fe9109673 --- /dev/null +++ b/.github/actions/codebuild-authorize-runner-ip/action.yml @@ -0,0 +1,73 @@ +# Needs actions/checkout earlier in the job and AWS credentials in the environment. The caller +# uploads the ip-file output as artifact runner-ip- for codebuild-revoke-runner-ips. +name: 'Authorize the CodeBuild runner egress IP address' +description: 'Discovers this job''s egress IPv4 address, opens TCP 3306 and 5432 from it in the default security group, and writes it to a file.' +inputs: + id: + description: 'Identifier unique to this job within the run. Names the file runner-ip-.txt; use it in the artifact name runner-ip- as well.' + required: true +outputs: + ipv4: + description: 'The egress IPv4 address that was authorized.' + value: ${{ steps.ip.outputs.ipv4 }} + ip-file: + description: 'Path of the file holding the address, to upload as artifact runner-ip-.' + value: ${{ steps.ip.outputs.ip-file }} +runs: + using: 'composite' + steps: + - name: 'Discover this job''s egress IP address' + id: ip + shell: bash + env: + RUNNER_IP_FILE: ${{ runner.temp }}/runner-ip-${{ inputs.id }}.txt + run: | + if ! response=$(curl -fsS --max-time 10 https://checkip.amazonaws.com); then + echo "::error::checkip.amazonaws.com did not answer, so this job's egress IP address is unknown and the test databases would be unreachable." + exit 1 + fi + ipv4=$(printf '%s' "$response" | tr -d '[:space:]') + octet='(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])' + ipv4_re="^($octet\.){3}$octet\$" + if ! [[ $ipv4 =~ $ipv4_re ]]; then + echo "::error::checkip.amazonaws.com did not return a dotted IPv4 address, so this job's egress IP address is unknown." + exit 1 + fi + echo "Runner egress IP address: $ipv4" + echo "ipv4=$ipv4" >> "$GITHUB_OUTPUT" + echo "$ipv4" > "$RUNNER_IP_FILE" + echo "ip-file=$RUNNER_IP_FILE" >> "$GITHUB_OUTPUT" + + # Only TCP 3306 and 5432 are opened, the ports the harness reaches (TestEnvironment.getPort()). + # Keep the description EXACTLY "Test run at " plus an ISO-8601 instant: + # AuroraTestUtility.securityGroupRulesCleanUp() calls Instant.parse on it + # and revokes the rule after 12 hours if revoke-runner-ip never ran. + # Appending anything opts the rule out. + # On InvalidPermission.Duplicate (shared address) the description is refreshed so the sweep keeps the rule. + # If 3306 succeeds and 5432 fails, nothing is recorded; the sweep reclaims it. + - name: 'Authorize this job''s egress IP address' + shell: bash + env: + RUNNER_IPV4: ${{ steps.ip.outputs.ipv4 }} + run: | + ipv4=$RUNNER_IPV4 + description="Test run at $(date -u +%Y-%m-%dT%H:%M:%SZ)" + for port in 3306 5432; do + permissions=$(printf \ + '[{"IpProtocol":"tcp","FromPort":%s,"ToPort":%s,"IpRanges":[{"CidrIp":"%s/32","Description":"%s"}]}]' \ + "$port" "$port" "$ipv4" "$description") + if output=$(aws ec2 authorize-security-group-ingress \ + --group-name default --ip-permissions "$permissions" 2>&1); then + echo "Authorized TCP $port from $ipv4/32." + elif [ "${output#*InvalidPermission.Duplicate}" != "$output" ]; then + if ! output=$(aws ec2 update-security-group-rule-descriptions-ingress \ + --group-name default --ip-permissions "$permissions" 2>&1); then + echo "$output" + exit 1 + fi + echo "TCP $port from $ipv4/32 was already authorized; refreshed its description." + else + echo "$output" + exit 1 + fi + done diff --git a/.github/actions/codebuild-revoke-runner-ips/action.yml b/.github/actions/codebuild-revoke-runner-ips/action.yml new file mode 100644 index 000000000..4397bc712 --- /dev/null +++ b/.github/actions/codebuild-revoke-runner-ips/action.yml @@ -0,0 +1,50 @@ +# Needs actions/checkout, AWS credentials, and the runner-ip-* artifacts downloaded (merge-multiple) into ip-dir. +name: 'Revoke the CodeBuild runner egress IP addresses' +description: 'Revokes TCP 3306 and 5432 for every address recorded in ip-dir. Missing rules and an empty directory are not errors.' +inputs: + ip-dir: + description: 'Directory holding the downloaded runner-ip-*.txt files.' + required: true +runs: + using: 'composite' + steps: + - name: 'Revoke the recorded egress IP addresses' + shell: bash + env: + RUNNER_IP_DIR: ${{ inputs.ip-dir }} + run: | + shopt -s nullglob + files=("$RUNNER_IP_DIR"/runner-ip-*.txt) + if [ ${#files[@]} -eq 0 ]; then + echo "No matrix job recorded an authorized address; nothing to revoke." + exit 0 + fi + octet='(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])' + ipv4_re="^($octet\.){3}$octet\$" + while IFS= read -r ipv4; do + if ! [[ $ipv4 =~ $ipv4_re ]]; then + echo "::warning::Skipping a recorded egress address that is not a dotted IPv4 address." + continue + fi + for port in 3306 5432; do + permissions=$(printf \ + '[{"IpProtocol":"tcp","FromPort":%s,"ToPort":%s,"IpRanges":[{"CidrIp":"%s/32"}]}]' \ + "$port" "$port" "$ipv4") + if output=$(aws ec2 revoke-security-group-ingress \ + --group-name default --ip-permissions "$permissions" 2>&1); then + # In a default VPC an unmatched revoke is not an error: the rules that were not found + # come back under UnknownIpPermissions, so echo the response instead of claiming the + # rule was there. A non-default VPC raises InvalidPermission.NotFound, handled below. + echo "Revoke of TCP $port from $ipv4/32 accepted:" + echo "$output" + elif [ "${output#*InvalidPermission.NotFound}" != "$output" ]; then + # Already gone, e.g. revoked by hand or by the 12-hour sweep. + echo "TCP $port from $ipv4/32 was already revoked." + else + # Revoke the rest before failing. + echo "$output" + status=1 + fi + done + done < <(cat "${files[@]}" | tr -d '\r' | awk 'NF' | sort -u) + exit "${status:-0}" diff --git a/.github/workflows/autoscaling_tests.yml b/.github/workflows/autoscaling_tests.yml index 91c5c5c07..751b21beb 100644 --- a/.github/workflows/autoscaling_tests.yml +++ b/.github/workflows/autoscaling_tests.yml @@ -39,12 +39,18 @@ jobs: role-duration-seconds: 21600 aws-region: ${{ secrets.AWS_DEFAULT_REGION }} + - name: 'Set a random database password' + run: | + password=$(openssl rand -hex 16) + echo "::add-mask::$password" + echo "DB_PASSWORD=$password" >> "$GITHUB_ENV" + - name: 'Run Autoscaling Tests' run: | ./gradlew --no-parallel --no-daemon test-autoscaling --info env: - RDS_CLUSTER_DOMAIN: ${{ secrets.DB_CONN_SUFFIX }} - AURORA_DB_REGION: ${{ secrets.AWS_DEFAULT_REGION }} + RDS_DB_REGION: ${{ secrets.AWS_DEFAULT_REGION }} + SWEEP_DRY_RUN: ${{ github.ref_name != 'main' }} - name: 'Archive results' if: always() diff --git a/.github/workflows/blue_green_integration_tests.yml b/.github/workflows/blue_green_integration_tests.yml index b8b0bc8d0..b0b8c45c7 100644 --- a/.github/workflows/blue_green_integration_tests.yml +++ b/.github/workflows/blue_green_integration_tests.yml @@ -1,18 +1,8 @@ name: Blue/Green Integration Tests on: + # The push trigger is in blue_green_integration_tests_codebuild.yml, which runs these tests on CodeBuild runners. workflow_dispatch: - push: - branches: - - main - paths-ignore: - - '**/*.md' - - '**/*.jpg' - - '**/README.txt' - - '**/LICENSE.txt' - - 'docs/**' - - 'ISSUE_TEMPLATE/**' - - '**/remove-old-artifacts.yml' concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -60,6 +50,12 @@ jobs: role-duration-seconds: 21600 aws-region: ${{ secrets.AWS_DEFAULT_REGION }} + - name: 'Set a random database password' + run: | + password=$(openssl rand -hex 16) + echo "::add-mask::$password" + echo "DB_PASSWORD=$password" >> "$GITHUB_ENV" + - name: 'Run Blue/Green Integration Tests' run: | ./gradlew --no-parallel --no-daemon test-bgd-${{ matrix.task }} --info @@ -67,6 +63,7 @@ jobs: RDS_DB_REGION: ${{ secrets.AWS_DEFAULT_REGION }} MYSQL_VERSION: default PG_VERSION: default + SWEEP_DRY_RUN: ${{ github.ref_name != 'main' }} - name: 'Archive Blue/Green results' if: always() diff --git a/.github/workflows/blue_green_integration_tests_codebuild.yml b/.github/workflows/blue_green_integration_tests_codebuild.yml new file mode 100644 index 000000000..cd3316ca1 --- /dev/null +++ b/.github/workflows/blue_green_integration_tests_codebuild.yml @@ -0,0 +1,130 @@ +name: Blue/Green Integration Tests (CodeBuild) + +on: + workflow_dispatch: + push: + branches: + - main + paths-ignore: + - '**/*.md' + - '**/*.jpg' + - '**/README.txt' + - '**/LICENSE.txt' + - 'docs/**' + - 'ISSUE_TEMPLATE/**' + - '**/remove-old-artifacts.yml' + +concurrency: + # Shared with the other CodeBuild workflow: jobs share outbound IPs, and each run's last job revokes their database rules. + group: rds-integration-tests-codebuild + cancel-in-progress: false + +permissions: + id-token: write # This is required for requesting the JWT + contents: read # This is required for actions/checkout + +env: + # CodeBuild runners share outbound addresses, and Docker Hub limits anonymous pulls per address. + TEST_CONTAINER_REGISTRY: ecr + # Each job authorizes its address and one job revokes them all, so the harness must not revoke + # a rule that other jobs on the same address still use. + SKIP_IP_AUTHORIZATION: true + +jobs: + blue-green-integration-tests: + name: Run Blue/Green Integration Tests + runs-on: codebuild-pythonWrapper-${{ github.run_id }}-${{ github.run_attempt }} + timeout-minutes: 120 + strategy: + fail-fast: false + max-parallel: 2 + matrix: + task: [ "mysql-aurora-sync", "mysql-aurora-async", "pg-aurora-sync", "pg-aurora-async" ] + + steps: + - name: 'Clone repository' + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + + - name: 'Set up JDK 8' + uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5 + with: + distribution: 'corretto' + java-version: 8 + + - name: 'Configure AWS Credentials' + uses: aws-actions/configure-aws-credentials@d979d5b3a71173a29b74b5b88418bfda9437d885 # v6 + with: + role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.AWS_DEPLOY_ROLE }} + role-session-name: python_bg_integration_tests + role-duration-seconds: 21600 + aws-region: ${{ secrets.AWS_DEFAULT_REGION }} + + - name: 'Authorize the runner IP address' + id: ip + uses: ./.github/actions/codebuild-authorize-runner-ip + with: + id: bgd-${{ matrix.task }} + + - name: 'Record the runner IP address' + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: runner-ip-bgd-${{ matrix.task }} + path: ${{ steps.ip.outputs.ip-file }} + if-no-files-found: error + retention-days: 1 + + - name: 'Set a random database password' + run: | + password=$(openssl rand -hex 16) + echo "::add-mask::$password" + echo "DB_PASSWORD=$password" >> "$GITHUB_ENV" + + - name: 'Run Blue/Green Integration Tests' + run: | + ./gradlew --no-parallel --no-daemon test-bgd-${{ matrix.task }} --info + env: + RDS_DB_REGION: ${{ secrets.AWS_DEFAULT_REGION }} + MYSQL_VERSION: default + PG_VERSION: default + SWEEP_DRY_RUN: ${{ github.ref_name != 'main' }} + + - name: 'Archive Blue/Green results' + if: always() + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: pytest-integration-report-bgd-${{ matrix.task }} + path: ./tests/integration/container/reports + retention-days: 5 + + revoke-runner-ip: + name: 'Revoke runner IP' + runs-on: codebuild-pythonWrapper-${{ github.run_id }}-${{ github.run_attempt }} + timeout-minutes: 30 + needs: blue-green-integration-tests + if: always() + + steps: + - name: 'Clone repository' + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + with: + fetch-depth: 1 + + - name: 'Configure AWS Credentials' + uses: aws-actions/configure-aws-credentials@d979d5b3a71173a29b74b5b88418bfda9437d885 # v6 + with: + role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.AWS_DEPLOY_ROLE }} + role-session-name: python_bg_integration_tests + role-duration-seconds: 21600 + aws-region: ${{ secrets.AWS_DEFAULT_REGION }} + + - name: 'Download the recorded runner IP addresses' + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + pattern: runner-ip-* + merge-multiple: true + path: ${{ runner.temp }}/runner-ips + + - name: 'Revoke the recorded runner IP addresses' + uses: ./.github/actions/codebuild-revoke-runner-ips + with: + ip-dir: ${{ runner.temp }}/runner-ips diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 76519f84d..0c57b5c04 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -1,18 +1,8 @@ name: Integration Tests on: + # The push trigger is in integration_tests_codebuild.yml, which runs these tests on CodeBuild runners. workflow_dispatch: - push: - branches: - - main - paths-ignore: - - '**/*.md' - - '**/*.jpg' - - '**/README.txt' - - '**/LICENSE.txt' - - 'docs/**' - - 'ISSUE_TEMPLATE/**' - - '**/remove-old-artifacts.yml' concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -59,14 +49,20 @@ jobs: role-duration-seconds: 21600 aws-region: ${{ secrets.AWS_DEFAULT_REGION }} + - name: 'Set a random database password' + run: | + password=$(openssl rand -hex 16) + echo "::add-mask::$password" + echo "DB_PASSWORD=$password" >> "$GITHUB_ENV" + - name: 'Run LTS Integration Tests' run: | ./gradlew --no-parallel --no-daemon test-python-${{ matrix.python-version }}-${{ matrix.environment }} --info env: - RDS_CLUSTER_DOMAIN: ${{ secrets.DB_CONN_SUFFIX }} RDS_DB_REGION: ${{ secrets.AWS_DEFAULT_REGION }} - AURORA_MYSQL_DB_ENGINE_VERSION: lts - AURORA_PG_ENGINE_VERSION: lts + MYSQL_VERSION: default + PG_VERSION: default + SWEEP_DRY_RUN: ${{ github.ref_name != 'main' }} - name: 'Archive LTS results' if: always() @@ -113,14 +109,20 @@ jobs: role-duration-seconds: 21600 aws-region: ${{ secrets.AWS_DEFAULT_REGION }} + - name: 'Set a random database password' + run: | + password=$(openssl rand -hex 16) + echo "::add-mask::$password" + echo "DB_PASSWORD=$password" >> "$GITHUB_ENV" + - name: 'Run Latest Integration Tests' run: | ./gradlew --no-parallel --no-daemon test-python-${{ matrix.python-version }}-${{ matrix.environment }} --info env: - RDS_CLUSTER_DOMAIN: ${{ secrets.DB_CONN_SUFFIX }} RDS_DB_REGION: ${{ secrets.AWS_DEFAULT_REGION }} - AURORA_MYSQL_DB_ENGINE_VERSION: latest - AURORA_PG_ENGINE_VERSION: latest + MYSQL_VERSION: latest + PG_VERSION: latest + SWEEP_DRY_RUN: ${{ github.ref_name != 'main' }} - name: 'Archive Latest results' if: always() diff --git a/.github/workflows/integration_tests_codebuild.yml b/.github/workflows/integration_tests_codebuild.yml index b8f63c3d7..003b5862b 100644 --- a/.github/workflows/integration_tests_codebuild.yml +++ b/.github/workflows/integration_tests_codebuild.yml @@ -1,24 +1,46 @@ -name: Integration Tests CodeBuild +name: Integration Tests (CodeBuild) on: workflow_dispatch: + push: + branches: + - main + paths-ignore: + - '**/*.md' + - '**/*.jpg' + - '**/README.txt' + - '**/LICENSE.txt' + - 'docs/**' + - 'ISSUE_TEMPLATE/**' + - '**/remove-old-artifacts.yml' + +concurrency: + # Shared with the other CodeBuild workflow: jobs share outbound IPs, and each run's last job revokes their database rules. + group: rds-integration-tests-codebuild + cancel-in-progress: false permissions: id-token: write # This is required for requesting the JWT contents: read # This is required for actions/checkout +env: + # CodeBuild runners share outbound addresses, and Docker Hub limits anonymous pulls per address. + TEST_CONTAINER_REGISTRY: ecr + # Each job authorizes its address and one job revokes them all, so the harness must not revoke + # a rule that other jobs on the same address still use. + SKIP_IP_AUTHORIZATION: true + jobs: - build-integration-tests-codebuild: - name: Run Integration Tests With CodeBuild + lts-integration-tests: + name: Run LTS Integration Tests + runs-on: codebuild-pythonWrapper-${{ github.run_id }}-${{ github.run_attempt }} + timeout-minutes: 330 strategy: fail-fast: false matrix: - python-version: [ "3.11", "3.12", "3.13", "3.14" ] + python-version: [ "3.11", "3.12", "3.13", "3.14" ] environment: [ "mysql", "pg" ] - runs-on: ubuntu-latest - environment: ${{ matrix.environment }}_integ - steps: - name: 'Clone repository' uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 @@ -29,37 +51,146 @@ jobs: distribution: 'corretto' java-version: 8 - - name: Install poetry - shell: bash + - name: 'Configure AWS Credentials' + uses: aws-actions/configure-aws-credentials@d979d5b3a71173a29b74b5b88418bfda9437d885 # v6 + with: + role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.AWS_DEPLOY_ROLE }} + role-session-name: python_integration_tests + role-duration-seconds: 21600 + aws-region: ${{ secrets.AWS_DEFAULT_REGION }} + + - name: 'Authorize the runner IP address' + id: ip + uses: ./.github/actions/codebuild-authorize-runner-ip + with: + id: lts-${{ matrix.python-version }}-${{ matrix.environment }} + + - name: 'Record the runner IP address' + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: runner-ip-lts-${{ matrix.python-version }}-${{ matrix.environment }} + path: ${{ steps.ip.outputs.ip-file }} + if-no-files-found: error + retention-days: 1 + + - name: 'Set a random database password' run: | - pipx install poetry==1.8.2 - poetry config virtualenvs.prefer-active-python true + password=$(openssl rand -hex 16) + echo "::add-mask::$password" + echo "DB_PASSWORD=$password" >> "$GITHUB_ENV" + + - name: 'Run LTS Integration Tests' + run: | + ./gradlew --no-parallel --no-daemon test-python-${{ matrix.python-version }}-${{ matrix.environment }} --info + env: + RDS_DB_REGION: ${{ secrets.AWS_DEFAULT_REGION }} + MYSQL_VERSION: default + PG_VERSION: default + SWEEP_DRY_RUN: ${{ github.ref_name != 'main' }} + + - name: 'Archive LTS results' + if: always() + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: pytest-integration-report-${{ matrix.python-version }}-${{ matrix.environment }}-lts + path: ./tests/integration/container/reports + retention-days: 5 + + latest-integration-tests: + name: Run Latest Integration Tests + runs-on: codebuild-pythonWrapper-${{ github.run_id }}-${{ github.run_attempt }} + timeout-minutes: 330 + needs: lts-integration-tests + strategy: + fail-fast: false + matrix: + python-version: [ "3.11", "3.12", "3.13", "3.14" ] + environment: [ "mysql", "pg" ] - - name: Install dependencies - run: poetry install + steps: + - name: 'Clone repository' + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + + - name: 'Set up JDK 8' + uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5 + with: + distribution: 'corretto' + java-version: 8 - name: 'Configure AWS Credentials' uses: aws-actions/configure-aws-credentials@d979d5b3a71173a29b74b5b88418bfda9437d885 # v6 with: role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.AWS_DEPLOY_ROLE }} - role-session-name: python_integration_codebuild_tests + role-session-name: python_integration_tests role-duration-seconds: 21600 aws-region: ${{ secrets.AWS_DEFAULT_REGION }} - - name: 'Run Integration Tests' + - name: 'Authorize the runner IP address' + id: ip + uses: ./.github/actions/codebuild-authorize-runner-ip + with: + id: latest-${{ matrix.python-version }}-${{ matrix.environment }} + + - name: 'Record the runner IP address' + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: runner-ip-latest-${{ matrix.python-version }}-${{ matrix.environment }} + path: ${{ steps.ip.outputs.ip-file }} + if-no-files-found: error + retention-days: 1 + + - name: 'Set a random database password' + run: | + password=$(openssl rand -hex 16) + echo "::add-mask::$password" + echo "DB_PASSWORD=$password" >> "$GITHUB_ENV" + + - name: 'Run Latest Integration Tests' run: | ./gradlew --no-parallel --no-daemon test-python-${{ matrix.python-version }}-${{ matrix.environment }} --info env: - RDS_CLUSTER_DOMAIN: ${{ secrets.DB_CONN_SUFFIX }} RDS_DB_REGION: ${{ secrets.AWS_DEFAULT_REGION }} - RDS_ENDPOINT: ${{ secrets.RDS_ENDPOINT }} - AURORA_MYSQL_DB_ENGINE_VERSION: "latest" - AURORA_PG_ENGINE_VERSION: "latest" + MYSQL_VERSION: latest + PG_VERSION: latest + SWEEP_DRY_RUN: ${{ github.ref_name != 'main' }} - - name: 'Archive results' + - name: 'Archive Latest results' if: always() uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: - name: pytest-integration-report-${{ matrix.python-version }}-${{ matrix.environment }} + name: pytest-integration-report-${{ matrix.python-version }}-${{ matrix.environment }}-latest path: ./tests/integration/container/reports retention-days: 5 + + revoke-runner-ip: + name: 'Revoke runner IP' + runs-on: codebuild-pythonWrapper-${{ github.run_id }}-${{ github.run_attempt }} + timeout-minutes: 30 + needs: [ lts-integration-tests, latest-integration-tests ] + if: always() + + steps: + - name: 'Clone repository' + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + with: + fetch-depth: 1 + + - name: 'Configure AWS Credentials' + uses: aws-actions/configure-aws-credentials@d979d5b3a71173a29b74b5b88418bfda9437d885 # v6 + with: + role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.AWS_DEPLOY_ROLE }} + role-session-name: python_integration_tests + role-duration-seconds: 21600 + aws-region: ${{ secrets.AWS_DEFAULT_REGION }} + + - name: 'Download the recorded runner IP addresses' + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + pattern: runner-ip-* + merge-multiple: true + path: ${{ runner.temp }}/runner-ips + + - name: 'Revoke the recorded runner IP addresses' + uses: ./.github/actions/codebuild-revoke-runner-ips + with: + ip-dir: ${{ runner.temp }}/runner-ips diff --git a/.github/workflows/integration_tests_custom_endpoint.yml b/.github/workflows/integration_tests_custom_endpoint.yml new file mode 100644 index 000000000..849a06d80 --- /dev/null +++ b/.github/workflows/integration_tests_custom_endpoint.yml @@ -0,0 +1,71 @@ +name: Integration Tests Custom Endpoint + +on: + workflow_dispatch: + +permissions: + id-token: write # This is required for requesting the JWT + contents: read # This is required for actions/checkout + +jobs: + custom-endpoint-integration-tests: + name: Run Custom Endpoint Integration Tests + strategy: + fail-fast: false + matrix: + python-version: [ "3.11", "3.12", "3.13", "3.14" ] + environment: [ "mysql", "pg" ] + + runs-on: ubuntu-latest + environment: ${{ matrix.environment }}_integ + + steps: + - name: 'Clone repository' + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + + - name: 'Set up JDK 8' + uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5 + with: + distribution: 'corretto' + java-version: 8 + + - name: Install poetry + shell: bash + run: | + pipx install poetry==1.8.2 + poetry config virtualenvs.prefer-active-python true + + - name: Install dependencies + run: poetry install + + - name: 'Configure AWS Credentials' + uses: aws-actions/configure-aws-credentials@d979d5b3a71173a29b74b5b88418bfda9437d885 # v6 + with: + role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.AWS_DEPLOY_ROLE }} + role-session-name: python_integration_codebuild_tests + role-duration-seconds: 21600 + aws-region: ${{ secrets.AWS_DEFAULT_REGION }} + + - name: 'Set a random database password' + run: | + password=$(openssl rand -hex 16) + echo "::add-mask::$password" + echo "DB_PASSWORD=$password" >> "$GITHUB_ENV" + + - name: 'Run Integration Tests' + run: | + ./gradlew --no-parallel --no-daemon test-python-${{ matrix.python-version }}-${{ matrix.environment }} --info + env: + RDS_DB_REGION: ${{ secrets.AWS_DEFAULT_REGION }} + RDS_ENDPOINT: ${{ secrets.RDS_ENDPOINT }} + MYSQL_VERSION: latest + PG_VERSION: latest + SWEEP_DRY_RUN: ${{ github.ref_name != 'main' }} + + - name: 'Archive results' + if: always() + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: pytest-integration-report-${{ matrix.python-version }}-${{ matrix.environment }} + path: ./tests/integration/container/reports + retention-days: 5 diff --git a/.github/workflows/mysql_performance_tests.yml b/.github/workflows/mysql_performance_tests.yml index 43f841bfd..3fdd41d64 100644 --- a/.github/workflows/mysql_performance_tests.yml +++ b/.github/workflows/mysql_performance_tests.yml @@ -41,14 +41,20 @@ jobs: role-duration-seconds: 21600 aws-region: ${{ secrets.AWS_DEFAULT_REGION }} + - name: 'Set a random database password' + run: | + password=$(openssl rand -hex 16) + echo "::add-mask::$password" + echo "DB_PASSWORD=$password" >> "$GITHUB_ENV" + - name: 'Run MySQL Performance Tests' run: | ./gradlew --no-parallel --no-daemon test-mysql-aurora-performance --info env: - RDS_CLUSTER_DOMAIN: ${{ secrets.DB_CONN_SUFFIX }} - AURORA_DB_REGION: ${{ secrets.AWS_DEFAULT_REGION }} - AURORA_MYSQL_DB_ENGINE_VERSION: "lts" - AURORA_PG_ENGINE_VERSION: "lts" + RDS_DB_REGION: ${{ secrets.AWS_DEFAULT_REGION }} + MYSQL_VERSION: default + PG_VERSION: default + SWEEP_DRY_RUN: ${{ github.ref_name != 'main' }} - name: 'Archive results' if: always() diff --git a/.github/workflows/pg_performance_tests.yml b/.github/workflows/pg_performance_tests.yml index cc10ec560..bbcea12de 100644 --- a/.github/workflows/pg_performance_tests.yml +++ b/.github/workflows/pg_performance_tests.yml @@ -39,14 +39,20 @@ jobs: role-duration-seconds: 21600 aws-region: ${{ secrets.AWS_DEFAULT_REGION }} + - name: 'Set a random database password' + run: | + password=$(openssl rand -hex 16) + echo "::add-mask::$password" + echo "DB_PASSWORD=$password" >> "$GITHUB_ENV" + - name: 'Run PG Performance Tests' run: | ./gradlew --no-parallel --no-daemon test-pg-aurora-performance --info env: - RDS_CLUSTER_DOMAIN: ${{ secrets.DB_CONN_SUFFIX }} - AURORA_DB_REGION: ${{ secrets.AWS_DEFAULT_REGION }} - AURORA_MYSQL_DB_ENGINE_VERSION: "lts" - AURORA_PG_ENGINE_VERSION: "lts" + RDS_DB_REGION: ${{ secrets.AWS_DEFAULT_REGION }} + MYSQL_VERSION: default + PG_VERSION: default + SWEEP_DRY_RUN: ${{ github.ref_name != 'main' }} - name: 'Archive results' if: always() diff --git a/docs/development-guide/IntegrationTests.md b/docs/development-guide/IntegrationTests.md index 52779c4e4..cd6de0b4d 100644 --- a/docs/development-guide/IntegrationTests.md +++ b/docs/development-guide/IntegrationTests.md @@ -66,17 +66,18 @@ unset FILTER # Done testing the IAM tests, unset FILTER ### Existing clusters and leftovers -When `REUSE_RDS_DB` isn't `true` and `RDS_DB_NAME` names a cluster that exists, an Aurora run fails before it adds the rule for the runner's IP or makes a cluster. +When `REUSE_RDS_DB` isn't `true` and `RDS_DB_NAME` names a cluster that exists, an Aurora run fails before it adds the rules for the runner's IP or makes a cluster. Then set `REUSE_RDS_DB=true` to use that cluster, or set `RDS_DB_NAME` to a new name. -An Aurora run adds an all-traffic rule for the runner's IP to the `default` security group, described `Test run at