Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Commit

Permalink
we don't get timeout, but car_too_large
Browse files Browse the repository at this point in the history
  • Loading branch information
juliangruber committed Mar 28, 2024
1 parent 0ec4020 commit 7f62043
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/preprocess.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ const assertValidMeasurement = measurement => {
* @return {import('./typings').RetrievalResult}
*/
export const getRetrievalResult = measurement => {
if (measurement.timeout) return 'TIMEOUT'
if (measurement.car_too_large) return 'CAR_TOO_LARGE'
switch (measurement.status_code) {
case 502: return 'BAD_GATEWAY'
case 504: return 'GATEWAY_TIMEOUT'
Expand Down
2 changes: 1 addition & 1 deletion lib/retrieval-stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const buildRetrievalStats = (measurements, telemetryPoint) => {
/** @type {Record<import('./typings').RetrievalResult, number> */
const resultBreakdown = {
OK: 0,
TIMEOUT: 0,
CAR_TOO_LARGE: 0,
BAD_GATEWAY: 0,
GATEWAY_TIMEOUT: 0
}
Expand Down
4 changes: 2 additions & 2 deletions lib/typings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export type FraudAssesment =
// When adding a new enum value, remember to update the summary initializer inside `reportRetrievalStats()`
export type RetrievalResult =
| 'OK'
| 'TIMEOUT'
| 'CAR_TOO_LARGE'
| 'BAD_GATEWAY'
| 'GATEWAY_TIMEOUT'
| 'ERROR_500'
Expand All @@ -54,7 +54,7 @@ export interface Measurement {
finished_at: number;

status_code: number | undefined | null;
timeout: boolean;
car_too_large: boolean;
}

export interface GroupWinningStats {
Expand Down
2 changes: 1 addition & 1 deletion test/evaluate.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ describe('evaluate', () => {
inet_group: 'group3',
// invalid task
cid: 'bafyreicnokmhmrnlp2wjhyk2haep4tqxiptwfrp2rrs7rzq7uk766chqvq',
retrievalResult: 'TIMEOUT'
retrievalResult: 'CAR_TOO_LARGE'
})
}
const setScoresCalls = []
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/test-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const VALID_MEASUREMENT = {
participantAddress: VALID_PARTICIPANT_ADDRESS,
inet_group: 'some-group-id',
status_code: 200,
timeout: false,
car_too_large: false,
end_at: new Date('2023-11-01T09:00:02.000Z').getTime(),
finished_at: new Date('2023-11-01T09:00:10.000Z').getTime(),
retrievalResult: 'OK'
Expand Down
10 changes: 5 additions & 5 deletions test/preprocess.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('getRetrievalResult', () => {
id: 11009569,
zinnia_version: '0.14.0',
participant_address: 'f410fgkhpcrbmdvic52o3nivftrjxr7nzw47updmuzra',
timeout: false,
car_too_large: false,
status_code: 200,
end_at: '1970-01-01T00:00:00.000Z',
inet_group: 'ue49TX_JdYjI',
Expand All @@ -82,12 +82,12 @@ describe('getRetrievalResult', () => {
assert.strictEqual(result, 'OK')
})

it('TIMEOUT', () => {
it('CAR_TOO_LARGE', () => {
const result = getRetrievalResult({
...SUCCESSFUL_RETRIEVAL,
timeout: true
car_too_large: true
})
assert.strictEqual(result, 'TIMEOUT')
assert.strictEqual(result, 'CAR_TOO_LARGE')
})

it('BAD_GATEWAY', () => {
Expand Down Expand Up @@ -133,7 +133,7 @@ describe('getRetrievalResult', () => {
it('UNKNOWN_ERROR - status_code is null', () => {
const result = getRetrievalResult({
...SUCCESSFUL_RETRIEVAL,
timeout: false,
car_too_large: false,
status_code: null
})
assert.strictEqual(result, 'UNKNOWN_ERROR')
Expand Down
6 changes: 3 additions & 3 deletions test/retrieval-stats.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ describe('retrieval statistics', () => {
},
{
...VALID_MEASUREMENT,
timeout: true,
retrievalResult: 'TIMEOUT',
car_too_large: true,
retrievalResult: 'CAR_TOO_LARGE',

end_at: new Date('2023-11-01T09:00:50.000Z').getTime(),
finished_at: new Date('2023-11-01T09:00:30.000Z').getTime()
Expand Down Expand Up @@ -50,7 +50,7 @@ describe('retrieval statistics', () => {
assertPointFieldValue(point, 'inet_groups', '2i')

assertPointFieldValue(point, 'result_rate_OK', '0.3333333333333333')
assertPointFieldValue(point, 'result_rate_TIMEOUT', '0.3333333333333333')
assertPointFieldValue(point, 'result_rate_CAR_TOO_LARGE', '0.3333333333333333')
assertPointFieldValue(point, 'result_rate_ERROR_500', '0.3333333333333333')

assertPointFieldValue(point, 'tasks_per_node_p5', '1i')
Expand Down

0 comments on commit 7f62043

Please sign in to comment.