File size: 888 Bytes
bad179a
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
// a console command with endless output must not take the monitor down. node t_flood.js <port>
const { sleep, client, check, done } = require('./lib'), { req, post } = client(process.argv[2]);
(async () => {
    const t = Date.now();
    const r = await req('POST', '/api/exec', { id: 'local1', cmd: 'yes 0123456789012345678901234567890123456789' }).catch(e => ({ status: 0, text: String(e) }));
    check('endless output: the command is stopped and reported', r.status === 200 && r.json.code === -1 && r.json.out.length < 6e6, `status ${r.status} after ${Date.now() - t} ms, ${r.json ? r.json.out.length + ' chars, …' + JSON.stringify(r.json.out.slice(-40)) : r.text}`);
    await sleep(1500);
    const s = await req('GET', '/api/state').catch(e => ({ status: 0, text: String(e) }));
    check('the monitor is still running', s.status === 200, s.status || s.text);
    done();
})();