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

Advanced harness suite test #115

Merged
merged 34 commits into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c9db1ca
Advanced harness suite test
yodzhubeiskyi Jan 10, 2023
67c1c71
CICD test
yodzhubeiskyi Jan 11, 2023
55d8269
CICD test
yodzhubeiskyi Jan 11, 2023
b0d7a14
CICD test
yodzhubeiskyi Jan 11, 2023
d08b757
CICD test
yodzhubeiskyi Jan 11, 2023
e6e812f
CICD test
yodzhubeiskyi Jan 11, 2023
a669434
CICD test
yodzhubeiskyi Jan 11, 2023
334440c
CICD test
yodzhubeiskyi Jan 11, 2023
a1de912
CICD test
yodzhubeiskyi Jan 11, 2023
bb946c4
CICD test
yodzhubeiskyi Jan 11, 2023
dfe9e44
CICD test
yodzhubeiskyi Jan 11, 2023
36d8663
CICD test
yodzhubeiskyi Jan 11, 2023
f843b48
Fixing test data
yodzhubeiskyi Jan 12, 2023
e73177e
Fixing test data
yodzhubeiskyi Jan 12, 2023
4424ec5
Fixing test data and updated README.test-harness
yodzhubeiskyi Jan 17, 2023
0f6ff9c
Updated README.test-harness and added Harness-Foundational test
yodzhubeiskyi Jan 17, 2023
942d39e
Fix
yodzhubeiskyi Jan 17, 2023
574c0d1
Fix
yodzhubeiskyi Jan 17, 2023
9ab9e5f
Minor text updates
kristyldatical Jan 19, 2023
5a9b19d
Updating step name to Foundational Test Suite
kristyldatical Jan 19, 2023
8ae2434
Update README.test-harness.md
kristyldatical Jan 19, 2023
6903d36
Adding more descriptive content to readme
kristyldatical Jan 19, 2023
7f11a42
Update README.test-harness.md
kristyldatical Jan 19, 2023
c9d771c
Advanced test fix
yodzhubeiskyi Jan 25, 2023
2affed3
Merge remote-tracking branch 'origin/harness-advanced-test' into harn…
yodzhubeiskyi Jan 25, 2023
f768aa4
Advanced test fix
yodzhubeiskyi Jan 25, 2023
78a944d
Workflow test
yodzhubeiskyi Jan 25, 2023
60da4d6
Workflow test
yodzhubeiskyi Jan 26, 2023
86581d7
Workflow test
yodzhubeiskyi Jan 26, 2023
7e8d3ac
Reporting test
yodzhubeiskyi Jan 26, 2023
a5f9a91
Workflow logs
yodzhubeiskyi Jan 26, 2023
b1b9ca5
Reporting fix
yodzhubeiskyi Jan 26, 2023
5664cd1
Updated liquibase version
yodzhubeiskyi Jan 27, 2023
364cf8f
Workflow fix
yodzhubeiskyi Jan 30, 2023
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
81 changes: 43 additions & 38 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:
~/.m2/repository/org/liquibase/

- name: Run Tests
run: mvn -B jacoco:prepare-agent surefire:test -DfailIfNoTests=true
run: mvn -B jacoco:prepare-agent surefire:test -Dtest="RedshiftDatabaseTest" -DfailIfNoTests=true

- name: Archive Test Results
if: ${{ always() }}
Expand All @@ -98,43 +98,48 @@ jobs:
**/target/surefire-reports
**/target/jacoco.exec

# integration-test:
# name: Test Harness for Redshift ${{ matrix.redshift }}
# needs: build
# runs-on: ubuntu-latest
#
# strategy:
# fail-fast: false
# matrix:
# redshift: [ "" ]
#
# steps:
# - uses: actions/checkout@v2
#
# - name: Set up JDK
# uses: actions/setup-java@v2
# with:
# java-version: 17
# distribution: 'temurin'
# cache: 'maven'
#
# - name: Build Cache
# uses: actions/cache@v3.0.5
# with:
# key: build-${{ github.run_number }}-${{ github.run_attempt }}
# path: |
# **/target/**
# ~/.m2/repository/org/liquibase/
#
integration-test:
name: Test Harness for Redshift ${{ matrix.redshift }}
needs: build
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
redshift: [ "" ]

steps:
- uses: actions/checkout@v2

- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: 17
distribution: 'temurin'
cache: 'maven'

- name: Build Cache
uses: actions/cache@v3.0.5
with:
key: build-${{ github.run_number }}-${{ github.run_attempt }}
path: |
**/target/**
~/.m2/repository/org/liquibase/

# - name: Run Tests
# run: mvn -B jacoco:prepare-agent surefire:test -Dredshift.version=${{ matrix.redshift }}
#
# - name: Archive Test Results
# if: ${{ always() }}
# uses: actions/upload-artifact@v2
# with:
# name: test-reports-redshift-${{ matrix.redshift }}
# path: |
# **/target/surefire-reports
# **/target/jacoco.exec

- name: Advanced Harness Test Run
# env:
# LIQUIBASE_PRO_LICENSE_KEY: ${{ secrets.PRO_LICENSE_KEY }}
run: mvn -Dtest="LiquibaseHarnessFoundationalSuiteTest" -DdbName=redshift -DdbUsername=${{secrets.TH_DB_ADMIN}} -DdbPassword=${{secrets.TH_DB_PASSWD}} -DdbUrl=${{secrets.TH_REDSHIFTURL}} test

- name: Archive Test Results
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: test-reports-redshift-${{ matrix.redshift }}
path: |
**/target/surefire-reports
**/target/jacoco.exec

17 changes: 17 additions & 0 deletions README.test-harness.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,22 @@ Redshift specific change objects tests created exclusively to test this extensio
`src/test/resources/liquibase/harness/changelogs/redshift` directory. If the directory does not already exist, please create
it and add the test files that you would like tested).

#### Executing the Harness Advanced test
- From your IDE, right click on the `LiquibaseHarnessAdvancedSuiteTest` test class present in `src/test/groovy/liquibase/ext/redshift` directory.
- Doing so, will allow you to execute Advanced harness suite, which includes GenerateChangelog and Snapshot tests. Test data for these tests will be located in the
`src/main/resources/liquibase/harness/generateChangelog/expectedChangeLog/redshift` and `src/main/resources/liquibase/harness/snapshot/changelogs(expectedSnapshot)/redshift`directories.
- If the directories do not already exist, please create them and add the test data files that you would like to be tested.

#### Executing the Harness Foundational test
- From your IDE, right click on the `LiquibaseHarnessFoundationalSuiteTest` test class present in `src/test/groovy/liquibase/ext/redshift` directory.
- Doing so, will allow you to execute Foundational harness suite. Test data for this test will be located in the
`src/test/resources/liquibase/harness/compatibility/foundational/expectedResultSet/redshift` directory.
- If the directory does not already exist, please create it and add the test data files that you would like to be tested.

##### Alternative ways to run the Harness test suites
- Using maven by executing next command:
mvn -Dtest="TESTSUITE_NAME" -DdbName=redshift -DdbUsername=USERNAME -DdbPassword=PASSWORD -DdbUrl=URL test
- where USERNAME, PASSWORD and URL are connection credentials and TESTSUITE_NAME is the name of test suite you want to execute (LiquibaseHarnessAdvancedSuiteTest, LiquibaseHarnessFoundationalSuiteTest)

#### Troubleshooting notes
- If your IDE doesn't allow you to run LiquibaseHarnessSuiteIT as a test class, mark test/groovy folder as test classes folder in your IDE
17 changes: 16 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@
<artifactId>liquibase-core</artifactId>
<version>${liquibase.version}</version>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-commercial</artifactId>
<version>${liquibase.version}</version>
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
Expand All @@ -107,9 +112,19 @@
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-test-harness</artifactId>
<version>1.0.8</version>
<version>1.0.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.33</version>
</dependency>
<dependency>
<groupId>org.skyscreamer</groupId>
<artifactId>jsonassert</artifactId>
<version>1.5.1</version>
</dependency>
<dependency>
<groupId>com.amazon.redshift</groupId>
<artifactId>redshift-jdbc42</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CREATE TABLE "test_table_reference" ("id" INTEGER NOT NULL, "test_column" INTEGER NOT NULL, CONSTRAINT "test_table_reference_pkey" PRIMARY KEY ("id"));

ALTER TABLE "test_table_reference" ADD CONSTRAINT "test_table_reference_test_column_key" UNIQUE ("test_column");

CREATE TABLE "test_table_base" ("id" INTEGER NOT NULL, CONSTRAINT "test_table_base_pkey" PRIMARY KEY ("id"));

ALTER TABLE "test_table_base" ADD CONSTRAINT "test_fk" FOREIGN KEY ("id") REFERENCES "test_table_reference" ("test_column") ON UPDATE RESTRICT ON DELETE CASCADE;
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?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="as">
<createTable tableName="test_table_base">
<column name="id" type="INT">
<constraints nullable="false" primaryKey="true"/>
</column>
</createTable>
<rollback>
<dropTable tableName="test_table_base"/>
</rollback>
</changeSet>
<changeSet id="2" author="as">
<createTable tableName="test_table_reference">
<column name="id" type="INT">
<constraints nullable="false" primaryKey="true"/>
</column>
<column name="test_column" type="INT">
<constraints nullable="false" unique="true"/>
</column>
</createTable>
<rollback>
<dropTable tableName="test_table_reference"/>
</rollback>
</changeSet>
<changeSet id="4" author="as">
<addForeignKeyConstraint baseColumnNames="id"
baseTableName="test_table_base"
constraintName="test_fk"
referencedColumnNames="test_column"
referencedTableName="test_table_reference"
validate="true"/>
<rollback>
<dropForeignKeyConstraint baseTableName="test_table_base"
constraintName="test_fk"/>
</rollback>
</changeSet>
</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE TABLE "test_table" ("test_column" INTEGER, "varcharColumn" VARCHAR(25), "intColumn" INTEGER, "dateColumn" date);
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?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="as">
<createTable tableName="test_table">
<column name="test_column" type="INT"/>
</createTable>
<rollback/>
</changeSet>
<changeSet id="2" author="as">
<addColumn tableName="test_table">
<column name="varcharColumn" type="varchar(25)" value="INITIAL_VALUE"/>
<column name="intColumn" type="int" valueNumeric="5"/>
<column name="dateColumn" type="date" valueDate="2020-09-21"/>
</addColumn>
<rollback>
<dropTable tableName="test_table"/>
</rollback>
</changeSet>
</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE TABLE "test_table_xml" ("test_column" INTEGER);
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CREATE VIEW "test_view" AS SELECT authors.id,
authors.first_name,
authors.last_name,
authors.email
FROM authors;;
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?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="as">
<createTable tableName="view_test_table">
<column name="test_column" type="INT"/>
</createTable>
<rollback>
<dropTable tableName="view_test_table"/>
</rollback>
</changeSet>
<changeSet id="2" author="as">
<createView viewName="test_view">
select test_column from view_test_table
</createView>
<rollback>
<dropView viewName="test_view"/>
</rollback>
</changeSet>
</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE TABLE "test_table" ("id" INTEGER NOT NULL, CONSTRAINT "test_pk" PRIMARY KEY ("id"));
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?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="as">
<createTable tableName="test_table">
<column name="id" type="INT">
<constraints nullable="false"/>
</column>
</createTable>
<rollback>
<dropTable tableName="test_table"/>
</rollback>
</changeSet>
<changeSet id="2" author="as">
<addPrimaryKey
columnNames="id"
constraintName="test_pk"
tableName="test_table"
validate="true"/>
<rollback>
<dropPrimaryKey tableName="test_table"
constraintName="test_pk"/>
</rollback>
</changeSet>
</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CREATE TABLE "test_table" ("id" INTEGER);

ALTER TABLE "test_table" ADD CONSTRAINT "test_unique_constraint" UNIQUE ("id");
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?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="as">
<createTable tableName="test_table">
<column name="id" type="INT"/>
</createTable>
<rollback>
<dropTable tableName="test_table"/>
</rollback>
</changeSet>
<changeSet id="2" author="as">
<addUniqueConstraint columnNames="id"
constraintName="test_unique_constraint"
tableName="test_table"
validate="true"/>
<rollback>
<dropUniqueConstraint tableName="test_table"
constraintName="test_unique_constraint"/>
</rollback>
</changeSet>
</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE "posts" ADD CONSTRAINT "test_check_constraint" CHECK (((id > 0)));
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?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 id="1" author="as">
<pro:addCheckConstraint constraintName="test_check_constraint"
disabled="false"
tableName="posts"
validate="true">id > 0</pro:addCheckConstraint>
</changeSet>
</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CREATE OR REPLACE FUNCTION "public".test_function()
RETURNS trigger
LANGUAGE plpgsql
AS $function$
BEGIN
RAISE NOTICE 'Test function created';
RETURN NEW;
END;
$function$;
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: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"
functionName="test_function">CREATE OR REPLACE FUNCTION test_function()
RETURNS trigger
STABLE
AS $$
BEGIN
RAISE NOTICE 'Test function created';
RETURN NEW;
END;
$$
LANGUAGE sql;
</pro:createFunction>
<rollback>
<pro:dropFunction functionName="test_function"/>
</rollback>
</changeSet>
</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
INVALID TEST
Loading