Skip to content

Commit

Permalink
chore: update tests framework
Browse files Browse the repository at this point in the history
  • Loading branch information
karenc-bq committed May 9, 2024
1 parent 2773ed8 commit e961229
Show file tree
Hide file tree
Showing 11 changed files with 595 additions and 317 deletions.
141 changes: 141 additions & 0 deletions .github/workflows/codebuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
name: Integration Tests on CodeBuild

on:
workflow_dispatch:

env:
BUILD_TYPE: Release

jobs:
integration-tests-codebuild:
strategy:
matrix:
engine_version: ["latest"]
concurrency: # Cancel previous runs in the same branch
group: environment-${{ github.ref }}
cancel-in-progress: true
name: CodeBuild Integration Tests

runs-on: codebuild-jdbcWrapper-${{ github.run_id }}-${{ github.run_attempt }}
environment: mysql_integ

env:
CMAKE_GENERATOR: Unix Makefiles

steps:
- name: Checkout source code
uses: actions/checkout@v4

- name: Install build dependencies
run: sudo apt-get update && sudo apt-get install libcurl4 && sudo apt-get install libcurl4-openssl-dev

- name: Cache AWS SDK libraries
id: cache-dynamic-aws-sdk
uses: actions/cache@v4
with:
path: |
aws_sdk
key: ${{ runner.os }}-aws-sdk-dynamic-lib

- name: Build and install AWS SDK C++
working-directory: ./scripts
if: steps.cache-dynamic-aws-sdk.outputs.cache-hit != 'true'
run: |
./build_aws_sdk_unix.sh $BUILD_TYPE
- name: 'Set up JDK 8'
uses: actions/setup-java@v4
with:
distribution: 'corretto'
java-version: 8

- name: 'Configure AWS Credentials'
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}

- name: 'Set up Temp AWS Credentials'
run: |
creds=($(aws sts get-session-token \
--duration-seconds 21600 \
--query 'Credentials.[AccessKeyId, SecretAccessKey, SessionToken]' \
--output text \
| xargs));
echo "::add-mask::${creds[0]}"
echo "::add-mask::${creds[1]}"
echo "::add-mask::${creds[2]}"
echo "TEMP_AWS_ACCESS_KEY_ID=${creds[0]}" >> $GITHUB_ENV
echo "TEMP_AWS_SECRET_ACCESS_KEY=${creds[1]}" >> $GITHUB_ENV
echo "TEMP_AWS_SESSION_TOKEN=${creds[2]}" >> $GITHUB_ENV
- name: 'Run Integration Tests'
working-directory: ${{ github.workspace }}/testframework
run: |
./gradlew --no-parallel --no-daemon test-failover --info
env:
TEST_DSN: awsmysqlodbca
TEST_USERNAME: ${{ secrets.TEST_USERNAME }}
TEST_PASSWORD: ${{ secrets.TEST_PASSWORD }}
TEST_DB_CLUSTER_IDENTIFIER: ${{ secrets.TEST_DB_CLUSTER_IDENTIFIER }}-${{ github.run_id }}-${{ github.run_attempt }}
AWS_ACCESS_KEY_ID: ${{ env.TEMP_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ env.TEMP_AWS_SECRET_ACCESS_KEY }}
AWS_SESSION_TOKEN: ${{ env.TEMP_AWS_SESSION_TOKEN }}
DB_ENGINE_VERSION: ${{ matrix.engine_version }}
RDS_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
RDS_ENDPOINT: ${{ secrets.RDS_ENDPOINT }}
DRIVER_PATH: ${{ github.workspace }}

- name: 'Get Github Action IP'
id: ip
uses: haythem/public-ip@v1.3

- name: 'Remove Github Action IP'
if: always()
run: |
aws ec2 revoke-security-group-ingress \
--group-name default \
--protocol tcp \
--port 3306 \
--cidr ${{ steps.ip.outputs.ipv4 }}/32 \
2>&1 > /dev/null;
- name: 'Display and save log'
if: always()
working-directory: ${{ github.workspace }}
run: |
echo "Displaying logs"
mkdir -p ./reports/tests
if [[ -f myodbc.log && -s myodbc.log ]]; then
cat myodbc.log
cp myodbc.log ./reports/tests/myodbc.log
fi
- name: 'Archive log results'
if: always()
uses: actions/upload-artifact@v4
with:
name: 'integration-test-logs'
path: reports/tests/
retention-days: 3

- name: 'Delete Test Clusters if Ungraceful Cancel'
if: cancelled()
run: |
db_instances=($(aws rds describe-db-clusters \
--db-cluster-identifier ${{ secrets.TEST_DB_CLUSTER_IDENTIFIER }}-${{ github.run_id }}-${{ github.run_attempt }} \
--query 'DBClusters[].DBClusterMembers[].DBInstanceIdentifier' \
--output text \
| xargs));
for ((i = 0; i < ${#db_instances[@]}; i++)); \
do \
aws rds delete-db-instance \
--db-instance-identifier ${db_instances[i]} \
--skip-final-snapshot \
2>&1 > /dev/null; \
done;
aws rds delete-db-cluster \
--db-cluster-identifier ${{ secrets.TEST_DB_CLUSTER_IDENTIFIER }}-${{ github.run_id }}-${{ github.run_attempt }} \
--skip-final-snapshot \
2>&1 > /dev/null;
137 changes: 2 additions & 135 deletions .github/workflows/dockerized.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Dockerized Tests
name: Community Integration Tests

on:
push:
Expand All @@ -20,7 +20,7 @@ env:
BUILD_TYPE: Release

jobs:
build-dockerized-community-tests:
community-tests:
name: Dockerized Community Tests
runs-on: ubuntu-20.04
env:
Expand Down Expand Up @@ -62,136 +62,3 @@ jobs:
TEST_USERNAME: root
TEST_PASSWORD: root
DRIVER_PATH: ${{ github.workspace }}

build-dockerized-integration-tests:
concurrency: # Cancel previous runs in the same branch
group: environment-${{ github.ref }}
cancel-in-progress: true
name: Dockerized Integration Tests
runs-on: ubuntu-20.04
env:
CMAKE_GENERATOR: Unix Makefiles

steps:
- name: Checkout source code
uses: actions/checkout@v4

- name: Install build dependencies
run: sudo apt-get update && sudo apt-get install libcurl4 && sudo apt-get install libcurl4-openssl-dev

- name: Cache AWS SDK libraries
id: cache-dynamic-aws-sdk
uses: actions/cache@v4
with:
path: |
aws_sdk
key: ${{ runner.os }}-aws-sdk-dynamic-lib

- name: Build and install AWS SDK C++
working-directory: ./scripts
if: steps.cache-dynamic-aws-sdk.outputs.cache-hit != 'true'
run: |
./build_aws_sdk_unix.sh $BUILD_TYPE
- name: 'Set up JDK 8'
uses: actions/setup-java@v4
with:
distribution: 'corretto'
java-version: 8

- name: 'Configure AWS Credentials'
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}

- name: 'Set up Temp AWS Credentials'
run: |
creds=($(aws sts get-session-token \
--duration-seconds 7200 \
--query 'Credentials.[AccessKeyId, SecretAccessKey, SessionToken]' \
--output text \
| xargs));
echo "::add-mask::${creds[0]}"
echo "::add-mask::${creds[1]}"
echo "::add-mask::${creds[2]}"
echo "TEMP_AWS_ACCESS_KEY_ID=${creds[0]}" >> $GITHUB_ENV
echo "TEMP_AWS_SECRET_ACCESS_KEY=${creds[1]}" >> $GITHUB_ENV
echo "TEMP_AWS_SESSION_TOKEN=${creds[2]}" >> $GITHUB_ENV
- name: 'Run Integration Tests'
working-directory: ${{ github.workspace }}/testframework
run: |
./gradlew --no-parallel --no-daemon test-failover --info
env:
TEST_DSN: awsmysqlodbca
TEST_USERNAME: ${{ secrets.TEST_USERNAME }}
TEST_PASSWORD: ${{ secrets.TEST_PASSWORD }}
TEST_DB_CLUSTER_IDENTIFIER: ${{ secrets.TEST_DB_CLUSTER_IDENTIFIER }}-${{ github.run_id }}-${{ github.run_attempt }}
AWS_ACCESS_KEY_ID: ${{ env.TEMP_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ env.TEMP_AWS_SECRET_ACCESS_KEY }}
AWS_SESSION_TOKEN: ${{ env.TEMP_AWS_SESSION_TOKEN }}
DRIVER_PATH: ${{ github.workspace }}

- name: 'Get Github Action IP'
id: ip
uses: haythem/public-ip@v1.3

- name: 'Remove Github Action IP'
if: always()
run: |
aws ec2 revoke-security-group-ingress \
--group-name default \
--protocol tcp \
--port 3306 \
--cidr ${{ steps.ip.outputs.ipv4 }}/32 \
2>&1 > /dev/null;
- name: 'Display and save log'
if: always()
working-directory: ${{ github.workspace }}
run: |
echo "Displaying logs"
mkdir -p ./reports/tests
if [[ -f myodbc.log && -s myodbc.log ]]; then
cat myodbc.log
cp myodbc.log ./reports/tests/myodbc.log
fi
if [[ -f failover_performance.xlsx && -s failover_performance.xlsx ]]; then
cp failover_performance.xlsx ./reports/tests/failover_performance.xlsx
fi
if [[ -f efm_performance.xlsx && -s efm_performance.xlsx ]]; then
cp efm_performance.xlsx ./reports/tests/efm_performance.xlsx
fi
if [[ -f efm_detection_performance.xlsx && -s efm_detection_performance.xlsx ]]; then
cp efm_detection_performance.xlsx ./reports/tests/efm_detection_performance.xlsx
fi
- name: 'Archive log results'
if: always()
uses: actions/upload-artifact@v4
with:
name: 'integration-test-logs'
path: reports/tests/
retention-days: 3

- name: 'Delete Test Clusters if Ungraceful Cancel'
if: cancelled()
run: |
db_instances=($(aws rds describe-db-clusters \
--db-cluster-identifier ${{ secrets.TEST_DB_CLUSTER_IDENTIFIER }}-${{ github.run_id }}-${{ github.run_attempt }} \
--query 'DBClusters[].DBClusterMembers[].DBInstanceIdentifier' \
--output text \
| xargs));
for ((i = 0; i < ${#db_instances[@]}; i++)); \
do \
aws rds delete-db-instance \
--db-instance-identifier ${db_instances[i]} \
--skip-final-snapshot \
2>&1 > /dev/null; \
done;
aws rds delete-db-cluster \
--db-cluster-identifier ${{ secrets.TEST_DB_CLUSTER_IDENTIFIER }}-${{ github.run_id }}-${{ github.run_attempt }} \
--skip-final-snapshot \
2>&1 > /dev/null;
Loading

0 comments on commit e961229

Please sign in to comment.