Skip to content

Commit c5dbb28

Browse files
committed
Use boltkit for ITs and TCK
This commit makes integration tests and TCK use boltkit for starting/stopping a shared database instance. They previously used neokit submodule which is now outdated.
1 parent 0375eb0 commit c5dbb28

20 files changed

+367
-146
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ We build a special browser version of the driver, which supports connecting to N
5050
This will make a global `neo4j` object available, where you can access the `v1` API at `neo4j.v1`:
5151

5252
```javascript
53-
var driver = neo4j.driver("bolt://localhost", neo4j.auth.basic("neo4j", "neo4j"));
53+
var driver = neo4j.driver("bolt://localhost", neo4j.auth.basic("username", "password"));
5454
```
5555

5656
It is not required to explicitly close the driver on a web page. Web browser should gracefully close all open
@@ -67,7 +67,7 @@ Driver creation:
6767
```javascript
6868
// Create a driver instance, for the user neo4j with password neo4j.
6969
// It should be enough to have a single driver per database per application.
70-
var driver = neo4j.driver("bolt://localhost", neo4j.auth.basic("neo4j", "neo4j"));
70+
var driver = neo4j.driver("bolt://localhost", neo4j.auth.basic("username", "password"));
7171

7272
// Register a callback to know if driver creation was successful:
7373
driver.onCompleted = function () {
@@ -126,7 +126,7 @@ Transaction functions API:
126126
// Transaction functions provide a convenient API with minimal boilerplate and
127127
// retries on network fluctuations and transient errors. Maximum retry time is
128128
// configured on the driver level and is 30 seconds by default:
129-
neo4j.driver("bolt://localhost", neo4j.auth.basic("neo4j", "neo4j"), {maxTransactionRetryTime: 30000});
129+
neo4j.driver("bolt://localhost", neo4j.auth.basic("username", "password"), {maxTransactionRetryTime: 30000});
130130

131131
// It is possible to execute read transactions that will benefit from automatic
132132
// retries on both single instance ('bolt' URI scheme) and Causal Cluster

gulpfile.babel.js

Lines changed: 6 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ var source = require('vinyl-source-stream');
2222
var buffer = require('vinyl-buffer');
2323
var gulp = require('gulp');
2424
var through = require('through2');
25-
var gulpif = require('gulp-if');
2625
var uglify = require('gulp-uglify');
2726
var concat = require('gulp-concat');
2827
var gutil = require('gulp-util');
@@ -40,14 +39,14 @@ var decompress = require('gulp-decompress');
4039
var fs = require("fs-extra");
4140
var runSequence = require('run-sequence');
4241
var path = require('path');
43-
var childProcess = require("child_process");
4442
var minimist = require('minimist');
4543
var cucumber = require('gulp-cucumber');
4644
var merge = require('merge-stream');
4745
var install = require("gulp-install");
4846
var os = require('os');
4947
var file = require('gulp-file');
5048
var semver = require('semver');
49+
var sharedNeo4j = require('./test/internal/shared-neo4j').default;
5150

5251
gulp.task('default', ["test"]);
5352

@@ -232,43 +231,12 @@ gulp.task('set', function() {
232231
});
233232

234233

235-
var neo4jHome = path.resolve('./build/neo4j');
236-
var neorunPath = path.resolve('./neokit/neorun.py');
237-
var neorunStartArgsName = "--neorun.start.args"; // use this args to provide additional args for running neorun.start
234+
var neo4jHome = path.resolve('./build/neo4j');
238235

239-
gulp.task('start-neo4j', function() {
240-
241-
var neorunStartArgs = '-p neo4j'; // default args to neorun.start: change the default password to neo4j
242-
process.argv.slice(2).forEach(function (val) {
243-
if(val.startsWith(neorunStartArgsName))
244-
{
245-
neorunStartArgs = val.split("=")[1];
246-
}
247-
});
248-
249-
neorunStartArgs = neorunStartArgs.match(/\S+/g) || '';
250-
251-
return runScript([
252-
neorunPath, '--start=' + neo4jHome
253-
].concat( neorunStartArgs ) );
236+
gulp.task('start-neo4j', function () {
237+
sharedNeo4j.start(neo4jHome, process.env.NEOCTRL_ARGS);
254238
});
255239

256-
gulp.task('stop-neo4j', function() {
257-
return runScript([
258-
neorunPath, '--stop=' + neo4jHome
259-
]);
240+
gulp.task('stop-neo4j', function () {
241+
sharedNeo4j.stop(neo4jHome);
260242
});
261-
262-
var runScript = function(cmd) {
263-
var spawnSync = childProcess.spawnSync, child, code;
264-
child = spawnSync('python', cmd);
265-
console.log("Script Outputs:\n" + child.stdout.toString());
266-
var error = child.stderr.toString();
267-
if (error.trim() !== "")
268-
console.log("Script Errors:\n"+ error);
269-
code = child.status;
270-
if( code !==0 )
271-
{
272-
throw "Script finished with code " + code
273-
}
274-
};

runTests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ try
1010
}
1111
else
1212
{
13-
$env:NEORUN_START_ARGS="$args"
13+
$env:NEOCTRL_ARGS="$args"
1414
npm run start-neo4j
1515
}
1616

runTests.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ npm install
1010
if [ "$1" == "" ]; then
1111
npm run start-neo4j
1212
else
13-
# Example: ./runTests.sh '-v 3.0.1 -p neo4j'
14-
# Example: npm run start-neo4j -- --neorun.start.args='-v 3.0.1 -p neo4j'
15-
NEORUN_START_ARGS="$1" npm run start-neo4j
13+
# Example: ./runTests.sh '-e 3.1.3'
14+
NEOCTRL_ARGS="$1" npm run start-neo4j
1615
fi
1716

1817
sleep 2
19-
npm test
18+
npm test

test/internal/connector.test.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {Packer} from '../../src/v1/internal/packstream';
2323
import {Chunker} from '../../src/v1/internal/chunking';
2424
import {alloc} from '../../src/v1/internal/buf';
2525
import {Neo4jError} from '../../src/v1/error';
26+
import sharedNeo4j from '../internal/shared-neo4j';
2627

2728
describe('connector', () => {
2829

@@ -31,7 +32,7 @@ describe('connector', () => {
3132
const conn = connect("bolt://localhost");
3233

3334
// When
34-
conn.initialize("mydriver/0.0.0", {scheme: "basic", principal: "neo4j", credentials: "neo4j"}, {
35+
conn.initialize("mydriver/0.0.0", basicAuthToken(), {
3536
onCompleted: msg => {
3637
expect(msg).not.toBeNull();
3738
conn.close();
@@ -49,7 +50,7 @@ describe('connector', () => {
4950

5051
// When
5152
const records = [];
52-
conn.initialize("mydriver/0.0.0", {scheme: "basic", principal: "neo4j", credentials: "neo4j"});
53+
conn.initialize("mydriver/0.0.0", basicAuthToken());
5354
conn.run("RETURN 1.0", {});
5455
conn.pullAll({
5556
onNext: record => {
@@ -70,10 +71,10 @@ describe('connector', () => {
7071
const conn = connect("bolt://localhost", {channel: DummyChannel.channel});
7172

7273
// When
73-
conn.initialize("mydriver/0.0.0", {scheme: "basic", principal: "neo4j", credentials: "neo4j"});
74+
conn.initialize("mydriver/0.0.0", basicAuthToken());
7475
conn.run("RETURN 1", {});
7576
conn.sync();
76-
expect(observer.instance.toHex()).toBe('60 60 b0 17 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 41 b2 01 8e 6d 79 64 72 69 76 65 72 2f 30 2e 30 2e 30 a3 86 73 63 68 65 6d 65 85 62 61 73 69 63 89 70 72 69 6e 63 69 70 61 6c 85 6e 65 6f 34 6a 8b 63 72 65 64 65 6e 74 69 61 6c 73 85 6e 65 6f 34 6a 00 00 00 0c b2 10 88 52 45 54 55 52 4e 20 31 a0 00 00 ');
77+
expect(observer.instance.toHex()).toBe('60 60 b0 17 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 44 b2 01 8e 6d 79 64 72 69 76 65 72 2f 30 2e 30 2e 30 a3 86 73 63 68 65 6d 65 85 62 61 73 69 63 89 70 72 69 6e 63 69 70 61 6c 85 6e 65 6f 34 6a 8b 63 72 65 64 65 6e 74 69 61 6c 73 88 70 61 73 73 77 6f 72 64 00 00 00 0c b2 10 88 52 45 54 55 52 4e 20 31 a0 00 00 ');
7778
done();
7879
});
7980

@@ -82,7 +83,7 @@ describe('connector', () => {
8283
const conn = connect("bolt://localhost:7474", {encrypted: false});
8384

8485
// When
85-
conn.initialize("mydriver/0.0.0", {scheme: "basic", principal: "neo4j", credentials: "neo4j"}, {
86+
conn.initialize("mydriver/0.0.0", basicAuthToken(), {
8687
onCompleted: msg => {
8788
},
8889
onError: err => {
@@ -142,4 +143,12 @@ describe('connector', () => {
142143
}).toThrow(new Neo4jError(expectedMessage, expectedCode));
143144
}
144145

146+
function basicAuthToken() {
147+
return {
148+
scheme: 'basic',
149+
principal: sharedNeo4j.username,
150+
credentials: sharedNeo4j.password
151+
};
152+
}
153+
145154
});

0 commit comments

Comments
 (0)