Skip to content

Commit bdb9d4c

Browse files
committed
chore: unify upstream polling options into one place
Make it explicit which options we are configuring when polling the upstream for data in tests.
1 parent 305a8ba commit bdb9d4c

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

test/helpers/kubernetes-upstream.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ import {
77
import { WorkloadLocatorValidator, WorkloadMetadataValidator } from './types';
88
import config = require('../../src/common/config');
99

10-
const toneDownFactor = 5;
11-
const maxPodChecks = 600 / toneDownFactor;
10+
const UPSTREAM_POLLING_CONFIGURATION = {
11+
WAIT_BETWEEN_REQUESTS_MS: 5000,
12+
MAXIMUM_REQUESTS: 120,
13+
};
1214

1315
export async function getUpstreamResponseBody(
1416
relativeUrl: string,
@@ -22,7 +24,7 @@ export async function getUpstreamResponseBody(
2224
export async function validateUpstreamStoredData(
2325
validatorFn: WorkloadLocatorValidator,
2426
relativeUrl: string,
25-
remainingChecks: number = maxPodChecks,
27+
remainingChecks: number = UPSTREAM_POLLING_CONFIGURATION.MAXIMUM_REQUESTS,
2628
): Promise<boolean> {
2729
while (remainingChecks > 0) {
2830
console.log(`Pinging upstream for existing data (${remainingChecks} checks remaining)...`);
@@ -32,7 +34,7 @@ export async function validateUpstreamStoredData(
3234
if (result) {
3335
return true;
3436
}
35-
await sleep(1000 * toneDownFactor);
37+
await sleep(UPSTREAM_POLLING_CONFIGURATION.WAIT_BETWEEN_REQUESTS_MS);
3638
remainingChecks--;
3739
}
3840
return false;
@@ -41,7 +43,7 @@ export async function validateUpstreamStoredData(
4143
export async function validateUpstreamStoredMetadata(
4244
validatorFn: WorkloadMetadataValidator,
4345
relativeUrl: string,
44-
remainingChecks: number = maxPodChecks,
46+
remainingChecks: number = UPSTREAM_POLLING_CONFIGURATION.MAXIMUM_REQUESTS,
4547
): Promise<boolean> {
4648
while (remainingChecks > 0) {
4749
console.log(`Pinging upstream for existing metadata (${remainingChecks} checks remaining)...`);
@@ -52,7 +54,7 @@ export async function validateUpstreamStoredMetadata(
5254
if (result) {
5355
return true;
5456
}
55-
await sleep(1000 * toneDownFactor);
57+
await sleep(UPSTREAM_POLLING_CONFIGURATION.WAIT_BETWEEN_REQUESTS_MS);
5658
remainingChecks--;
5759
}
5860
return false;

0 commit comments

Comments
 (0)