Skip to content

Added support to auto start neo4j for tests on windows #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 25, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ See files under `examples/` on how to use.
This runs the test suite against a fresh download of Neo4j.
Or `npm test` if you already have a running version of a compatible Neo4j server.

### Testing on windows
Running tests on windows requires PhantomJS installed and its bin folder added in windows system variable `Path`.
To run the same test suite, run `.\runTest.ps1` instead in powershell with admin right.
The admin right is required to start/stop Neo4j properly as a system service.
While there is no need to grab admin right if you are running tests against an existing Neo4j server using `npm test`.

## A note on numbers and the Integer type
For this driver to fully map to the Neo4j type system handling of 64-bits Integers is needed.
Javascript can saftely represent numbers between `-(2`<sup>`53`</sup>` - 1)` and `(2`<sup>`53`</sup>` - 1)`.
Expand Down
74 changes: 58 additions & 16 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var gutil = require('gulp-util');
var download = require("gulp-download");
var gunzip = require('gulp-gunzip');
var untar = require('gulp-untar2');
var shell = require('gulp-shell');
var jasmine = require('gulp-jasmine');
var jasmineBrowser = require('gulp-jasmine-browser');
Expand All @@ -39,6 +37,9 @@ var watch = require('gulp-watch');
var batch = require('gulp-batch');
var fs = require("fs");
var runSequence = require('run-sequence');
var path = require('path');
var childProcess = require("child_process");
var decompress = require('gulp-decompress');

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

Expand Down Expand Up @@ -131,15 +132,6 @@ gulp.task('test', function(cb){
runSequence('test-nodejs', 'test-browser', cb);
});

gulp.task('start-neo4j', ['download-neo4j'], shell.task([
'chmod +x build/neo4j-enterprise*/bin/neo4j',
'build/neo4j-enterprise*/bin/neo4j start',
]));

gulp.task('stop-neo4j', shell.task([
'build/neo4j-enterprise*/bin/neo4j stop',
]));

gulp.task('test-nodejs', ['nodejs'], function () {
return gulp.src('test/**/*.test.js')
.pipe(jasmine({
Expand Down Expand Up @@ -167,12 +159,62 @@ gulp.task('watch', function () {
}));
});

var neo4jLinuxUrl = 'http://alpha.neohq.net/dist/neo4j-enterprise-3.0.0-M01-NIGHTLY-unix.tar.gz';
var neo4jWinUrl = 'http://alpha.neohq.net/dist/neo4j-enterprise-3.0.0-M01-NIGHTLY-windows.zip';
var neo4jHome = './build/neo4j-enterprise-3.0.0-M01';
var isWin = /^win/.test(process.platform);

gulp.task('download-neo4j', function() {
if( !fs.existsSync('./build/neo4j-enterprise-3.0.0-alpha') ) {
if( !fs.existsSync(neo4jHome) ) {
// Need to download
return download("http://alpha.neohq.net/dist/neo4j-enterprise-3.0.0-M01-NIGHTLY-unix.tar.gz")
.pipe(gunzip())
.pipe(untar())
.pipe(gulp.dest('./build'));
if(isWin) {
return download(neo4jWinUrl)
.pipe(decompress({strip: 1}))
.pipe(gulp.dest(neo4jHome));
}
else {
return download(neo4jLinuxUrl)
.pipe(decompress({strip: 1}))
.pipe(gulp.dest(neo4jHome));
}
}
});

var runPowershell = function( cmd ) {
var spawn = childProcess.spawn, child;
child = spawn("powershell.exe",[
'Import-Module ' + neo4jHome + '/bin/Neo4j-Management.psd1;' + cmd]);
child.stdout.on("data",function(data){
console.log("Powershell Data: " + data);
});
child.stderr.on("data",function(data){
console.log("Powershell Errors: " + data);
});
child.on("exit",function(){
console.log("Powershell Script finished");
});
child.stdin.end(); //end input
}

gulp.task('start-neo4j', ['download-neo4j'], function() {
if(isWin) {
runPowershell('Install-Neo4jServer -Neo4jServer ' + neo4jHome + ' -Name neo4j-js;' +
'Start-Neo4jServer -Neo4jServer ' + neo4jHome + ' -ServiceName neo4j-js');
} else {
shell.task([
'chmod +x' + neo4jHome + 'bin/neo4j',
neo4jHome + '/bin/neo4j start',
]);
}
});

gulp.task('stop-neo4j', function() {
if(isWin) {
runPowershell('Stop-Neo4jServer -Neo4jServer ' + neo4jHome + ' -ServiceName neo4j-js;' +
'Uninstall-Neo4jServer -Neo4jServer ' + neo4jHome + ' -ServiceName neo4j-js');
} else {
shell.task([
neo4jHome + '/bin/neo4j stop',
])
}
});
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,19 @@
"gulp-concat": "^2.6.0",
"gulp-cucumber": "^0.0.12",
"gulp-download": "^0.0.1",
"gulp-gunzip": "^0.0.3",
"gulp-if": "^1.2.5",
"gulp-jasmine": "^2.1.0",
"gulp-jasmine-browser": "^0.2.3",
"gulp-shell": "^0.4.3",
"gulp-uglify": "^1.4.2",
"gulp-untar2": "^0.1.0",
"gulp-util": "^3.0.6",
"gulp-watch": "^4.3.5",
"jasmine-reporters": "^2.0.7",
"phantomjs2-ext": "^0.1.0",
"run-sequence": "^1.1.4",
"through2": "~2.0.0",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0"
"vinyl-source-stream": "^1.1.0",
"gulp-decompress": "^1.2.0"
}
}
14 changes: 14 additions & 0 deletions runTests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Try
{
npm install
npm run start-neo4j
npm test
}
Catch [system.exception]
{
"Error found while running tests"
}
Finally
{
npm run stop-neo4j
}