0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-16 21:56:25 -05:00

automated tests against fd leaks

This commit is contained in:
Alex Kocharin 2014-09-25 05:21:59 +04:00
parent 0786ec6108
commit 862b1eeed4
2 changed files with 37 additions and 0 deletions

View file

@ -3,6 +3,7 @@ require('./lib/startup')
var assert = require('assert')
, async = require('async')
, crypto = require('crypto')
, exec = require('child_process').exec
, ex = module.exports
function readfile(x) {
@ -24,6 +25,18 @@ describe('Func', function() {
], cb)
})
before(function(cb) {
async.map([server, server2], function(server, cb) {
server.debug(function(res, body) {
server.pid = body.pid
exec('lsof -p ' + Number(server.pid), function(err, result) {
server.fdlist = result
cb()
})
})
}, cb)
})
before(function auth(cb) {
async.map([server, server2], function(server, cb) {
server.auth('test', 'test', function(res, body) {
@ -49,5 +62,19 @@ describe('Func', function() {
require('./security')()
require('./adduser')()
require('./addtag')()
after(function(cb) {
async.map([server, server2], function(server, cb) {
exec('lsof -p ' + Number(server.pid), function(err, result) {
assert.equal(server.fdlist, result.split('\n').filter(function(q) {
if (q.match(/TCP localhost:55551->localhost:\d+ \(ESTABLISHED\)/)) return false;
if (q.match(/\/libcrypt-[^\/]+\.so/)) return false;
if (q.match(/\/node_modules\/crypt3\/build\/Release/)) return false;
return true;
}).join('\n'))
cb()
})
}, cb)
})
})

View file

@ -130,5 +130,15 @@ Server.prototype.add_package = function(name, cb) {
})
}
Server.prototype.debug = function(cb) {
this.request({
uri: '/-/_debug',
method: 'GET',
headers: {
'content-type': 'application/json'
},
}, prep(cb))
}
module.exports = Server