xref: /third_party/node/test/parallel/test-inspector-stress-http.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ci
41cb0ef41Sopenharmony_cicommon.skipIfInspectorDisabled();
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ciconst assert = require('assert');
71cb0ef41Sopenharmony_ciconst { NodeInstance } = require('../common/inspector-helper.js');
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ciasync function testHttp(child, number) {
101cb0ef41Sopenharmony_ci  try {
111cb0ef41Sopenharmony_ci    await child.httpGet(null, '/json/list');
121cb0ef41Sopenharmony_ci    return true;
131cb0ef41Sopenharmony_ci  } catch (e) {
141cb0ef41Sopenharmony_ci    console.error(`Attempt ${number} failed`, e);
151cb0ef41Sopenharmony_ci    return false;
161cb0ef41Sopenharmony_ci  }
171cb0ef41Sopenharmony_ci}
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_ciasync function runTest() {
201cb0ef41Sopenharmony_ci  const child = new NodeInstance(undefined, '');
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_ci  const promises = [];
231cb0ef41Sopenharmony_ci  for (let i = 0; i < 100; i++) {
241cb0ef41Sopenharmony_ci    promises.push(testHttp(child, i));
251cb0ef41Sopenharmony_ci  }
261cb0ef41Sopenharmony_ci  const result = await Promise.all(promises);
271cb0ef41Sopenharmony_ci  assert(!result.some((a) => !a), 'Some attempts failed');
281cb0ef41Sopenharmony_ci  return child.kill();
291cb0ef41Sopenharmony_ci}
301cb0ef41Sopenharmony_ci
311cb0ef41Sopenharmony_cirunTest().then(common.mustCall());
32

Indexes created Thu Nov 07 10:32:03 CST 2024