()
| 35 | spawnAutoCannon(); |
| 36 | |
| 37 | function spawnAutoCannon() { |
| 38 | const url = `${getUrl(vendor)}/assets/${insertResponse.body.data.id}?access_token=${USER.ADMIN.TOKEN}`; |
| 39 | |
| 40 | const options = ['exec', 'autocannon', '-j', '-c', '100', '-t', '60', url]; |
| 41 | const child = spawn('pnpm', options); |
| 42 | |
| 43 | isSpawnRunning = true; |
| 44 | |
| 45 | let log = ''; |
| 46 | |
| 47 | child.stdout.on('data', (data) => { |
| 48 | log += String(data); |
| 49 | }); |
| 50 | |
| 51 | child.on('close', () => { |
| 52 | spawnCount++; |
| 53 | |
| 54 | const result = JSON.parse(log); |
| 55 | |
| 56 | if (result.timeouts > 0 || result.non2xx > 0) hasErrors = true; |
| 57 | |
| 58 | if (spawnCount < spawnCountTarget && !hasErrors) { |
| 59 | spawnAutoCannon(); |
| 60 | } else { |
| 61 | isSpawnRunning = false; |
| 62 | } |
| 63 | }); |
| 64 | } |
| 65 | |
| 66 | while (isSpawnRunning) { |
| 67 | await sleep(1000 * spawnCountTarget); |
no test coverage detected