11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures'); 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ciif (!common.hasCrypto) 61cb0ef41Sopenharmony_ci common.skip('missing crypto'); 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ciconst child_process = require('child_process'); 91cb0ef41Sopenharmony_ciconst http2 = require('http2'); 101cb0ef41Sopenharmony_ciconst fs = require('fs'); 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ciconst key = fixtures.readKey('agent8-key.pem', 'binary'); 131cb0ef41Sopenharmony_ciconst cert = fixtures.readKey('agent8-cert.pem', 'binary'); 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ciconst server = http2.createSecureServer({ key, cert }, (request, response) => { 161cb0ef41Sopenharmony_ci fs.createReadStream(process.execPath).pipe(response); 171cb0ef41Sopenharmony_ci}); 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_ci// This should be doable with a reproduction purely written in Node; 201cb0ef41Sopenharmony_ci// that just requires somebody to take the time and actually do it. 211cb0ef41Sopenharmony_ciserver.listen(0, () => { 221cb0ef41Sopenharmony_ci const proc = child_process.spawn('h2load', [ 231cb0ef41Sopenharmony_ci '-n', '1000', 241cb0ef41Sopenharmony_ci `https://localhost:${server.address().port}/`, 251cb0ef41Sopenharmony_ci ]); 261cb0ef41Sopenharmony_ci proc.on('error', (err) => { 271cb0ef41Sopenharmony_ci if (err.code === 'ENOENT') 281cb0ef41Sopenharmony_ci common.skip('no h2load'); 291cb0ef41Sopenharmony_ci }); 301cb0ef41Sopenharmony_ci proc.on('exit', () => server.close()); 311cb0ef41Sopenharmony_ci setTimeout(() => proc.kill(2), 100); 321cb0ef41Sopenharmony_ci}); 33