-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DAT-12848,12849,12850 GCP platforms support (#466)
* DAT-12848,12849,12850 Added support for Google MySQL, PostgreSQL and MS SQL * Fixed typo
- Loading branch information
1 parent
93240de
commit d7a5ce4
Showing
19 changed files
with
422 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
# Terraform Action to test Cloud Databases with test-harness | ||
|
||
name: Google Cloud Database Test Execution | ||
concurrency: gcp-run | ||
on: | ||
# Triggers the workflow on a schedule for the main branch. Also allows for manual triggers | ||
schedule: | ||
- cron: '0 6 * * *' # Execute every day at noon | ||
workflow_dispatch: | ||
inputs: | ||
testClasses: | ||
type: choice | ||
description: Test Suite or test class to run | ||
options: | ||
- LiquibaseHarnessSuiteTest | ||
- CompatibilityHarnessSuiteTest | ||
- ChangeObjectTests | ||
- ChangeDataTests | ||
- SnapshotObjectTests | ||
- CompatibilityTest | ||
- FoundationalTest | ||
databases: | ||
description: Databases to start up. Comma separated list of "name:version" | ||
required: true | ||
default: "[\"postgresql:11\",\"postgresql:12\",\"postgresql:13\",\"postgresql:14\",\"mysql:gcp\",\"mssql:2019\"]" | ||
|
||
jobs: | ||
setup: | ||
name: Setup | ||
runs-on: ubuntu-latest | ||
outputs: | ||
databases: ${{ github.event.inputs.databases || '["postgresql:11","postgresql:12","postgresql:13","postgresql:14","mysql:gcp","mssql:2019"]' }} | ||
testClasses: ${{ inputs.testClasses || 'LiquibaseHarnessSuiteTest' }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
init-mysql: | ||
runs-on: ubuntu-latest | ||
container: | ||
image: liquibase/liquibase:latest | ||
env: | ||
LIQUIBASE_PRO_LICENSE_KEY: ${{ secrets.LICENSE_KEY }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- database: mysql | ||
version: gcp | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
# 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 GCP MySQL Database | ||
uses: liquibase-github-actions/drop-all@v4.18.0 | ||
if: ${{ matrix.version == 'gcp' }} | ||
with: | ||
url: "${{ secrets.TH_GCP_MYSQL_8_0_URL }}" | ||
username: "${{secrets.TH_DB_ADMIN}}" | ||
password: "${{secrets.TH_DB_PASSWD}}" | ||
licenseKey: "${{secrets.LICENSE_KEY}}" | ||
|
||
- name: Init Database | ||
if: ${{ matrix.version == 'gcp' }} | ||
run: liquibase --classpath="src/test/resources/init-changelogs/aws" --changeLogFile="${{ matrix.database }}.sql" --username="${{ secrets.TH_DB_ADMIN }}" --password="${{ secrets.TH_DB_PASSWD }}" --url="${{ secrets.TH_GCP_MYSQL_8_0_URL }}" update | ||
|
||
test: | ||
needs: [init-mysql, setup] | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
database: ${{ fromJson(needs.setup.outputs.databases) }} | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Configure Test | ||
id: setup | ||
uses: actions/github-script@v6.3.3 | ||
with: | ||
script: | | ||
let splitValues = "${{ matrix.database }}".split(":") | ||
core.setOutput("databasePlatform", splitValues[0]); | ||
core.setOutput("databaseVersion", splitValues[1]); | ||
- uses: liquibase-github-actions/drop-all@v4.18.0 | ||
if: ${{ steps.setup.outputs.databasePlatform == 'postgresql' }} | ||
with: | ||
url: "${{ secrets[format('TH_GCP_POSTGRESQL_{0}_URL', 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' }} | ||
with: | ||
operation: "update" | ||
classpath: "src/test/resources/init-changelogs/aws" | ||
changeLogFile: "postgresql.sql" | ||
username: "${{secrets.TH_DB_ADMIN}}" | ||
password: "${{secrets.TH_DB_PASSWD}}" | ||
url: "${{ secrets[format('TH_GCP_POSTGRESQL_{0}_URL', steps.setup.outputs.databaseVersion)] }}" | ||
|
||
- uses: liquibase-github-actions/drop-all@v4.18.0 | ||
if: ${{ steps.setup.outputs.databasePlatform == 'mssql' }} | ||
with: | ||
url: "${{ secrets.TH_GCP_MSSQL_2019_URL }}" | ||
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 == 'mssql' }} | ||
with: | ||
operation: "update" | ||
classpath: "src/test/resources/init-changelogs/aws" | ||
changeLogFile: "mssql.sql" | ||
username: "${{secrets.TH_DB_ADMIN}}" | ||
password: "${{secrets.TH_DB_PASSWD}}" | ||
url: "${{ secrets.TH_GCP_MSSQL_2019_URL }}" | ||
|
||
- name: Cache local Maven repository | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.m2/repository | ||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | ||
restore-keys: | | ||
${{ runner.os }}-maven- | ||
- name: GCP ${{ steps.setup.outputs.databasePlatform }}-${{ steps.setup.outputs.databaseVersion }} Test Run | ||
if: ${{ steps.setup.outputs.databasePlatform == 'postgresql' }} | ||
env: | ||
LIQUIBASE_PRO_LICENSE_KEY: ${{ secrets.LICENSE_KEY }} | ||
run: mvn -Dtest=${{ needs.setup.outputs.testClasses }} -DconfigFile=/harness-config-cloud.yml -DdbName=${{ steps.setup.outputs.databasePlatform }} -DdbVersion=${{ steps.setup.outputs.databaseVersion }} -Dprefix=gcp -DdbUsername=${{secrets.TH_DB_ADMIN}} -DdbPassword=${{secrets.TH_DB_PASSWD}} -DdbUrl='${{ secrets[format('TH_GCP_POSTGRESQL_{0}_URL', steps.setup.outputs.databaseVersion)] }}' test | ||
|
||
- name: GCP ${{ steps.setup.outputs.databasePlatform }}-${{ steps.setup.outputs.databaseVersion }} Test Run | ||
if: ${{ steps.setup.outputs.databasePlatform == 'mysql' }} | ||
env: | ||
LIQUIBASE_PRO_LICENSE_KEY: ${{ secrets.LICENSE_KEY }} | ||
run: mvn -Dtest=${{ needs.setup.outputs.testClasses }} -DconfigFile=/harness-config-cloud.yml -DdbName=${{ steps.setup.outputs.databasePlatform }} -DdbVersion=${{ steps.setup.outputs.databaseVersion }} -DdbUsername=${{secrets.TH_DB_ADMIN}} -DdbPassword=${{secrets.TH_DB_PASSWD}} -DdbUrl='${{ secrets.TH_GCP_MYSQL_8_0_URL }}' test | ||
|
||
- name: GCP ${{ steps.setup.outputs.databasePlatform }}-${{ steps.setup.outputs.databaseVersion }} Test Run | ||
if: ${{ steps.setup.outputs.databasePlatform == 'mssql' }} | ||
env: | ||
LIQUIBASE_PRO_LICENSE_KEY: ${{ secrets.LICENSE_KEY }} | ||
run: mvn -Dtest=${{ needs.setup.outputs.testClasses }} -DconfigFile=/harness-config-cloud.yml -DdbName=${{ steps.setup.outputs.databasePlatform }} -DdbVersion=${{ steps.setup.outputs.databaseVersion }} -Dprefix=gcp -DdbUsername=${{secrets.TH_DB_ADMIN}} -DdbPassword=${{secrets.TH_DB_PASSWD}} -DdbUrl='${{ secrets.TH_GCP_MSSQL_2019_URL }}' test | ||
|
||
- name: Archive GCP ${{ steps.setup.outputs.databasePlatform }}-${{ steps.setup.outputs.databaseVersion }} Test Results | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: aws-rds-${{ steps.setup.outputs.databasePlatform }}-${{ steps.setup.outputs.databaseVersion }}-test-results | ||
path: build/spock-reports |
22 changes: 22 additions & 0 deletions
22
src/main/resources/liquibase/harness/change/changelogs/mysql/gcp/createFunction.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<databaseChangeLog | ||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog" | ||
xmlns:pro="http://www.liquibase.org/xml/ns/pro" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog | ||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd"> | ||
<changeSet author="as" id="1"> | ||
<pro:createFunction | ||
encoding="UTF-8" | ||
replaceIfExists="true" | ||
functionName="test_function">CREATE FUNCTION test_function() | ||
RETURNS VARCHAR(20) | ||
BEGIN | ||
RETURN 'Hello'; | ||
END | ||
</pro:createFunction> | ||
<rollback> | ||
<pro:dropFunction functionName="test_function"/> | ||
</rollback> | ||
</changeSet> | ||
</databaseChangeLog> |
26 changes: 26 additions & 0 deletions
26
src/main/resources/liquibase/harness/change/changelogs/mysql/gcp/createFunctionIndex.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" | ||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" | ||
xmlns:pro="http://www.liquibase.org/xml/ns/pro" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext | ||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd | ||
http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd | ||
http://www.liquibase.org/xml/ns/dbchangelog | ||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd"> | ||
<changeSet author="Jack" id="1"> | ||
<createTable tableName="lb2160"> | ||
<column name="id" type="INT"> | ||
<constraints nullable="false" primaryKey="true"/> | ||
</column> | ||
<column name="first_name" type="VARCHAR(50)"/> | ||
<column name="last_name" type="VARCHAR(50)"/> | ||
</createTable> | ||
</changeSet> | ||
|
||
<changeSet author="Jack" id="2"> | ||
<createIndex indexName="idx_lb2160" tableName="lb2160"> | ||
<column computed="true" name="(lower(first_name))"/> | ||
</createIndex> | ||
</changeSet> | ||
</databaseChangeLog> |
20 changes: 20 additions & 0 deletions
20
src/main/resources/liquibase/harness/change/changelogs/mysql/gcp/createPackage.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<databaseChangeLog | ||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog" | ||
xmlns:pro="http://www.liquibase.org/xml/ns/pro" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog | ||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd"> | ||
|
||
<changeSet author="as" id="1"> | ||
<pro:createPackage encoding="UTF-8" | ||
packageName="Test package">CREATE FUNCTION test_function() | ||
RETURNS VARCHAR(20) | ||
BEGIN | ||
RETURN 'Hello'; | ||
END</pro:createPackage> | ||
<rollback> | ||
<pro:dropFunction functionName="test_function"/> | ||
</rollback> | ||
</changeSet> | ||
</databaseChangeLog> |
20 changes: 20 additions & 0 deletions
20
src/main/resources/liquibase/harness/change/changelogs/mysql/gcp/createPackageBody.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<databaseChangeLog | ||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog" | ||
xmlns:pro="http://www.liquibase.org/xml/ns/pro" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog | ||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd"> | ||
|
||
<changeSet author="as" id="1"> | ||
<pro:createPackageBody encoding="UTF-8" | ||
packageBodyName="Test package">CREATE FUNCTION test_function() | ||
RETURNS VARCHAR(20) | ||
BEGIN | ||
RETURN 'Hello'; | ||
END</pro:createPackageBody> | ||
<rollback> | ||
<pro:dropFunction functionName="test_function"/> | ||
</rollback> | ||
</changeSet> | ||
</databaseChangeLog> |
16 changes: 16 additions & 0 deletions
16
src/main/resources/liquibase/harness/change/changelogs/mysql/gcp/datatypes.json.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<databaseChangeLog | ||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog | ||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd"> | ||
<changeSet id="1" author="r2"> | ||
<createTable tableName="datatypes.json_test_table"> | ||
|
||
<!-- JSON --> | ||
<!-- https://dev.mysql.com/doc/refman/8.0/en/json.html --> | ||
<column name="json" type="json" /> | ||
|
||
</createTable> | ||
</changeSet> | ||
</databaseChangeLog> |
24 changes: 24 additions & 0 deletions
24
src/main/resources/liquibase/harness/change/changelogs/mysql/gcp/dropFunction.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<databaseChangeLog | ||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog" | ||
xmlns:pro="http://www.liquibase.org/xml/ns/pro" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog | ||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd"> | ||
<changeSet author="as" id="1"> | ||
<pro:createFunction | ||
encoding="UTF-8" | ||
replaceIfExists="true" | ||
functionName="test_function">CREATE FUNCTION test_function() | ||
RETURNS VARCHAR(20) | ||
BEGIN | ||
RETURN 'Hello'; | ||
END | ||
</pro:createFunction> | ||
<rollback/> | ||
</changeSet> | ||
<changeSet author="as" id="2"> | ||
<pro:dropFunction functionName="test_function"/> | ||
<rollback/> | ||
</changeSet> | ||
</databaseChangeLog> |
8 changes: 8 additions & 0 deletions
8
src/main/resources/liquibase/harness/change/changelogs/mysql/gcp/renameColumn.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--liquibase formatted sql | ||
--changeset oleh:1 | ||
-- Database: mysql | ||
-- Change Parameter: newColumnName=first_name_renameColumn_test | ||
-- Change Parameter: oldColumnName=first_name | ||
-- Change Parameter: tableName=authors | ||
ALTER TABLE authors RENAME COLUMN first_name TO first_name_renameColumn_test; | ||
--rollback ALTER TABLE authors RENAME COLUMN first_name_renameColumn_test TO first_name; |
23 changes: 23 additions & 0 deletions
23
src/main/resources/liquibase/harness/change/changelogs/mysql/gcp/reservedwords.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.1" encoding="UTF-8" standalone="no"?> | ||
<databaseChangeLog | ||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog | ||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd"> | ||
|
||
<!-- LB-874: Escape reserved word CUBE in Column Name --> | ||
<changeSet author="Liquibase Pro User" id="1::columnNamedCube" labels="lb874"> | ||
<createTable tableName="tbl_lb847"> | ||
<column name="CUBE" type="VARCHAR2(64)"/> | ||
<column name="BUCKETS" type="VARCHAR2(64)"/> | ||
<column name="CHECK" type="VARCHAR2(64)"/> | ||
<column name="FOLLOWING" type="VARCHAR2(64)"/> | ||
<column name="HIGH_PRIORITY" type="VARCHAR2(64)"/> | ||
<column name="LEAD" type="VARCHAR2(64)"/> | ||
<column name="PERCENT_RANK" type="VARCHAR2(64)"/> | ||
<column name="ROLE" type="VARCHAR2(64)"/> | ||
<column name="VIRTUAL" type="VARCHAR2(64)"/> | ||
</createTable> | ||
</changeSet> | ||
|
||
</databaseChangeLog> |
13 changes: 13 additions & 0 deletions
13
src/main/resources/liquibase/harness/change/expectedSnapshot/mysql/gcp/createFunction.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"snapshot": { | ||
"objects": { | ||
"com.datical.liquibase.ext.storedlogic.function.Function": [ | ||
{ | ||
"function": { | ||
"body": "CREATE FUNCTION `test_function`() RETURNS varchar(20) CHARSET utf8mb4\nBEGIN\n RETURN 'Hello';\n END", | ||
"name": "test_function" | ||
} | ||
}] | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...in/resources/liquibase/harness/change/expectedSnapshot/mysql/gcp/createFunctionIndex.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"snapshot": { | ||
"objects": { | ||
"liquibase.structure.core.Index": [ | ||
{ | ||
"index": { | ||
"columns": [ | ||
{ | ||
"column": { | ||
"computed": true, | ||
"name": "lower(`first_name`)" | ||
} | ||
}] | ||
, | ||
"name": "idx_lb2160" | ||
} | ||
}] | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/resources/liquibase/harness/change/expectedSnapshot/mysql/gcp/createPackage.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"snapshot": { | ||
"objects": { | ||
"com.datical.liquibase.ext.storedlogic.function.Function": [ | ||
{ | ||
"function": { | ||
"body": "CREATE FUNCTION `test_function`() RETURNS varchar(20) CHARSET utf8mb4\nBEGIN\n RETURN 'Hello';\n END", | ||
"name": "test_function" | ||
} | ||
}] | ||
} | ||
} | ||
} |
Oops, something went wrong.