Skip to content

Commit

Permalink
Add concurrent CIT tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fbiville committed Feb 6, 2025
1 parent 09d97ce commit b56f86e
Show file tree
Hide file tree
Showing 31 changed files with 688 additions and 18 deletions.
18 changes: 14 additions & 4 deletions src/test/groovy/liquibase/ext/neo4j/e2e/InvertDirectionIT.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import liquibase.command.core.helpers.DatabaseChangelogCommandStep
import liquibase.command.core.helpers.DbUrlConnectionCommandStep
import liquibase.ext.neo4j.Neo4jContainerSpec

import static liquibase.ext.neo4j.DockerNeo4j.neo4jVersion
import static liquibase.ext.neo4j.database.KernelVersion.V5_21_0
import static org.junit.jupiter.api.Assumptions.assumeTrue

class InvertDirectionIT extends Neo4jContainerSpec {

def "runs migrations inverting direction"() {
Expand Down Expand Up @@ -48,11 +52,14 @@ class InvertDirectionIT extends Neo4jContainerSpec {

def "runs batched migrations inverting direction"() {
given:
if (concurrent) {
assumeTrue(neo4jVersion() >= V5_21_0)
}
def command = new CommandScope(UpdateCommandStep.COMMAND_NAME)
.addArgumentValue(DbUrlConnectionCommandStep.URL_ARG, "jdbc:neo4j:${neo4jContainer.getBoltUrl()}".toString())
.addArgumentValue(DbUrlConnectionCommandStep.USERNAME_ARG, "neo4j")
.addArgumentValue(DbUrlConnectionCommandStep.PASSWORD_ARG, PASSWORD)
.addArgumentValue(DatabaseChangelogCommandStep.CHANGELOG_FILE_ARG, "/e2e/invert-direction/changeLog-simple-batched.${format}".toString())
.addArgumentValue(DatabaseChangelogCommandStep.CHANGELOG_FILE_ARG, "/e2e/invert-direction/changeLog-simple-batched${if (concurrent) "-concurrent" else ""}.${format}".toString())
.setOutput(System.out)
command.execute()

Expand Down Expand Up @@ -81,7 +88,7 @@ class InvertDirectionIT extends Neo4jContainerSpec {
]

where:
format << ["json", "xml", "yaml"]
[format, concurrent] << [["json", "xml", "yaml"], [false, true]].combinations()
}

def "runs migrations inverting direction of matching relationships"() {
Expand Down Expand Up @@ -123,11 +130,14 @@ class InvertDirectionIT extends Neo4jContainerSpec {

def "runs batched migrations inverting direction of matching relationships"() {
given:
if (concurrent) {
assumeTrue(neo4jVersion() >= V5_21_0)
}
def command = new CommandScope(UpdateCommandStep.COMMAND_NAME)
.addArgumentValue(DbUrlConnectionCommandStep.URL_ARG, "jdbc:neo4j:${neo4jContainer.getBoltUrl()}".toString())
.addArgumentValue(DbUrlConnectionCommandStep.USERNAME_ARG, "neo4j")
.addArgumentValue(DbUrlConnectionCommandStep.PASSWORD_ARG, PASSWORD)
.addArgumentValue(DatabaseChangelogCommandStep.CHANGELOG_FILE_ARG, "/e2e/invert-direction/changeLog-pattern-batched.${format}".toString())
.addArgumentValue(DatabaseChangelogCommandStep.CHANGELOG_FILE_ARG, "/e2e/invert-direction/changeLog-pattern-batched${if (concurrent) "-concurrent" else ""}.${format}".toString())
.setOutput(System.out)
command.execute()

Expand Down Expand Up @@ -155,6 +165,6 @@ class InvertDirectionIT extends Neo4jContainerSpec {
]

where:
format << ["json", "xml", "yaml"]
[format, concurrent] << [["json", "xml", "yaml"], [false, true]].combinations()
}
}
18 changes: 14 additions & 4 deletions src/test/groovy/liquibase/ext/neo4j/e2e/RenameLabelIT.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import liquibase.command.core.helpers.DatabaseChangelogCommandStep
import liquibase.command.core.helpers.DbUrlConnectionCommandStep
import liquibase.ext.neo4j.Neo4jContainerSpec

import static liquibase.ext.neo4j.DockerNeo4j.neo4jVersion
import static liquibase.ext.neo4j.database.KernelVersion.V5_21_0
import static org.junit.jupiter.api.Assumptions.assumeTrue

class RenameLabelIT extends Neo4jContainerSpec {

def "runs migrations renaming labels"() {
Expand Down Expand Up @@ -52,11 +56,14 @@ class RenameLabelIT extends Neo4jContainerSpec {

def "runs batched migrations renaming labels"() {
given:
if (concurrent) {
assumeTrue(neo4jVersion() >= V5_21_0)
}
def command = new CommandScope(UpdateCommandStep.COMMAND_NAME)
.addArgumentValue(DbUrlConnectionCommandStep.URL_ARG, "jdbc:neo4j:${neo4jContainer.getBoltUrl()}".toString())
.addArgumentValue(DbUrlConnectionCommandStep.USERNAME_ARG, "neo4j")
.addArgumentValue(DbUrlConnectionCommandStep.PASSWORD_ARG, PASSWORD)
.addArgumentValue(DatabaseChangelogCommandStep.CHANGELOG_FILE_ARG, "/e2e/rename-label/changeLog-simple-batched.${format}".toString())
.addArgumentValue(DatabaseChangelogCommandStep.CHANGELOG_FILE_ARG, "/e2e/rename-label/changeLog-simple-batched${if (concurrent) "-concurrent" else ""}.$format".toString())
.setOutput(System.out)
command.execute()

Expand Down Expand Up @@ -89,7 +96,7 @@ class RenameLabelIT extends Neo4jContainerSpec {
]

where:
format << ["json", "xml", "yaml"]
[format, concurrent] << [["json", "xml", "yaml"], [false, true]].combinations()
}

def "runs migrations renaming labels of matching nodes"() {
Expand Down Expand Up @@ -136,11 +143,14 @@ class RenameLabelIT extends Neo4jContainerSpec {

def "runs batched migrations renaming labels of matching nodes"() {
given:
if (concurrent) {
assumeTrue(neo4jVersion() >= V5_21_0)
}
def command = new CommandScope(UpdateCommandStep.COMMAND_NAME)
.addArgumentValue(DbUrlConnectionCommandStep.URL_ARG, "jdbc:neo4j:${neo4jContainer.getBoltUrl()}".toString())
.addArgumentValue(DbUrlConnectionCommandStep.USERNAME_ARG, "neo4j")
.addArgumentValue(DbUrlConnectionCommandStep.PASSWORD_ARG, PASSWORD)
.addArgumentValue(DatabaseChangelogCommandStep.CHANGELOG_FILE_ARG, "/e2e/rename-label/changeLog-pattern-batched.${format}".toString())
.addArgumentValue(DatabaseChangelogCommandStep.CHANGELOG_FILE_ARG, "/e2e/rename-label/changeLog-pattern-batched${if (concurrent) "-concurrent" else ""}.${format}".toString())
.setOutput(System.out)
command.execute()

Expand Down Expand Up @@ -173,6 +183,6 @@ class RenameLabelIT extends Neo4jContainerSpec {
]

where:
format << ["json", "xml", "yaml"]
[format, concurrent] << [["json", "xml", "yaml"], [false, true]].combinations()
}
}
25 changes: 19 additions & 6 deletions src/test/groovy/liquibase/ext/neo4j/e2e/RenamePropertyIT.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import liquibase.command.core.helpers.DatabaseChangelogCommandStep
import liquibase.command.core.helpers.DbUrlConnectionCommandStep
import liquibase.ext.neo4j.Neo4jContainerSpec

import static liquibase.ext.neo4j.DockerNeo4j.neo4jVersion
import static liquibase.ext.neo4j.database.KernelVersion.V5_21_0
import static org.junit.jupiter.api.Assumptions.assumeTrue

class RenamePropertyIT extends Neo4jContainerSpec {

def "runs migrations renaming properties of all entities"() {
Expand Down Expand Up @@ -127,11 +131,14 @@ class RenamePropertyIT extends Neo4jContainerSpec {

def "runs batched migrations renaming properties of all entities"() {
given:
if (concurrent) {
assumeTrue(neo4jVersion() >= V5_21_0)
}
def command = new CommandScope(UpdateCommandStep.COMMAND_NAME)
.addArgumentValue(DbUrlConnectionCommandStep.URL_ARG, "jdbc:neo4j:${neo4jContainer.getBoltUrl()}".toString())
.addArgumentValue(DbUrlConnectionCommandStep.USERNAME_ARG, "neo4j")
.addArgumentValue(DbUrlConnectionCommandStep.PASSWORD_ARG, PASSWORD)
.addArgumentValue(DatabaseChangelogCommandStep.CHANGELOG_FILE_ARG, "/e2e/rename-property/changeLog-all-batched.${format}".toString())
.addArgumentValue(DatabaseChangelogCommandStep.CHANGELOG_FILE_ARG, "/e2e/rename-property/changeLog-all-batched${if (concurrent) "-concurrent" else ""}.${format}".toString())
.setOutput(System.out)
command.execute()

Expand Down Expand Up @@ -161,16 +168,19 @@ class RenamePropertyIT extends Neo4jContainerSpec {
]

where:
format << ["json", "xml", "yaml"]
[format, concurrent] << [["json", "xml", "yaml"], [false, true]].combinations()
}

def "runs batched migrations renaming properties of nodes only"() {
given:
if (concurrent) {
assumeTrue(neo4jVersion() >= V5_21_0)
}
def command = new CommandScope(UpdateCommandStep.COMMAND_NAME)
.addArgumentValue(DbUrlConnectionCommandStep.URL_ARG, "jdbc:neo4j:${neo4jContainer.getBoltUrl()}".toString())
.addArgumentValue(DbUrlConnectionCommandStep.USERNAME_ARG, "neo4j")
.addArgumentValue(DbUrlConnectionCommandStep.PASSWORD_ARG, PASSWORD)
.addArgumentValue(DatabaseChangelogCommandStep.CHANGELOG_FILE_ARG, "/e2e/rename-property/changeLog-node-batched.${format}".toString())
.addArgumentValue(DatabaseChangelogCommandStep.CHANGELOG_FILE_ARG, "/e2e/rename-property/changeLog-node-batched${if (concurrent) "-concurrent" else ""}.${format}".toString())
.setOutput(System.out)
command.execute()

Expand Down Expand Up @@ -200,16 +210,19 @@ class RenamePropertyIT extends Neo4jContainerSpec {
]

where:
format << ["json", "xml", "yaml"]
[format, concurrent] << [["json", "xml", "yaml"], [false, true]].combinations()
}

def "runs batched migrations renaming properties of rels only"() {
given:
if (concurrent) {
assumeTrue(neo4jVersion() >= V5_21_0)
}
def command = new CommandScope(UpdateCommandStep.COMMAND_NAME)
.addArgumentValue(DbUrlConnectionCommandStep.URL_ARG, "jdbc:neo4j:${neo4jContainer.getBoltUrl()}".toString())
.addArgumentValue(DbUrlConnectionCommandStep.USERNAME_ARG, "neo4j")
.addArgumentValue(DbUrlConnectionCommandStep.PASSWORD_ARG, PASSWORD)
.addArgumentValue(DatabaseChangelogCommandStep.CHANGELOG_FILE_ARG, "/e2e/rename-property/changeLog-rel-batched.${format}".toString())
.addArgumentValue(DatabaseChangelogCommandStep.CHANGELOG_FILE_ARG, "/e2e/rename-property/changeLog-rel-batched${if (concurrent) "-concurrent" else ""}.${format}".toString())
.setOutput(System.out)
command.execute()

Expand Down Expand Up @@ -239,6 +252,6 @@ class RenamePropertyIT extends Neo4jContainerSpec {
]

where:
format << ["json", "xml", "yaml"]
[format, concurrent] << [["json", "xml", "yaml"], [false, true]].combinations()
}
}
18 changes: 14 additions & 4 deletions src/test/groovy/liquibase/ext/neo4j/e2e/RenameTypeIT.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import liquibase.command.core.helpers.DatabaseChangelogCommandStep
import liquibase.command.core.helpers.DbUrlConnectionCommandStep
import liquibase.ext.neo4j.Neo4jContainerSpec

import static liquibase.ext.neo4j.DockerNeo4j.neo4jVersion
import static liquibase.ext.neo4j.database.KernelVersion.V5_21_0
import static org.junit.jupiter.api.Assumptions.assumeTrue

class RenameTypeIT extends Neo4jContainerSpec {

def "runs migrations renaming types"() {
Expand Down Expand Up @@ -48,11 +52,14 @@ class RenameTypeIT extends Neo4jContainerSpec {

def "runs batched migrations renaming types"() {
given:
if (concurrent) {
assumeTrue(neo4jVersion() >= V5_21_0)
}
def command = new CommandScope(UpdateCommandStep.COMMAND_NAME)
.addArgumentValue(DbUrlConnectionCommandStep.URL_ARG, "jdbc:neo4j:${neo4jContainer.getBoltUrl()}".toString())
.addArgumentValue(DbUrlConnectionCommandStep.USERNAME_ARG, "neo4j")
.addArgumentValue(DbUrlConnectionCommandStep.PASSWORD_ARG, PASSWORD)
.addArgumentValue(DatabaseChangelogCommandStep.CHANGELOG_FILE_ARG, "/e2e/rename-type/changeLog-simple-batched.${format}".toString())
.addArgumentValue(DatabaseChangelogCommandStep.CHANGELOG_FILE_ARG, "/e2e/rename-type/changeLog-simple-batched${if (concurrent) "-concurrent" else ""}.${format}".toString())
.setOutput(System.out)
command.execute()

Expand Down Expand Up @@ -81,7 +88,7 @@ class RenameTypeIT extends Neo4jContainerSpec {
]

where:
format << ["json", "xml", "yaml"]
[format, concurrent] << [["json", "xml", "yaml"], [false, true]].combinations()
}

def "runs migrations renaming types of matching relationships"() {
Expand Down Expand Up @@ -123,11 +130,14 @@ class RenameTypeIT extends Neo4jContainerSpec {

def "runs batched migrations renaming types of matching relationships"() {
given:
if (concurrent) {
assumeTrue(neo4jVersion() >= V5_21_0)
}
def command = new CommandScope(UpdateCommandStep.COMMAND_NAME)
.addArgumentValue(DbUrlConnectionCommandStep.URL_ARG, "jdbc:neo4j:${neo4jContainer.getBoltUrl()}".toString())
.addArgumentValue(DbUrlConnectionCommandStep.USERNAME_ARG, "neo4j")
.addArgumentValue(DbUrlConnectionCommandStep.PASSWORD_ARG, PASSWORD)
.addArgumentValue(DatabaseChangelogCommandStep.CHANGELOG_FILE_ARG, "/e2e/rename-type/changeLog-pattern-batched.${format}".toString())
.addArgumentValue(DatabaseChangelogCommandStep.CHANGELOG_FILE_ARG, "/e2e/rename-type/changeLog-pattern-batched${if (concurrent) "-concurrent" else ""}.${format}".toString())
.setOutput(System.out)
command.execute()

Expand Down Expand Up @@ -155,6 +165,6 @@ class RenameTypeIT extends Neo4jContainerSpec {
]

where:
format << ["json", "xml", "yaml"]
[format, concurrent] << [["json", "xml", "yaml"], [false, true]].combinations()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"databaseChangeLog": [
{
"changeSet": {
"id": "my-movie-init-oops",
"author": "fbiville",
"changes": [
{
"cypher": "CREATE (:Movie)<-[:VIEWED_BY {date: 'now'}]-(:Person)"
},
{
"cypher": "CREATE (:Movie)-[:VIEWED_BY {date: 'yesterday'}]->(:Dog)"
}
]
}
},
{
"changeSet": {
"id": "my-movie-init-fixed",
"author": "fbiville",
"runInTransaction": false,
"changes": [
{
"invertDirection": {
"type": "VIEWED_BY",
"fragment": "(:Person)-[r:VIEWED_BY]->()",
"outputVariable": "r",
"enableBatchImport": true,
"batchSize": 1,
"concurrent": true
}
}
]
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:neo4j="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">

<changeSet id="my-movie-init-oops" author="fbiville">
<neo4j:cypher><![CDATA[CREATE (:Movie)<-[:VIEWED_BY {date: 'now'}]-(:Person)]]></neo4j:cypher>
<neo4j:cypher><![CDATA[CREATE (:Movie)-[:VIEWED_BY {date: 'yesterday'}]->(:Dog)]]></neo4j:cypher>
</changeSet>

<changeSet id="my-movie-init-fixed" author="fbiville" runInTransaction="false">
<neo4j:invertDirection type="VIEWED_BY" fragment="(:Person)-[r:VIEWED_BY]-&gt;()" outputVariable="r" enableBatchImport="true" batchSize="1" concurrent="true" />
</changeSet>

</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
databaseChangeLog:
- changeSet:
id: my-movie-init-oops
author: fbiville
changes:
- cypher: 'CREATE (:Movie)<-[:VIEWED_BY {date: ''now''}]-(:Person)'
- cypher: 'CREATE (:Movie)-[:VIEWED_BY {date: ''yesterday''}]->(:Dog)'
- changeSet:
id: my-movie-init-fixed
author: fbiville
runInTransaction: false
changes:
- invertDirection:
type: 'VIEWED_BY'
fragment: '(:Person)-[r:VIEWED_BY]->()'
outputVariable: 'r'
enableBatchImport: true
batchSize: 1
concurrent: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"databaseChangeLog": [
{
"changeSet": {
"id": "my-movie-init-oops",
"author": "fbiville",
"changes": [
{
"cypher": "CREATE (:Movie)<-[:VIEWED_BY {date: 'now'}]-(:Person)"
},
{
"cypher": "CREATE (:Movie)<-[:VIEWED_BY {date: 'yesterday'}]-(:Dog)"
}
]
}
},
{
"changeSet": {
"id": "my-movie-init-fixed",
"author": "fbiville",
"runInTransaction": false,
"changes": [
{
"invertDirection": {
"type": "VIEWED_BY",
"enableBatchImport": true,
"batchSize": 1,
"concurrent": true
}
}
]
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:neo4j="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">

<changeSet id="my-movie-init-oops" author="fbiville">
<neo4j:cypher><![CDATA[CREATE (:Movie)<-[:VIEWED_BY {date: 'now'}]-(:Person)]]></neo4j:cypher>
<neo4j:cypher><![CDATA[CREATE (:Movie)<-[:VIEWED_BY {date: 'yesterday'}]-(:Dog)]]></neo4j:cypher>
</changeSet>

<changeSet id="my-movie-init-fixed" author="fbiville" runInTransaction="false">
<neo4j:invertDirection type="VIEWED_BY" enableBatchImport="true" batchSize="1" concurrent="true" />
</changeSet>

</databaseChangeLog>
Loading

0 comments on commit b56f86e

Please sign in to comment.