Skip to content

Commit 207256a

Browse files
author
Zhen Li
committed
Tested the new start code on windows.
Turns out that on windows, python scripts would fail to rename known_host file with the error `file occupied by other process.` This problem could be addressed by 1) closing each driver properly and/or 2) tiggering GC after each write op to known_host file. However we work around this problem in this PR by letting java driver code to delete the known_host file directly.
1 parent 30fedf3 commit 207256a

File tree

2 files changed

+15
-23
lines changed

2 files changed

+15
-23
lines changed

README.md

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,13 @@ Java 8, because Neo4j-the-database needs it to run.
5656

5757
### Windows
5858

59-
If you are building on windows, you need to have Python (v2.7) installed and run install as admin,
60-
so that Neo4j-the-database could be installed and started with Python scripts for integration tests.
61-
Or you could choose to ignore integration tests by running:
62-
63-
mvn clean install -DskipITs
64-
65-
## Q&A
59+
If you are building on windows, you need to have Python (v2.7) installed and have Python.exe to be added in your system `PATH` variables.
60+
Then run install as admin, so that Neo4j-the-database could be installed and started with Python scripts for integration tests.
6661

67-
**Q**: Where can I find the changelogs?
68-
**A**: [wiki](https://github.com/neo4j/neo4j-java-driver/wiki)
69-
70-
71-
**Q**: Why my driver stops working today after I upgrade my Neo4j server? It was working well yesterday.
72-
**A**: If the driver is configured to use [trust-on-first-use]
73-
(http://neo4j.com/docs/developer-manual/3.0/index.html#_trust) mode,
74-
then following the error message you got while using the driver, you might need to modify `known_hosts` file.
62+
Or you could choose to ignore integration tests by running:
7563

64+
mvn clean install -DskipITs
7665

77-
**Q**: Why I cannot connect the driver to the server at `bolt://localhost:7474`?
78-
**A**: Bolt uses port 7687 by default, so try `bolt://localhost:7687` or `bolt://localhost` instead.
66+
Without integration tests, there is no need to install Python or run as admin.
7967

80-
For any other questions, please refer to Github issues.
68+
For more information such as manual, driver API documentations, changelogs, please refer to [wiki](https://github.com/neo4j/neo4j-java-driver/wiki).

driver/src/test/java/org/neo4j/driver/v1/util/Neo4jRunner.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.neo4j.driver.v1.Driver;
3434
import org.neo4j.driver.v1.GraphDatabase;
3535

36+
import static org.neo4j.driver.internal.ConfigTest.deleteDefaultKnownCertFileIfExists;
3637
import static org.neo4j.driver.v1.util.FileTools.updateProperties;
3738

3839
/**
@@ -45,12 +46,13 @@ public class Neo4jRunner
4546

4647
private static final boolean debug = Boolean.getBoolean( "neo4j.runner.debug" );
4748

49+
public static final String NEORUN_START_ARGS = System.getProperty("neorun.start.args", "-v 3.0.1");
4850
public static final String DEFAULT_URL = "bolt://localhost:7687";
4951
private static final Config TEST_CONFIG = Config.build().withEncryptionLevel( Config.EncryptionLevel.NONE ).toConfig();
5052
private Driver driver;
5153
private Neo4jSettings currentSettings = Neo4jSettings.DEFAULT_SETTINGS;
5254

53-
public static final String NEO4J_HOME = "../target/neo4j/neo4jhome";
55+
public static final String NEO4J_HOME = new File("../target/neo4j/neo4jhome").getAbsolutePath();
5456
private static final String NEORUN_PATH = new File("../neokit/neorun.py").getAbsolutePath();
5557
private static final String NEO4J_CONF = new File( NEO4J_HOME, "conf/neo4j.conf" ).getAbsolutePath();
5658

@@ -94,7 +96,10 @@ public Driver driver()
9496

9597
private void startNeo4j() throws IOException
9698
{
97-
startNeo4j( "-v", "3.0.1" );
99+
// this is required for windows as python scripts cannot delete the file when it is used by driver tests
100+
deleteDefaultKnownCertFileIfExists();
101+
102+
startNeo4j( NEORUN_START_ARGS.split( "\\s" ) );
98103
}
99104

100105
private void startNeo4j(String... opts) throws IOException
@@ -105,7 +110,7 @@ private void startNeo4j(String... opts) throws IOException
105110
int processStatus = runCommand( cmds.toArray( new String[cmds.size()]) );
106111
if (processStatus != 0) // success
107112
{
108-
throw new IOException( "Failed to the start neo4j server." );
113+
throw new IOException( "Failed to start neo4j server." );
109114
}
110115
driver = GraphDatabase.driver( DEFAULT_URL, TEST_CONFIG );
111116
}
@@ -153,8 +158,7 @@ public void restartNeo4j(Neo4jSettings neo4jSettings) throws IOException
153158
{
154159
if( updateServerSettings( neo4jSettings ) ) // needs to update server setting files
155160
{
156-
stopNeo4j();
157-
startNeo4j();
161+
forceToRestart();
158162
}
159163
}
160164

0 commit comments

Comments
 (0)