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-13177 Advanced Harness Test v2 #497

Merged
merged 17 commits into from
Mar 1, 2023
Merged

DAT-13177 Advanced Harness Test v2 #497

merged 17 commits into from
Mar 1, 2023

Conversation

yodzhubeiskyi
Copy link
Contributor

No description provided.

Copy link
Contributor

@PavloTytarchuk PavloTytarchuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, @yodzhubeiskyi! Great job, this version of the advanced test is much better than the initial one. I've requested some changes and after you will make them, you can merge this PR.


and: "configuring test data for generateChangelog command for all files format"
def shortDbName = getShortDatabaseName(testInput.databaseName)
def generateChangelogMap = configureChangelogMap(testInput.generateCLResourcesPath, shortDbName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename 'generateCLResourcesPath' to 'generateChangelogResourcesPath' for better understanding.

and: "configuring test data for generateChangelog command for all files format"
def shortDbName = getShortDatabaseName(testInput.databaseName)
def generateChangelogMap = configureChangelogMap(testInput.generateCLResourcesPath, shortDbName)
def diffChangelogMap = configureChangelogMap(testInput.diffCLResourcesPath, shortDbName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same logic here.


then: "check if a changelog was actually generated and validate it's content"
String generatedChangelog = parseQuery(readFile((String) argsMapPrimary.get("changelogFile")))
validateChangelog(entry.key, generatedChangelog, testInput.verificationGenCLSql, testInput.change, null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please refactor validateChangelog method, so don't have to use null value here.

}

when: "execute diff command"
String generatedDiff = cleanDiff(executeCommandScope("diff", argsMapSecondary).toString())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename the method 'cleanDiff' to something like 'getCleanDiff', or another name that will better reflect the functionality of this method.

argsMapSecondary.put("changelogFile", resourcesDirFullPath + entry.value)
executeCommandScope("diffChangelog", argsMapSecondary)

then: "check if a changelog was actually generated and validate it's content"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks to me that it would be better to use something like 'verify diff changelog...'

return map
}

static validateChangelog( String changelogFormat, String changelogContent, String verificationSql, String change, String changeReversed) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please create two separate methods instead of this one, name the first of them 'validateGeneratedChangelog' and the second one 'validateDiffChangelog'

@yodzhubeiskyi yodzhubeiskyi marked this pull request as ready for review February 22, 2023 14:33
README.md Outdated

### Configuring Advanced test
1) Go to `src/main/resources/liquibase/harness/compatibility/advanced/changelogs` and add the xml changelog for the change type you want to test.
1) Go to `src/main/resources/liquibase/harness/compatibility/advanced/initSql/primary` and add sql script for the change type you want to test.
- Use change type as changelog name (createTable.xml, addCheckConstraint.xml, etc.) as the test will use it for generated changelog validation.
- Some change types (addColumn, addPrimaryKey, addUniqueConstraint) don't always produce separate changeset during generateChangelog/diffChangelog execution, use column.xml, primary.xml, unique.xml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we now use init.sql scripts instead of XML changelogs this description is not correct.

README.md Outdated
- In case expectedSql is not provided, the test will auto-generate one to `src/test/resources/liquibase/harness/compatibility/advanced/expectedSql/generateChangelog` folder. Please verify its content and use it as expectedSql test data.
5) Go to `src/main/resources/liquibase/harness/compatibility/advanced/expectedSql/diffChangelog` and add query you expect liquibase to generate during updateSql command execution for generated diff changelog.
- In case expectedSql is not provided, the test will auto-generate one to `src/test/resources/liquibase/harness/compatibility/advanced/expectedSql/diffChangelog` folder. Please verify its content and use it as expectedSql test data.
6) Go to `src/main/resources/liquibase/harness/compatibility/advanced/expectedSnapshot` and add expected DB Snapshot results.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a note here regarding the usage of example.snapshot file.

README.md Outdated
6) Go to `src/main/resources/liquibase/harness/compatibility/advanced/expectedDiff` and add expected diff results.
- You will need to add this under the database specific folder.
- If you would like to test another DB type, please add the requisite folder.
7) Go to `src/main/resources/liquibase/harness/compatibility/advanced/expectedDiff` and add expected diff results.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the same note regarding the example file

Copy link
Contributor

@kristyldatical kristyldatical left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made some minor edits @yodzhubeiskyi , but overall this looks very good, thank you for all the work here!

Please also add the examples that @PavloTytarchuk is asking for and I think we should remove references that still exist in the readme about Running Advanced test suite against your database since we now want users to use the new Advanced Test class and not the earlier Test Suite.

Copy link
Contributor

@PavloTytarchuk PavloTytarchuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, @yodzhubeiskyi ! Approved.

@yodzhubeiskyi yodzhubeiskyi merged commit 01470ae into main Mar 1, 2023
@kristyldatical kristyldatical deleted the DAT-13177 branch March 1, 2023 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants