Skip to content

Commit

Permalink
Fix issue with flaky sample data API integration test (elastic#165328)
Browse files Browse the repository at this point in the history
## Summary

Closes;  
- elastic#164568
- elastic#121883
  
## Context;  

This issue is caused by inconsistencies in timestamp format existing in
the [sample data for
flights](https://github.com/elastic/kibana/blob/8.10/src/plugins/home/server/services/sample_data/data_sets/flights/flights.json.gz).

See screenshot; 

<img width="1020" alt="Screenshot 2023-09-06 at 09 45 18"
src="https://github.com/elastic/kibana/assets/7893459/e358eb2d-dc92-4e0d-b697-e362e2dbd33b">

When the flight sample data is being installed, on encountering any one
of these data points with a timestamp that's not a valid representation
for a date ISOString, it results in the [computation of a
value](https://github.com/elastic/kibana/blame/v8.9.1/src/plugins/home/server/services/sample_data/lib/translate_timestamp.ts#L46)
that can not be parsed as a valid date, this is verifiable taking a look
at the result of a failed flaky test run
[here](https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/3037#018a5164-27e7-45d9-897c-56f34fe2bfc3/288-1243)
logging the documents returned that the test would run against, one
would note that the timestamp value for the first document is
`2000-01-15T` which computes to `NaN` when parsed which further cascades
into other parts of the test, causing it to fail eventually.

This PR removes the data points with the invalid timestamps and modifies
the tests to match the new expectation for the number of documents that
should have been indexed. This change set was also ran through the
[flaky test
runner](https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/3077)
with success.


### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
  • Loading branch information
eokoneyo authored Sep 13, 2023
1 parent 9a798c7 commit 92fcfa9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
Binary file not shown.
19 changes: 9 additions & 10 deletions test/api_integration/apis/home/sample_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,19 @@ export default function ({ getService }: FtrProviderContext) {

const MILLISECOND_IN_WEEK = 1000 * 60 * 60 * 24 * 7;
const SPACES = ['default', 'other'];
const FLIGHTS_OVERVIEW_DASHBOARD_ID = '7adfa750-4c81-11e8-b3d7-01146121b73d'; // default ID of the flights overview dashboard
/**
* default ID of the flights overview dashboard
* @see src/plugins/home/server/services/sample_data/data_sets/flights/index.ts
*/
const FLIGHTS_OVERVIEW_DASHBOARD_ID = '7adfa750-4c81-11e8-b3d7-01146121b73d';
const FLIGHTS_CANVAS_APPLINK_PATH =
'/app/canvas#/workpad/workpad-a474e74b-aedc-47c3-894a-db77e62c41e0'; // includes default ID of the flights canvas applink path

const includesPathInAppLinks = (appLinks: Array<{ path: string }>, path: string): boolean => {
return appLinks.some((item) => item.path === path);
};

// Failing: See https://github.com/elastic/kibana/issues/164568
describe.skip('sample data apis', () => {
describe('sample data apis', () => {
before(async () => {
await esArchiver.emptyKibanaIndex();
});
Expand Down Expand Up @@ -64,7 +67,7 @@ export default function ({ getService }: FtrProviderContext) {
.expect(200);

expect(resp.body).to.eql({
elasticsearchIndicesCreated: { kibana_sample_data_flights: 13059 },
elasticsearchIndicesCreated: { kibana_sample_data_flights: 13014 },
kibanaSavedObjectsLoaded: 8,
});
});
Expand All @@ -73,9 +76,7 @@ export default function ({ getService }: FtrProviderContext) {
it('should load elasticsearch index containing sample data with dates relative to current time', async () => {
const resp = await es.search<{ timestamp: string }>({
index: 'kibana_sample_data_flights',
body: {
sort: [{ timestamp: { order: 'desc' } }],
},
sort: [{ timestamp: { order: 'desc' } }],
});

const doc = resp.hits.hits[0];
Expand All @@ -91,9 +92,7 @@ export default function ({ getService }: FtrProviderContext) {

const resp = await es.search<{ timestamp: string }>({
index: 'kibana_sample_data_flights',
body: {
sort: [{ timestamp: { order: 'desc' } }],
},
sort: [{ timestamp: { order: 'desc' } }],
});

const doc = resp.hits.hits[0];
Expand Down

0 comments on commit 92fcfa9

Please sign in to comment.