-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'NodeClusterCompatibility' of https://github.com/penartu…
- Loading branch information
Showing
2 changed files
with
68 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/usr/bin/env node | ||
|
||
const | ||
vows = require('vows'), | ||
assert = require('assert'), | ||
nodeCluster = require('cluster'), | ||
computeCluster = require('../lib/compute-cluster'), | ||
path = require('path'); | ||
|
||
if(nodeCluster.isMaster) { | ||
nodeCluster.fork(); | ||
return; | ||
} | ||
|
||
var suite = vows.describe('basic tests'); | ||
|
||
// disable vows (often flakey?) async error behavior | ||
suite.options.error = false; | ||
|
||
suite.addBatch({ | ||
"allocation of a compute cluster": { | ||
topic: function() { | ||
return new computeCluster({ | ||
module: path.join(__dirname, 'workers', 'echo.js') | ||
}); | ||
}, | ||
"runs without issue": function (cc) { | ||
assert.isObject(cc); | ||
}, | ||
"and invocation against this cluster": { | ||
topic: function(cc) { | ||
var cb = this.callback; | ||
cc.enqueue("hello", function(e, r) { | ||
cb.call(self, { cc: cc, r: r }); | ||
}); | ||
|
||
}, | ||
"succeeds": function (r) { | ||
assert.equal(r.r, 'hello'); | ||
}, | ||
"finally, exit": { | ||
topic: function(r) { | ||
r.cc.exit(this.callback); | ||
}, | ||
"also succeeds": function(err) { | ||
assert.isNull(err); | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
|
||
// run or export the suite. | ||
if (process.argv[1] === __filename) suite.run(); | ||
else suite.export(module); |