summaryrefslogtreecommitdiff
path: root/test/sequential/test-inspector-stress-http.js
blob: 8d4a2db9570aad5b9cf30e620b4a8602f05da0cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
'use strict';
const common = require('../common');

common.skipIfInspectorDisabled();

const assert = require('assert');
const { NodeInstance } = require('../common/inspector-helper.js');

async function testHttp(child, number) {
  try {
    await child.httpGet(null, '/json/list');
    return true;
  } catch (e) {
    console.error(`Attempt ${number} failed`, e);
    return false;
  }
}

async function runTest() {
  const child = new NodeInstance(undefined, '');

  const promises = [];
  for (let i = 0; i < 100; i++) {
    promises.push(testHttp(child, i));
  }
  const result = await Promise.all(promises);
  assert(!result.some((a) => !a), 'Some attempts failed');
  return child.kill();
}

runTest();