forked from alexandru-slobodcicov/liquibase-mongodb
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:liquibase/liquibase-mongodb into fe…
…rretdb
- Loading branch information
Showing
41 changed files
with
531 additions
and
99 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
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
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,27 @@ | ||
# Using the Liquibase Test Harness in the MongoDB Extension | ||
The liquibase-mongodb extension now comes with integration test support via the liquibase-test-harness. | ||
This Liquibase test framework is designed to *also* make it easier for you to test your extensions. | ||
|
||
### Configuring your project | ||
|
||
#### Configuring your connections | ||
|
||
- Use the provided `harness-config.yml` file in `src/test/resources` directory. | ||
- Update this file to add the connection information for all the databases you want the Liquibase MongoDB extension to be tested against. | ||
- *If this config file does not exist, create a new one using this as an example : https://github.com/liquibase/liquibase-test-harness/blob/main/src/test/resources/harness-config.yml* | ||
- Your database under test needs to be completely empty prior to the Harness tests running. | ||
|
||
#### Executing the Harness NoSQL Foundational test | ||
- From your IDE, right-click on the `HarnessNoSqlCompatibility` test class present in `src/test/groovy/liquibase/harness/compatibility/foundational` directory. | ||
- Doing so, will allow you to execute NoSQL Foundational harness suite. Test data for this test should be located in the next directories: | ||
- `src/test/resources/liquibase/harness/compatibility/foundational/changelogs/nosql` for the changelogs you want to test. XML, JSON & YAML formats are supported. | ||
- `src/test/resources/liquibase/harness/compatibility/foundational/expectedResultSet/mongodb` for the JSON format files with the values you expect to be present in the DATABASECHANGELOG table after applying your changelog files. | ||
In the key:value format like: `"id":"1"`, `"author":"as"`,`"description":"createCollection collectionName=towns"`, etc. Use existing files as an example. | ||
|
||
##### Alternative ways to run the Harness test suites | ||
- Using maven by executing next command: | ||
`mvn -Dtest="HarnessNoSqlCompatibility" -DdbName=mongodb(optional) -DdbUsername=USERNAME(optional) -DdbPassword=PASSWORD(optional) -DdbUrl=URL(optional) test` | ||
- where USERNAME, PASSWORD and URL are connection credentials. | ||
|
||
#### Troubleshooting notes | ||
- If your IDE doesn't allow you to run HarnessNoSqlCompatibility as a test class, mark test/groovy folder as test classes folder in your IDE |
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
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
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
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
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
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
41 changes: 41 additions & 0 deletions
41
src/main/java/liquibase/nosql/snapshot/NoSqlSnapshotGenerator.java
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,41 @@ | ||
package liquibase.nosql.snapshot; | ||
|
||
import liquibase.database.Database; | ||
import liquibase.exception.DatabaseException; | ||
import liquibase.ext.mongodb.database.MongoLiquibaseDatabase; | ||
import liquibase.snapshot.DatabaseSnapshot; | ||
import liquibase.snapshot.InvalidExampleException; | ||
import liquibase.snapshot.SnapshotGenerator; | ||
import liquibase.snapshot.SnapshotGeneratorChain; | ||
import liquibase.structure.DatabaseObject; | ||
|
||
import java.util.ResourceBundle; | ||
|
||
import static liquibase.plugin.Plugin.PRIORITY_SPECIALIZED; | ||
|
||
public class NoSqlSnapshotGenerator implements SnapshotGenerator { | ||
private static final ResourceBundle mongoBundle = ResourceBundle.getBundle("liquibase/i18n/liquibase-mongo"); | ||
|
||
@Override | ||
public int getPriority(Class<? extends DatabaseObject> objectType, Database database) { | ||
if (database instanceof MongoLiquibaseDatabase) { | ||
return PRIORITY_SPECIALIZED; | ||
} | ||
return PRIORITY_NONE; | ||
} | ||
|
||
@Override | ||
public <T extends DatabaseObject> T snapshot(T example, DatabaseSnapshot snapshot, SnapshotGeneratorChain chain) throws DatabaseException, InvalidExampleException { | ||
throw new DatabaseException(String.format(mongoBundle.getString("command.unsupported"), "db-doc, diff*, generate-changelog, and snapshot*")); | ||
} | ||
|
||
@Override | ||
public Class<? extends DatabaseObject>[] addsTo() { | ||
return new Class[0]; | ||
} | ||
|
||
@Override | ||
public Class<? extends SnapshotGenerator>[] replaces() { | ||
return new Class[0]; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
src/main/resources/META-INF/services/liquibase.snapshot.SnapshotGenerator
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 @@ | ||
liquibase.nosql.snapshot.NoSqlSnapshotGenerator |
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 @@ | ||
command.unsupported=Liquibase MongoDB Extension does not support %s commands\nPlease refer to our documentation for the entire list of supported commands for MongoDB |
Oops, something went wrong.