-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[HFWBmuq2] Fixes #155: Check for correct tx terminations
- Loading branch information
Showing
17 changed files
with
543 additions
and
161 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
package apoc.export; | ||
|
||
import apoc.export.csv.ExportCSV; | ||
import apoc.export.csv.ImportCsv; | ||
import apoc.export.cypher.ExportCypher; | ||
import apoc.export.graphml.ExportGraphML; | ||
import apoc.export.json.ExportJson; | ||
import apoc.graph.Graphs; | ||
import apoc.meta.Meta; | ||
import apoc.refactor.GraphRefactoring; | ||
import apoc.refactor.rename.Rename; | ||
import apoc.util.TestUtil; | ||
import apoc.util.Util; | ||
import org.junit.BeforeClass; | ||
import org.junit.ClassRule; | ||
import org.junit.Test; | ||
import org.neo4j.configuration.GraphDatabaseSettings; | ||
import org.neo4j.graphdb.Node; | ||
import org.neo4j.test.rule.DbmsRule; | ||
import org.neo4j.test.rule.ImpermanentDbmsRule; | ||
|
||
import java.io.File; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.IntStream; | ||
|
||
import static apoc.ApocConfig.APOC_EXPORT_FILE_ENABLED; | ||
import static apoc.ApocConfig.APOC_IMPORT_FILE_ENABLED; | ||
import static apoc.ApocConfig.apocConfig; | ||
import static apoc.util.TransactionTestUtil.checkTerminationGuard; | ||
import static org.neo4j.configuration.GraphDatabaseSettings.TransactionStateMemoryAllocation.OFF_HEAP; | ||
import static org.neo4j.configuration.SettingValueParsers.BYTES; | ||
|
||
public class BigGraphTest { | ||
private static File directory = new File("target/import"); | ||
static { //noinspection ResultOfMethodCallIgnored | ||
directory.mkdirs(); | ||
} | ||
|
||
@ClassRule | ||
public static DbmsRule db = new ImpermanentDbmsRule() | ||
.withSetting(GraphDatabaseSettings.memory_tracking, true) | ||
.withSetting(GraphDatabaseSettings.tx_state_memory_allocation, OFF_HEAP) | ||
.withSetting(GraphDatabaseSettings.tx_state_max_off_heap_memory, BYTES.parse("500m")) | ||
.withSetting(GraphDatabaseSettings.load_csv_file_url_root, directory.toPath().toAbsolutePath()); | ||
|
||
@BeforeClass | ||
public static void setUp() throws Exception { | ||
TestUtil.registerProcedure(db, Rename.class, ExportCSV.class, ExportJson.class, ExportCypher.class, ExportGraphML.class, Graphs.class, Meta.class, ImportCsv.class, GraphRefactoring.class); | ||
apocConfig().setProperty(APOC_IMPORT_FILE_ENABLED, true); | ||
apocConfig().setProperty(APOC_EXPORT_FILE_ENABLED, true); | ||
|
||
final String query = Util.readResourceFile("movies.cypher"); | ||
IntStream.range(0, 20000).forEach(__-> db.executeTransactionally(query)); | ||
} | ||
|
||
@Test | ||
public void testTerminateExportCsv() { | ||
checkTerminationGuard(db, "CALL apoc.export.csv.all('testTerminate.csv',{})"); | ||
} | ||
|
||
@Test | ||
public void testTerminateExportGraphMl() { | ||
checkTerminationGuard(db, "CALL apoc.export.graphml.all('testTerminate.graphml', null)"); | ||
} | ||
|
||
@Test | ||
public void testTerminateExportCypher() { | ||
checkTerminationGuard(db, "CALL apoc.export.cypher.all('testTerminate.cypher',{})"); | ||
} | ||
|
||
@Test | ||
public void testTerminateExportJson() { | ||
checkTerminationGuard(db, "CALL apoc.export.json.all('testTerminate.json',{})"); | ||
} | ||
|
||
@Test | ||
public void testTerminateRenameNodeProp() { | ||
checkTerminationGuard(db, "CALL apoc.refactor.rename.nodeProperty('name', 'nameTwo')"); | ||
} | ||
|
||
@Test | ||
public void testTerminateRenameTypeProp() { | ||
checkTerminationGuard(db, "CALL apoc.refactor.rename.typeProperty('roles', 'rolesTwo')"); | ||
} | ||
|
||
@Test | ||
public void testTerminateRenameType() { | ||
checkTerminationGuard(db, "CALL apoc.refactor.rename.type('DIRECTED', 'DIRECTED_TWO')"); | ||
} | ||
|
||
@Test | ||
public void testTerminateRenameLabel() { | ||
checkTerminationGuard(db, "CALL apoc.refactor.rename.label('Other', 'OtherTwo')"); | ||
} | ||
|
||
@Test | ||
public void testTerminateRefactorProcs() { | ||
List<Node> nodes = db.executeTransactionally("MATCH (n:Person) RETURN collect(n) as nodes", Collections.emptyMap(), | ||
r -> r.<List<Node>>columnAs("nodes").next()); | ||
|
||
checkTerminationGuard(db, "CALL apoc.refactor.cloneNodes($nodes)", | ||
Map.of("nodes", nodes)); | ||
|
||
checkTerminationGuard(db, "CALL apoc.refactor.cloneSubgraph($nodes)", | ||
Map.of("nodes", nodes)); | ||
|
||
db.executeTransactionally("CREATE CONSTRAINT FOR (n:BornLabel) REQUIRE n.targetKey IS UNIQUE"); | ||
checkTerminationGuard(db, "CALL apoc.refactor.categorize('id', 'SOMETHING', true, 'BornLabel', 'targetKey', [], 1)"); | ||
} | ||
} |
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
Oops, something went wrong.