Skip to content

Commit d5264a3

Browse files
committed
test: align monitor parallelization tests with new env var and default
Use SNYK_INTERNAL_REQUEST_CONCURRENCY (the internal env var the TS code now reads) and assert the new default of 5.
1 parent 07716e3 commit d5264a3

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

test/jest/unit/ecosystems-monitor-docker.spec.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -287,13 +287,13 @@ describe('monitorEcosystem docker/container', () => {
287287
});
288288

289289
describe('parallelization of monitor-dependencies requests', () => {
290-
const ORIGINAL_CONCURRENCY = process.env.SNYK_REQUEST_CONCURRENCY;
290+
const ORIGINAL_CONCURRENCY = process.env.SNYK_INTERNAL_REQUEST_CONCURRENCY;
291291

292292
afterEach(() => {
293293
if (ORIGINAL_CONCURRENCY === undefined) {
294-
delete process.env.SNYK_REQUEST_CONCURRENCY;
294+
delete process.env.SNYK_INTERNAL_REQUEST_CONCURRENCY;
295295
} else {
296-
process.env.SNYK_REQUEST_CONCURRENCY = ORIGINAL_CONCURRENCY;
296+
process.env.SNYK_INTERNAL_REQUEST_CONCURRENCY = ORIGINAL_CONCURRENCY;
297297
}
298298
});
299299

@@ -327,8 +327,8 @@ describe('monitorEcosystem docker/container', () => {
327327
});
328328
}
329329

330-
it('caps in-flight requests at the default concurrency (10)', async () => {
331-
delete process.env.SNYK_REQUEST_CONCURRENCY;
330+
it('caps in-flight requests at the default concurrency (5)', async () => {
331+
delete process.env.SNYK_INTERNAL_REQUEST_CONCURRENCY;
332332
const scanResults = Array.from({ length: 25 }, (_, i) =>
333333
makeMavenScanResult(`app-${i}`),
334334
);
@@ -349,12 +349,12 @@ describe('monitorEcosystem docker/container', () => {
349349

350350
await runMonitor(scanResults);
351351

352-
expect(peakInFlight).toBeLessThanOrEqual(10);
352+
expect(peakInFlight).toBeLessThanOrEqual(5);
353353
expect(peakInFlight).toBeGreaterThan(1);
354354
});
355355

356-
it('respects SNYK_REQUEST_CONCURRENCY override', async () => {
357-
process.env.SNYK_REQUEST_CONCURRENCY = '3';
356+
it('respects SNYK_INTERNAL_REQUEST_CONCURRENCY override', async () => {
357+
process.env.SNYK_INTERNAL_REQUEST_CONCURRENCY = '3';
358358
const scanResults = Array.from({ length: 15 }, (_, i) =>
359359
makeMavenScanResult(`app-${i}`),
360360
);
@@ -379,7 +379,7 @@ describe('monitorEcosystem docker/container', () => {
379379
});
380380

381381
it('preserves result order matching input order', async () => {
382-
delete process.env.SNYK_REQUEST_CONCURRENCY;
382+
delete process.env.SNYK_INTERNAL_REQUEST_CONCURRENCY;
383383
const scanResults = ['os', 'app-1', 'app-2', 'app-3', 'app-4'].map(
384384
makeMavenScanResult,
385385
);
@@ -410,7 +410,7 @@ describe('monitorEcosystem docker/container', () => {
410410
});
411411

412412
it('throws MonitorError when any request returns 4xx (fail-fast)', async () => {
413-
delete process.env.SNYK_REQUEST_CONCURRENCY;
413+
delete process.env.SNYK_INTERNAL_REQUEST_CONCURRENCY;
414414
const scanResults = ['app-1', 'app-2', 'app-3'].map(makeMavenScanResult);
415415

416416
jest.spyOn(request, 'makeRequest').mockImplementation((payload: any) => {
@@ -425,7 +425,7 @@ describe('monitorEcosystem docker/container', () => {
425425
});
426426

427427
it('accumulates 5xx errors per scan-result without aborting', async () => {
428-
delete process.env.SNYK_REQUEST_CONCURRENCY;
428+
delete process.env.SNYK_INTERNAL_REQUEST_CONCURRENCY;
429429
const scanResults = ['app-1', 'app-2', 'app-3'].map(makeMavenScanResult);
430430

431431
jest.spyOn(request, 'makeRequest').mockImplementation((payload: any) => {

0 commit comments

Comments
 (0)