MCPcopy
hub / github.com/directus/directus / spawnAutoCannon

Function spawnAutoCannon

tests/blackbox/tests/common/assets/concurrency.test.ts:37–64  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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);

Callers 1

Calls 3

getUrlFunction · 0.90
onMethod · 0.80
parseMethod · 0.45

Tested by

no test coverage detected