Skip to content

Commit acac0f0

Browse files
committed
[Discover] Context unskip date nanos functional tests (#73781)
* Use _source value of timestamp for search_after since ES allows this now * Unskip functional tests * Remove unused convertIsoToNanosAsStr # Conflicts: # src/plugins/discover/public/application/angular/context/api/utils/get_es_query_search_after.ts # test/functional/apps/context/_date_nanos_custom_timestamp.js
1 parent 8be822b commit acac0f0

File tree

4 files changed

+63
-19
lines changed

4 files changed

+63
-19
lines changed

src/plugins/discover/public/application/angular/context/api/utils/date_conversion.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,6 @@ export function extractNanos(timeFieldValue: string = ''): string {
3131
return fractionSeconds.length !== 9 ? fractionSeconds.padEnd(9, '0') : fractionSeconds;
3232
}
3333

34-
/**
35-
* extract the nanoseconds as string of a given ISO formatted timestamp
36-
*/
37-
export function convertIsoToNanosAsStr(isoValue: string): string {
38-
const nanos = extractNanos(isoValue);
39-
const millis = convertIsoToMillis(isoValue);
40-
return `${millis}${nanos.substr(3, 6)}`;
41-
}
42-
4334
/**
4435
* convert an iso formatted string to number of milliseconds since
4536
* 1970-01-01T00:00:00.000Z

src/plugins/discover/public/application/angular/context/api/utils/get_es_query_search_after.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
import { convertIsoToNanosAsStr } from './date_conversion';
2019
import { SurrDocType, EsHitRecordList, EsHitRecord } from '../context';
2120

2221
export type EsQuerySearchAfter = [string | number, string | number];
@@ -38,15 +37,10 @@ export function getEsQuerySearchAfter(
3837
// already surrounding docs -> first or last record is used
3938
const afterTimeRecIdx = type === 'successors' && documents.length ? documents.length - 1 : 0;
4039
const afterTimeDoc = documents[afterTimeRecIdx];
41-
const afterTimeValue = nanoSeconds
42-
? convertIsoToNanosAsStr(afterTimeDoc._source[timeFieldName])
43-
: afterTimeDoc.sort[0];
40+
const afterTimeValue = nanoSeconds ? afterTimeDoc._source[timeFieldName] : afterTimeDoc.sort[0];
4441
return [afterTimeValue, afterTimeDoc.sort[1]];
4542
}
4643
// if data_nanos adapt timestamp value for sorting, since numeric value was rounded by browser
4744
// ES search_after also works when number is provided as string
48-
return [
49-
nanoSeconds ? convertIsoToNanosAsStr(anchor._source[timeFieldName]) : anchor.sort[0],
50-
anchor.sort[1],
51-
];
45+
return [nanoSeconds ? anchor._source[timeFieldName] : anchor.sort[0], anchor.sort[1]];
5246
}

test/functional/apps/context/_date_nanos.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ export default function ({ getService, getPageObjects }) {
3030
const PageObjects = getPageObjects(['common', 'context', 'timePicker', 'discover']);
3131
const esArchiver = getService('esArchiver');
3232

33-
// FLAKY/FAILING ES PROMOTION: https://github.com/elastic/kibana/issues/58815
34-
describe.skip('context view for date_nanos', () => {
33+
describe('context view for date_nanos', () => {
3534
before(async function () {
3635
await security.testUser.setRoles(['kibana_admin', 'kibana_date_nanos']);
3736
await esArchiver.loadIfNeeded('date_nanos');
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import expect from '@kbn/expect';
21+
22+
const TEST_INDEX_PATTERN = 'date_nanos_custom_timestamp';
23+
const TEST_DEFAULT_CONTEXT_SIZE = 1;
24+
const TEST_STEP_SIZE = 3;
25+
26+
export default function ({ getService, getPageObjects }) {
27+
const kibanaServer = getService('kibanaServer');
28+
const docTable = getService('docTable');
29+
const security = getService('security');
30+
const PageObjects = getPageObjects(['common', 'context', 'timePicker', 'discover']);
31+
const esArchiver = getService('esArchiver');
32+
33+
describe('context view for date_nanos with custom timestamp', () => {
34+
before(async function () {
35+
await security.testUser.setRoles(['kibana_admin', 'kibana_date_nanos_custom']);
36+
await esArchiver.loadIfNeeded('date_nanos_custom');
37+
await kibanaServer.uiSettings.replace({ defaultIndex: TEST_INDEX_PATTERN });
38+
await kibanaServer.uiSettings.update({
39+
'context:defaultSize': `${TEST_DEFAULT_CONTEXT_SIZE}`,
40+
'context:step': `${TEST_STEP_SIZE}`,
41+
});
42+
});
43+
44+
it('displays predessors - anchor - successors in right order ', async function () {
45+
await PageObjects.context.navigateTo(TEST_INDEX_PATTERN, '1');
46+
const actualRowsText = await docTable.getRowsText();
47+
const expectedRowsText = [
48+
'Oct 21, 2019 @ 08:30:04.828733000 -',
49+
'Oct 21, 2019 @ 00:30:04.828740000 -',
50+
'Oct 21, 2019 @ 00:30:04.828723000 -',
51+
];
52+
expect(actualRowsText).to.eql(expectedRowsText);
53+
});
54+
55+
after(async function () {
56+
await security.testUser.restoreDefaults();
57+
await esArchiver.unload('date_nanos_custom');
58+
});
59+
});
60+
}

0 commit comments

Comments
 (0)