mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-30 22:34:10 -05:00
forking 2 servers for tests
This commit is contained in:
parent
6dc6f31579
commit
683f4657e4
5 changed files with 48 additions and 12 deletions
|
@ -63,3 +63,8 @@ if (hostport[0] == null) {
|
||||||
server(config).listen(hostport[1], hostport[0]);
|
server(config).listen(hostport[1], hostport[0]);
|
||||||
console.log('Server is listening on http://%s:%s/', hostport[0], hostport[1]);
|
console.log('Server is listening on http://%s:%s/', hostport[0], hostport[1]);
|
||||||
|
|
||||||
|
// undocumented stuff for tests
|
||||||
|
if (typeof(process.send) === 'function') {
|
||||||
|
process.send({sinopia_started: hostport});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,4 +9,4 @@ packages:
|
||||||
allow_access: test
|
allow_access: test
|
||||||
allow_publish: test
|
allow_publish: test
|
||||||
|
|
||||||
listen: 55550
|
listen: 55551
|
12
test/config-2.yaml
Normal file
12
test/config-2.yaml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
storage: ./test-storage2
|
||||||
|
|
||||||
|
users:
|
||||||
|
test:
|
||||||
|
password: a94a8fe5ccb19ba61c4c0873d391e987982fbbd3
|
||||||
|
|
||||||
|
packages:
|
||||||
|
'*':
|
||||||
|
allow_access: test
|
||||||
|
allow_publish: test
|
||||||
|
|
||||||
|
listen: 55552
|
|
@ -7,7 +7,7 @@ var readfile = require('fs').readFileSync;
|
||||||
var binary = readfile('../fixtures/binary');
|
var binary = readfile('../fixtures/binary');
|
||||||
var count = 10000;
|
var count = 10000;
|
||||||
|
|
||||||
var server = new Server('http://localhost:55550/');
|
var server = new Server('http://localhost:55551/');
|
||||||
async.series([
|
async.series([
|
||||||
function(cb) {
|
function(cb) {
|
||||||
server.auth('test', 'test', function(res, body) {
|
server.auth('test', 'test', function(res, body) {
|
||||||
|
|
39
test/run.js
39
test/run.js
|
@ -1,23 +1,33 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
var fs = require('fs');
|
||||||
var async = require('async');
|
var async = require('async');
|
||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
var rimraf = require('rimraf');
|
var rimraf = require('rimraf');
|
||||||
var Server = require('./lib/server');
|
var Server = require('./lib/server');
|
||||||
|
var fork = require('child_process').fork;
|
||||||
var readfile = require('fs').readFileSync;
|
var readfile = require('fs').readFileSync;
|
||||||
|
var forks = [];
|
||||||
|
|
||||||
var server = new Server('http://localhost:55550/');
|
var server = new Server('http://localhost:55551/');
|
||||||
async.series([
|
async.series([
|
||||||
function(cb) {
|
function(cb) {
|
||||||
rimraf('./test-storage', cb);
|
var count = 0;
|
||||||
},
|
function start(dir, conf) {
|
||||||
function(cb) {
|
count++;
|
||||||
process.argv = ['node', 'sinopia', '-c', './config.yaml'];
|
rimraf(dir, function() {
|
||||||
require('../bin/sinopia');
|
var f = fork('../bin/sinopia', ['-c', conf], {stdio: [null,null,null]});
|
||||||
cb();
|
forks.push(f);
|
||||||
},
|
f.on('message', function(msg) {
|
||||||
function(cb) {
|
if ('sinopia_started' in msg) {
|
||||||
setTimeout(cb, 1000);
|
if (!--count) cb();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
start('./test-storage', './config-1.yaml', cb);
|
||||||
|
start('./test-storage2', './config-2.yaml', cb);
|
||||||
},
|
},
|
||||||
function(cb) {
|
function(cb) {
|
||||||
server.auth('test', 'test', function(res, body) {
|
server.auth('test', 'test', function(res, body) {
|
||||||
|
@ -73,3 +83,12 @@ async.series([
|
||||||
process.exit();
|
process.exit();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
process.on('exit', function() {
|
||||||
|
if (forks[0]) forks[0].kill();
|
||||||
|
if (forks[1]) forks[1].kill();
|
||||||
|
});
|
||||||
|
|
||||||
|
process.on('uncaughtException', function() {
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue