Skip to content

Commit

Permalink
fix: sync workers
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-yarmosh committed Mar 26, 2024
1 parent dca8fe3 commit fe12233
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions test/e2e/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,22 @@ export const waitProbeToConnect = async () => {
};

export const waitProbeInCity = async (city: string) => {
let response;
let responses;

for (;;) {
try {
response = await got<any>('http://localhost:80/v1/probes', { responseType: 'json' });
responses = await Promise.all([
got<any>('http://localhost:80/v1/probes', { responseType: 'json' }),
got<any>('http://localhost:80/v1/probes', { responseType: 'json' }),
got<any>('http://localhost:80/v1/probes', { responseType: 'json' }),
got<any>('http://localhost:80/v1/probes', { responseType: 'json' }),
]);
} catch (err) {
logger.info((err as RequestError).code);
throw err;
}

if (response.body.length > 0 && response.body[0].location.city === city) {
if (responses.every(response => response.body.length > 0 && response.body[0].location.city === city)) {
return;
}

Expand All @@ -68,7 +73,6 @@ export const waitMesurementFinish = async (id: string) => {
const response = await got<any>(`http://localhost:80/v1/measurements/${id}`, { responseType: 'json' });

if (response.body.status !== 'in-progress') {
logger.info('return');
return response;
}

Expand Down

0 comments on commit fe12233

Please sign in to comment.