-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(slo): introduce cursor pagination in Find SLO API (#203712)
- Loading branch information
Showing
14 changed files
with
323 additions
and
84 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
x-pack/platform/packages/shared/kbn-slo-schema/src/rest_specs/routes/find.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { merge } from 'lodash'; | ||
import { findSLOParamsSchema } from './find'; | ||
|
||
const BASE_REQUEST = { | ||
query: { | ||
filters: 'irrelevant', | ||
kqlQuery: 'irrelevant', | ||
page: '1', | ||
perPage: '25', | ||
sortBy: 'error_budget_consumed', | ||
sortDirection: 'asc', | ||
hideStale: true, | ||
}, | ||
}; | ||
|
||
describe('FindSLO schema validation', () => { | ||
it.each(['not_an_array', 42, [], [42, 'ok']])( | ||
'returns an error when searchAfter is not a valid JSON array (%s)', | ||
(searchAfter) => { | ||
const request = merge(BASE_REQUEST, { | ||
query: { | ||
searchAfter, | ||
}, | ||
}); | ||
const result = findSLOParamsSchema.decode(request); | ||
expect(result._tag === 'Left').toBe(true); | ||
} | ||
); | ||
|
||
it('parses searchAfter correctly', () => { | ||
const request = merge(BASE_REQUEST, { | ||
query: { | ||
searchAfter: JSON.stringify([1, 'ok']), | ||
}, | ||
}); | ||
const result = findSLOParamsSchema.decode(request); | ||
expect(result._tag === 'Right').toBe(true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.