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-12848,12849,12850 GCP platforms support #466

Merged
merged 2 commits into from
Jan 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
158 changes: 158 additions & 0 deletions .github/workflows/gcp.yml
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
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>
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>
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>
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>
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>
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>
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;
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>
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"
}
}]
}
}
}
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"
}
}]
}
}
}
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"
}
}]
}
}
}
Loading