stop() { winston.debug('[TestServer] stop'); return new Promise((resolve) => { if (!this._child || this._child.killed) { resolve(); } this._child.on('close', () => resolve()); this._child.kill(); this._child = void 0; }); }
cleanup() { if (!this.child) { return; } try { this.child.kill(); } catch (e) { if (!this.sudo || e.code !== 'EPERM') { throw e; } } }
/** * @param force * @returns {Promise} */ async quit(force = false) { if (force) { this._worker.process.kill('SIGKILL'); return Promise.resolve(); } await this._sendMessage(Commands.QUIT); return this._assureStatusSequence([WorkerStatuses.SHUTTING_DOWN, WorkerStatuses.SHUTTED_DOWN]); }
it('should fork app and receive data', function(done) { var app = forkHistogram(); app.on('message', function(pck) { should(pck.data['min'].historic).eql(true); if (pck.data.mean && pck.data.mean.agg_type == 'avg' && pck.data.min && pck.data.min.agg_type == 'min' && pck.data.test && pck.data.test.agg_type == 'sum') { app.kill(); done(); } }); });
// Handle child process's error dashboardProcess.once('error', (err) => { // Kill child process once it occur error. logger.error(`DashboardProcess occur an error: ${err.toString()}`); logger.error(`DashboardProcess should be stopping......`); dashboardProcess.kill(); }).once('exit', (code, signal) => { // Stop collector while child process exit. logger.error(`DashboardProcess exited by code: ${code}`); logger.error(`Collector has been stopped.`); collector.stop(); });
function handleEvent(ifaceName, eventName) { test.equals(ifaceName, iface, 'interface name must match'); test.equals(eventName, event, 'event name must match'); client.kill(); server.close(); }
async function run (profilerEnabled) { const port = await getPort() const url = new URL(`http://localhost:${port}/hello`) const server = await createServer(profilerEnabled, url) title(`Benchmark (enabled=${profilerEnabled})`) await getUsage(url) const net = await benchmark(url.href, 15000) const cpu = await getUsage(url) server.kill('SIGINT') return { cpu, net } }
child.on('message', message => { oauth2.token(message) console.log('Login successful') child.kill() })
test(`should request and handle a greeting locally`, async (t) => { const PORT = 50051; const server = childProcess.exec(`${serverCmd} -p ${PORT}`, { cwd: cwd }); await delay(1000); console.log(`${clientCmd} -h localhost:${PORT} -k ${API_KEY}`); const clientOutput = await runAsync(`${clientCmd} -h localhost:${PORT} -k ${API_KEY}`, cwd); t.regex(clientOutput, /Hello world/); server.kill(); });
setTimeout(() => { child.kill('SIGINT'); process.exit(); }, 6000);
it('should instanciate metric sample app', function(done) { var app = forkMetric(); app.on('message', function(pck) { // Will iterate two times, metric change the value to false should(pck.data['Realtime user'].value).eql(2); should(pck.data['Realtime user'].unit).eql('kb'); should(pck.data['Realtime user'].historic).eql(false); should(pck.data['Realtime user'].type).eql('v8/smthing'); app.kill() done() }) });
it(`should request and handle a greeting locally using a JWT Auth Token`, async () => { const PORT = 50051; const server = childProcess.exec(`${serverCmd} -p ${PORT}`, {cwd: cwd}); await delay(1000); const clientOutput = await tools.runAsync( `${clientCmd} -h localhost:${PORT} -j ${JWT_AUTH_TOKEN}`, cwd ); assert.ok(new RegExp('Hello world').test(clientOutput)); server.kill(); });
it(`should request and handle a greeting locally using a JWT Auth Token`, async () => { const PORT = 50051; const server = childProcess.exec(`${serverCmd} -p ${PORT}`, {cwd: cwd}); await delay(1000); const clientOutput = await tools.runAsync( `${clientCmd} -h localhost:${PORT} -j ${JWT_AUTH_TOKEN}`, cwd ); assert.ok(new RegExp('Hello world').test(clientOutput)); server.kill(); });