Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DAT-17834 Ephemeral AWS infra for liquibase-test-harness #819

Merged
merged 39 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
25df9d7
✨ (aws-weekly.yml): Add AWS Weekly Cloud Database Test Execution work…
May 31, 2024
1a7b0e8
🔧 (aws-weekly.yml): Update schedule to execute workflow every Sunday …
May 31, 2024
5bac9b1
✨ (aws-weekly.yml): add support for AWS MySQL database option in the …
May 31, 2024
eaa73fb
🔧 (aws-weekly.yml): Update condition for aws_postgresql to exclude 'p…
May 31, 2024
33e3166
🐛 (aws-weekly.yml): fix condition for aws_postgresql to correctly che…
May 31, 2024
b416e8b
🔧 (aws-weekly.yml): add permissions for contents and id-token to impr…
May 31, 2024
b4eba1c
📝 (aws-weekly.yml): remove unnecessary concurrency key from workflow …
May 31, 2024
72c3137
🔧 (aws-weekly.yml): Update secret-ids format for mysql and aurora dat…
May 31, 2024
63b3876
🔧 (aws-weekly.yml): add support for fetching different AWS secrets ba…
May 31, 2024
c4ed610
🔧 (aws-weekly.yml): Update the reference to the ephemeral-cloud-infra…
May 31, 2024
9b95019
🔧 (aws-weekly.yml): Update the version of ephemeral-cloud-infra.yml t…
May 31, 2024
06c2255
🔧 (aws-weekly.yml): Update conditional statements to fetch AWS secret…
May 31, 2024
5175d98
🔧 (aws-weekly.yml): Update workflow to use 'needs' instead of 'steps'…
Jun 1, 2024
64543c5
🔧 (aws-weekly.yml): Refactor GitHub workflow to use 'steps' instead o…
Jun 1, 2024
d3eacc0
🔧 (aws-weekly.yml): update job dependencies to include deploy-ephemer…
Jun 1, 2024
96efe1c
🔧 (aws-weekly.yml): Remove unnecessary database cleanup steps to stre…
Jun 1, 2024
429c2ad
🔧 (aws-weekly.yml): refactor workflow to use a matrix for database ve…
Jun 1, 2024
cd836da
🔧 (aws-weekly.yml): update liquibase changeLogFile to include "_cloud…
Jun 1, 2024
04ff8b2
🔧 (aws-weekly.yml): Update conditional statements to fetch AWS secret…
Jun 1, 2024
b79f090
📝 (mssql.sql): add USE lbcat; statement to specify the database to us…
Jun 1, 2024
82a161e
📝 (mssql.sql): remove unnecessary USE lbcat; statement and fix DROP T…
Jun 1, 2024
071f2a3
🔧 (aws-weekly.yml): Remove redundant database initialization steps fo…
Jun 1, 2024
6fb4e90
🔧 (aws-weekly.yml): add conditional database initialization step for …
Jun 1, 2024
4508e0a
🔧 (aws-weekly.yml): remove unnecessary database initialization steps …
Jun 1, 2024
03411df
🔧 (aws-weekly.yml): Remove redundant AWS secrets retrieval steps for …
Jun 1, 2024
b173feb
✨ (aws-weekly.yml): Add a new line to improve readability and maintai…
Jun 1, 2024
557f89c
test
Jun 2, 2024
9dc8636
🔧 (aws-weekly.yml): add TH_MSSQLURL_HOST secret to support MSSQL host…
Jun 2, 2024
d82b8ff
🔧 (aws-weekly.yml): update TH_MSSQLURL_HOST secret to include correct…
Jun 2, 2024
bcf5c80
🔧 (aws-weekly.yml): transform TH_MSSQLURL_HOST value to replace colon…
Jun 2, 2024
a9105d2
🔧 (aws-weekly.yml): simplify sqlcmd command by removing unnecessary v…
Jun 2, 2024
a8dbc67
test
Jun 2, 2024
8846215
Merge branch 'main' into DAT-17834
jandroav Jun 3, 2024
e2dbf7a
🔧 (aws-weekly.yml): Update schedule to execute the workflow every Sun…
Jun 3, 2024
78ff609
🔧 (aws-weekly.yml): Update workflow to use the main branch for epheme…
Jun 3, 2024
1a420db
🔧 (aws-weekly.yml): Add missing newline characters for better readabi…
Jun 4, 2024
781f3e8
DAT-17834. fix for postgresql aurora failures.
PavloTytarchuk Jun 4, 2024
a8eac29
Merge remote-tracking branch 'origin/DAT-17834' into DAT-17834
PavloTytarchuk Jun 4, 2024
d0179e2
DAT-17834. fix for postgresql aurora failures.
PavloTytarchuk Jun 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
182 changes: 108 additions & 74 deletions .github/workflows/aws-weekly.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Terraform Action to test Cloud Databases with test-harness

name: AWS Weekly Cloud Database Test Execution
concurrency: aws-run
on:
# Triggers the workflow on a schedule for the main branch. Also allows for manual triggers
# Execute every sunday at 6:00 AM
# Execute every sunday at 4:00 AM
schedule:
- cron: '0 6 * * 0'
- cron: '0 4 * * 0'
workflow_dispatch:
inputs:
testClasses:
Expand Down Expand Up @@ -38,15 +37,24 @@ jobs:
uses: actions/checkout@v4

deploy-ephemeral-cloud-infra:
uses: liquibase/build-logic/.github/workflows/ephemeral-cloud-infra.yml@DAT-17834
uses: liquibase/build-logic/.github/workflows/ephemeral-cloud-infra.yml@main
secrets: inherit
with:
deploy: true
aws_test_harness: true
aws_postgresql: ${{ contains(inputs.databases, 'postgresql:12') || contains(inputs.databases, 'postgresql:13') || contains(inputs.databases, 'postgresql:14')}}
aws_oracle: ${{ contains(inputs.databases, 'oracle') }}
aws_mariadb: ${{ contains(inputs.databases, 'mariadb') }}
aws_aurora_mysql: ${{ contains(inputs.databases, 'mysql:aurora') }}
aws_mssql: ${{ contains(inputs.databases, 'mssql') }}
aws_aurora_postgres: ${{ contains(inputs.databases, 'postgresql:aurora') }}
aws_mysql: ${{ contains(inputs.databases, 'mysql:aws') }}

init-mysql:
runs-on: ubuntu-latest
needs: [deploy-ephemeral-cloud-infra]
permissions:
contents: read
id-token: write
container:
image: liquibase/liquibase:latest
env:
Expand All @@ -69,52 +77,44 @@ jobs:
role-to-assume: ${{ secrets.AWS_DEV_GITHUB_OIDC_ROLE_ARN_BUILD_LOGIC }}
aws-region: us-east-1

- name: Configure Test
id: setup
uses: actions/[email protected]
with:
script: |
let splitValues = "${{ matrix.database }}".split(":")
core.setOutput("databasePlatform", splitValues[0]);
core.setOutput("databaseVersion", splitValues[1]);

- name: Get AWS secrets
if: ${{ matrix.version == 'aws' && matrix.database == 'mysql'}}
uses: aws-actions/aws-secretsmanager-get-secrets@v2
with:
secret-ids: |
TH_MYSQLURL_8_0, /testautomation/db_details/aws_mysql_jdbc${{ needs.deploy-ephemeral-cloud-infra.outputs.resources_id }}
TH_AURORA_MYSQLURL, /testautomation/db_details/aurora_mysql_jdbc${{ needs.deploy-ephemeral-cloud-infra.outputs.resources_id }}
TH_ORACLEURL_19, /testautomation/db_details/aws_oracle_19_jdbc${{ needs.deploy-ephemeral-cloud-infra.outputs.resources_id }}
TH_PGRESURL_12, /testautomation/db_details/aws_postgresql_12_jdbc${{ needs.deploy-ephemeral-cloud-infra.outputs.resources_id }}
TH_PGRESURL_13, /testautomation/db_details/aws_postgresql_13_jdbc${{ needs.deploy-ephemeral-cloud-infra.outputs.resources_id }}
TH_PGRESURL_14, /testautomation/db_details/aws_postgresql_14_jdbc${{ needs.deploy-ephemeral-cloud-infra.outputs.resources_id }}
TH_MARIADBURL_10_6, /testautomation/db_details/aws_mariadb_jdbc${{ needs.deploy-ephemeral-cloud-infra.outputs.resources_id }}
TH_MSSQLURL, /testautomation/db_details/aws_mssql_jdbc${{ needs.deploy-ephemeral-cloud-infra.outputs.resources_id }}
TH_AURORA_POSTGRESQLURL, /testautomation/db_details/aurora_postgresql_jdbc${{ needs.deploy-ephemeral-cloud-infra.outputs.resources_id }}

TH_MYSQLURL_8_0, /testautomation/db_details/aws_mysql_jdbc_${{ needs.deploy-ephemeral-cloud-infra.outputs.resources_id }}
- name: Get AWS secrets
if: ${{ matrix.version == 'aurora' && matrix.database == 'mysql'}}
uses: aws-actions/aws-secretsmanager-get-secrets@v2
with:
secret-ids: |
TH_AURORA_MYSQLURL, /testautomation/db_details/aurora_mysql_jdbc_${{ needs.deploy-ephemeral-cloud-infra.outputs.resources_id }}
#This additional init step is required because of mysql driver issue on GH actions
- name: Install Dependencies
run: lpm update && lpm add mysql

- name: Clean AWS MySQL Database
uses: liquibase-github-actions/[email protected]
if: ${{ matrix.version == 'aws' }}
with:
url: "${{ env.TH_MYSQLURL_8_0 }}"
username: "${{secrets.TH_DB_ADMIN}}"
password: "${{secrets.TH_DB_PASSWD}}"
licenseKey: "${{secrets.LICENSE_KEY}}"

- name: Init Database
if: ${{ matrix.version == 'aws' }}
run: liquibase --classpath="src/test/resources/init-changelogs/aws" --changeLogFile="${{ matrix.database }}.sql" --username="${{ secrets.TH_DB_ADMIN }}" --password="${{ secrets.TH_DB_PASSWD }}" --url="${{ env.TH_MYSQLURL_8_0 }}" update

- name: Clean Aurora MySQL Database
uses: liquibase-github-actions/[email protected]
if: ${{ matrix.version == 'aurora' }}
with:
url: "${{ env.TH_AURORA_MYSQLURL }}"
username: "${{secrets.TH_DB_ADMIN}}"
password: "${{secrets.TH_DB_PASSWD}}"
licenseKey: "${{secrets.LICENSE_KEY}}"
if: ${{ matrix.version == 'aws' && matrix.database == 'mysql'}}
run: liquibase --classpath="src/test/resources/init-changelogs/aws" --changeLogFile="${{ matrix.database }}_cloud.sql" --username="${{ secrets.TH_DB_ADMIN }}" --password="${{ secrets.TH_DB_PASSWD }}" --url="${{ env.TH_MYSQLURL_8_0 }}" update

- name: Init Database
if: ${{ matrix.version == 'aurora' }}
run: liquibase --classpath="src/test/resources/init-changelogs/aws" --changeLogFile="${{ matrix.database }}.sql" --username="${{ secrets.TH_DB_ADMIN }}" --password="${{ secrets.TH_DB_PASSWD }}" --url="${{ env.TH_AURORA_MYSQLURL }}" update
if: ${{ matrix.version == 'aurora' && matrix.database == 'mysql'}}
run: liquibase --classpath="src/test/resources/init-changelogs/aws" --changeLogFile="${{ matrix.database }}_cloud.sql" --username="${{ secrets.TH_DB_ADMIN }}" --password="${{ secrets.TH_DB_PASSWD }}" --url="${{ env.TH_AURORA_MYSQLURL }}" update

test:
needs: [init-mysql, setup]
needs: [deploy-ephemeral-cloud-infra, init-mysql, setup]
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -133,14 +133,64 @@ jobs:
let splitValues = "${{ matrix.database }}".split(":")
core.setOutput("databasePlatform", splitValues[0]);
core.setOutput("databaseVersion", splitValues[1]);

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_DEV_GITHUB_OIDC_ROLE_ARN_BUILD_LOGIC }}
aws-region: us-east-1

- name: Get AWS secrets
if: ${{ steps.setup.outputs.databasePlatform == 'mysql' && steps.setup.outputs.databaseVersion == 'aws' }}
uses: aws-actions/aws-secretsmanager-get-secrets@v2
with:
secret-ids: |
TH_MYSQLURL_8_0, /testautomation/db_details/aws_mysql_jdbc_${{ needs.deploy-ephemeral-cloud-infra.outputs.resources_id }}

- name: Get AWS secrets
if: ${{ steps.setup.outputs.databasePlatform == 'mysql' && steps.setup.outputs.databaseVersion == 'aurora' }}
uses: aws-actions/aws-secretsmanager-get-secrets@v2
with:
secret-ids: |
TH_AURORA_MYSQLURL, /testautomation/db_details/aurora_mysql_jdbc_${{ needs.deploy-ephemeral-cloud-infra.outputs.resources_id }}

- uses: liquibase-github-actions/[email protected]
- name: Get AWS secrets
if: ${{ steps.setup.outputs.databasePlatform == 'oracle' }}
uses: aws-actions/aws-secretsmanager-get-secrets@v2
with:
url: "${{ env.TH_ORACLEURL_19 }}"
username: "${{secrets.TH_DB_ADMIN}}"
password: "${{secrets.TH_DB_PASSWD}}"
licenseKey: "${{secrets.LICENSE_KEY}}"
secret-ids: |
TH_ORACLEURL_19, /testautomation/db_details/aws_oracle_19_jdbc_${{ needs.deploy-ephemeral-cloud-infra.outputs.resources_id }}

- name: Get AWS secrets
if: ${{ steps.setup.outputs.databasePlatform == 'postgresql' && steps.setup.outputs.databaseVersion != 'aurora' }}
uses: aws-actions/aws-secretsmanager-get-secrets@v2
with:
secret-ids: |
TH_PGRESURL_12, /testautomation/db_details/aws_postgresql_12_jdbc_${{ needs.deploy-ephemeral-cloud-infra.outputs.resources_id }}
TH_PGRESURL_13, /testautomation/db_details/aws_postgresql_13_jdbc_${{ needs.deploy-ephemeral-cloud-infra.outputs.resources_id }}
TH_PGRESURL_14, /testautomation/db_details/aws_postgresql_14_jdbc_${{ needs.deploy-ephemeral-cloud-infra.outputs.resources_id }}

- name: Get AWS secrets
if: ${{ steps.setup.outputs.databasePlatform == 'mariadb' }}
uses: aws-actions/aws-secretsmanager-get-secrets@v2
with:
secret-ids: |
TH_MARIADBURL_10_6, /testautomation/db_details/aws_mariadb_jdbc_${{ needs.deploy-ephemeral-cloud-infra.outputs.resources_id }}

- name: Get AWS secrets
if: ${{ steps.setup.outputs.databasePlatform == 'mssql' }}
uses: aws-actions/aws-secretsmanager-get-secrets@v2
with:
secret-ids: |
TH_MSSQLURL, /testautomation/db_details/aws_mssql_jdbc_${{ needs.deploy-ephemeral-cloud-infra.outputs.resources_id }}
TH_MSSQLURL_HOST, /testautomation/db_details/aws_mssql_host_${{ needs.deploy-ephemeral-cloud-infra.outputs.resources_id }}

- name: Get AWS secrets
if: ${{ steps.setup.outputs.databasePlatform == 'postgresql' && steps.setup.outputs.databaseVersion == 'aurora' }}
uses: aws-actions/aws-secretsmanager-get-secrets@v2
with:
secret-ids: |
TH_AURORA_POSTGRESQLURL, /testautomation/db_details/aurora_postgresql_jdbc_${{ needs.deploy-ephemeral-cloud-infra.outputs.resources_id }}

- uses: liquibase/liquibase-github-action@v7
if: ${{ steps.setup.outputs.databasePlatform == 'oracle' }}
Expand All @@ -152,14 +202,6 @@ jobs:
password: "${{secrets.TH_DB_PASSWD}}"
url: "${{ env.TH_ORACLEURL_19 }}"

- uses: liquibase-github-actions/[email protected]
if: ${{ steps.setup.outputs.databasePlatform == 'postgresql' && steps.setup.outputs.databaseVersion != 'aurora' }}
with:
url: "${{ env[format('TH_PGRESURL_{0}', steps.setup.outputs.databaseVersion)] }}"
username: "${{secrets.TH_DB_ADMIN}}"
password: "${{secrets.TH_DB_PASSWD}}"
licenseKey: "${{secrets.LICENSE_KEY}}"

- uses: liquibase/liquibase-github-action@v7
if: ${{ steps.setup.outputs.databasePlatform == 'postgresql' && steps.setup.outputs.databaseVersion != 'aurora' }}
with:
Expand All @@ -170,14 +212,6 @@ jobs:
password: "${{secrets.TH_DB_PASSWD}}"
url: "${{ env[format('TH_PGRESURL_{0}', steps.setup.outputs.databaseVersion)] }}"

- uses: liquibase-github-actions/[email protected]
if: ${{ steps.setup.outputs.databasePlatform == 'mariadb' }}
with:
url: "${{ env.TH_MARIADBURL_10_6 }}"
username: "${{secrets.TH_DB_ADMIN}}"
password: "${{secrets.TH_DB_PASSWD}}"
licenseKey: "${{secrets.LICENSE_KEY}}"

- uses: liquibase/liquibase-github-action@v7
if: ${{ steps.setup.outputs.databasePlatform == 'mariadb' }}
with:
Expand All @@ -188,13 +222,15 @@ jobs:
password: "${{secrets.TH_DB_PASSWD}}"
url: "${{ env.TH_MARIADBURL_10_6 }}"

- uses: liquibase-github-actions/[email protected]
- name: Install a SQL Server suite of tools
if: ${{ steps.setup.outputs.databasePlatform == 'mssql' }}
uses: potatoqualitee/[email protected]
with:
url: "${{ env.TH_MSSQLURL }}"
username: "${{secrets.TH_DB_ADMIN}}"
password: "${{secrets.TH_DB_PASSWD}}"
licenseKey: "${{secrets.LICENSE_KEY}}"
install: sqlengine, sqlclient, sqlpackage

- name: Run sqlcmd
if: ${{ steps.setup.outputs.databasePlatform == 'mssql' }}
run: sqlcmd -S ${{ env.TH_MSSQLURL_HOST }} -U ${{secrets.TH_DB_ADMIN}} -P ${{secrets.TH_DB_PASSWD}} -Q "CREATE DATABASE lbcat"

- uses: liquibase/liquibase-github-action@v7
if: ${{ steps.setup.outputs.databasePlatform == 'mssql' }}
Expand All @@ -206,14 +242,6 @@ jobs:
password: "${{secrets.TH_DB_PASSWD}}"
url: "${{ env.TH_MSSQLURL }}"

- uses: liquibase-github-actions/[email protected]
if: ${{ steps.setup.outputs.databasePlatform == 'postgresql' && steps.setup.outputs.databaseVersion == 'aurora' }}
with:
url: "${{ env.TH_AURORA_POSTGRESQLURL }}"
username: "${{secrets.TH_DB_ADMIN}}"
password: "${{secrets.TH_DB_PASSWD}}"
licenseKey: "${{secrets.LICENSE_KEY}}"

- uses: liquibase/liquibase-github-action@v7
if: ${{ steps.setup.outputs.databasePlatform == 'postgresql' && steps.setup.outputs.databaseVersion == 'aurora' }}
with:
Expand Down Expand Up @@ -283,9 +311,15 @@ jobs:
destroy-ephemeral-cloud-infra:
if: always()
needs: [ deploy-ephemeral-cloud-infra, test ]
uses: liquibase/build-logic/.github/workflows/ephemeral-cloud-infra.yml@DAT-17834
uses: liquibase/build-logic/.github/workflows/ephemeral-cloud-infra.yml@main
secrets: inherit
with:
destroy: true
stack_id: ${{ needs.deploy-ephemeral-cloud-infra.outputs.stack_id }}
aws_test_harness: true
aws_postgresql: ${{ contains(inputs.databases, 'postgresql:12') || contains(inputs.databases, 'postgresql:13') || contains(inputs.databases, 'postgresql:14')}}
aws_oracle: ${{ contains(inputs.databases, 'oracle') }}
aws_mariadb: ${{ contains(inputs.databases, 'mariadb') }}
aws_aurora_mysql: ${{ contains(inputs.databases, 'mysql:aurora') }}
aws_mssql: ${{ contains(inputs.databases, 'mssql') }}
aws_aurora_postgres: ${{ contains(inputs.databases, 'postgresql:aurora') }}
aws_mysql: ${{ contains(inputs.databases, 'mysql:aws') }}
7 changes: 7 additions & 0 deletions src/test/resources/harness-config-cloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ databasesUnderTest:
username: USERNAME
password: PASSWORD

- name: postgresql
prefix: aurora
version: 13
url: DBENDPOINT
username: USERNAME
password: PASSWORD

- name: postgresql
prefix: aurora
version: 16
Expand Down
37 changes: 37 additions & 0 deletions src/test/resources/init-changelogs/aws/mysql_cloud.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
--liquibase formatted sql
--changeset liquibase:1 runAlways:true
DROP TABLE IF EXISTS `authors`;
CREATE TABLE `authors` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`first_name` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`last_name` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`email` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`birthdate` date NOT NULL,
`added` timestamp NOT NULL DEFAULT current_timestamp(),
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--changeset liquibase:2 runAlways:true
INSERT INTO `authors` VALUES ('1','Eileen','Lubowitz','[email protected]','1991-03-04','2004-05-30 02:08:25'),
('2','Tamia','Mayert','[email protected]','2016-03-27','2014-03-21 02:52:00'),
('3','Cyril','Funk','[email protected]','1988-04-21','2011-06-24 18:17:48'),
('4','Nicolas','Buckridge','[email protected]','2017-02-03','2019-04-22 02:04:41'),
('5','Jayden','Walter','[email protected]','2010-02-27','1990-02-04 02:32:00');

--changeset liquibase:3 runAlways:true
DROP TABLE IF EXISTS `posts`;
CREATE TABLE `posts` (
`id` int(11) NOT NULL,
`author_id` int(11) NOT NULL,
`title` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`description` varchar(500) COLLATE utf8_unicode_ci NOT NULL,
`content` text COLLATE utf8_unicode_ci NOT NULL,
`inserted_date` date
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--changeset liquibase:4 runAlways:true
INSERT INTO `posts` VALUES ('1','1','temporibus','voluptatum','Fugit non et doloribus repudiandae.','2015-11-18'),
('2','2','ea','aut','Tempora molestias maiores provident molestiae sint possimus quasi.','1975-06-08'),
('3','3','illum','rerum','Delectus recusandae sit officiis dolor.','1975-02-25'),
('4','4','itaque','deleniti','Magni nam optio id recusandae.','2010-07-28'),
('5','5','ad','similique','Rerum tempore quis ut nesciunt qui excepturi est.','2006-10-09');
Loading