Skip to content

Commit

Permalink
test: add offline test result int test
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-yarmosh committed Dec 8, 2023
1 parent 66b57da commit 75d90b7
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
18 changes: 18 additions & 0 deletions public/v1/components/schemas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,7 @@ components:
anyOf:
- $ref: 'schemas.yaml#/components/schemas/InProgressTestResult'
- $ref: 'schemas.yaml#/components/schemas/FailedTestResult'
- $ref: 'schemas.yaml#/components/schemas/OfflineTestResult'
- $ref: 'schemas.yaml#/components/schemas/FinishedPingTestResult'
- $ref: 'schemas.yaml#/components/schemas/FinishedTracerouteTestResult'
- $ref: 'schemas.yaml#/components/schemas/FinishedDnsTestResult'
Expand Down Expand Up @@ -762,6 +763,19 @@ components:
$ref: 'schemas.yaml#/components/schemas/FailedTestStatus'
rawOutput:
$ref: 'schemas.yaml#/components/schemas/TestRawOutput'
OfflineTestResult:
type: object
title: OfflineTestResult
description: |
Represents an `offline` test where requested probe is currently offline. Only possible when id of the previous measurement was passed to the `locations` field.
required:
- status
- rawOutput
properties:
status:
$ref: 'schemas.yaml#/components/schemas/OfflineTestStatus'
rawOutput:
$ref: 'schemas.yaml#/components/schemas/TestRawOutput'
FinishedPingTestResult:
title: FinishedPingTestResult
allOf:
Expand Down Expand Up @@ -1123,6 +1137,10 @@ components:
allOf:
- $ref: 'schemas.yaml#/components/schemas/BaseTestStatus'
- const: failed
OfflineTestStatus:
allOf:
- $ref: 'schemas.yaml#/components/schemas/BaseTestStatus'
- const: offline
TimingPacketRtt:
type: number
description: The round-trip time for this packet.
Expand Down
51 changes: 51 additions & 0 deletions test/tests/integration/measurement/create-measurement.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,57 @@ describe('Create measurement', () => {
});
});

describe('offline probes', () => {
after(() => {
probe.emit('probe:status:update', 'ready');
});

it('should create measurement with offline test result if requested probe is offline', async () => {
let id;
await requestAgent.post('/v1/measurements')
.send({
type: 'ping',
target: 'example.com',
limit: 2,
locations: [{
continent: 'NA',
}],
})
.expect(202)
.expect((response) => {
id = response.body.id;
});

probe.emit('probe:status:update', 'ping-test-failed');

let id2;
await requestAgent.post('/v1/measurements')
.send({
type: 'ping',
target: 'example.com',
locations: id,
})
.expect(202)
.expect((response) => {
expect(response.body.id).to.exist;
expect(response.header.location).to.exist;
expect(response.body.probesCount).to.equal(1);
expect(response).to.matchApiSchema();
id2 = response.body.id;
});

await requestAgent.get(`/v1/measurements/${id2}`)
.expect(200)
.expect((response) => {
expect(response.body.limit).to.equal(2);
expect(response.body.locations).to.deep.equal([{ continent: 'NA' }]);
expect(response.body.results[0].result.status).to.equal('offline');
expect(response.body.results[0].result.rawOutput).to.equal('This probe is currently offline. Please try again later.');
expect(response).to.matchApiSchema();
});
});
});

describe('adopted probes', () => {
before(async () => {
await client(ADOPTED_PROBES_TABLE).insert({
Expand Down

0 comments on commit 75d90b7

Please sign in to comment.