Skip to content

Commit

Permalink
[Data Explorer][Discover][Functional Test] Fix ciGroup7
Browse files Browse the repository at this point in the history
Issue Resolve
opensearch-project#5129

Signed-off-by: Anan Zhuang <[email protected]>
  • Loading branch information
ananzh committed Sep 27, 2023
1 parent 7a843e6 commit 03e9cd1
Show file tree
Hide file tree
Showing 9 changed files with 262 additions and 138 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@
"chai": "3.5.0",
"chance": "1.0.18",
"cheerio": "0.22.0",
"chromedriver": "^107.0.3",
"chromedriver": "^100",
"classnames": "2.3.1",
"compare-versions": "3.5.1",
"d3": "3.5.17",
Expand Down
5 changes: 2 additions & 3 deletions test/functional/apps/context/_discover_navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@ export default function ({ getService, getPageObjects }) {
});

it('should open the context view with the same columns', async () => {
const data = await dataGrid.getDataGridTableData();

expect(data.columns).to.eql(['', 'Time (@timestamp)', ...TEST_COLUMN_NAMES]);
const data = await dataGrid.getHeaderFields();
expect(data.columns).to.eql(['Time (@timestamp)', ...TEST_COLUMN_NAMES]);
});

it('should open the context view with the filters disabled', async () => {
Expand Down
24 changes: 7 additions & 17 deletions test/functional/apps/management/_index_pattern_results_sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ export default function ({ getService, getPageObjects }) {
before(async function () {
// delete .kibana index and then wait for OpenSearch Dashboards to re-create it
await opensearchDashboardsServer.uiSettings.replace({});
await PageObjects.settings.navigateTo();
await PageObjects.settings.createIndexPattern();
});

after(async function () {
return await PageObjects.settings.removeIndexPattern();
});

const columns = [
Expand All @@ -64,14 +70,6 @@ export default function ({ getService, getPageObjects }) {

columns.forEach(function (col) {
describe('sort by heading - ' + col.heading, function indexPatternCreation() {
before(async function () {
await PageObjects.settings.createIndexPattern();
});

after(async function () {
return await PageObjects.settings.removeIndexPattern();
});

it('should sort ascending', async function () {
await PageObjects.settings.sortBy(col.heading);
const rowText = await col.selector();
Expand All @@ -85,17 +83,9 @@ export default function ({ getService, getPageObjects }) {
});
});
});

describe('field list pagination', function () {
const EXPECTED_FIELD_COUNT = 86;

before(async function () {
await PageObjects.settings.createIndexPattern();
});

after(async function () {
return await PageObjects.settings.removeIndexPattern();
});

it('makelogs data should have expected number of fields', async function () {
await retry.try(async function () {
const TabCount = await PageObjects.settings.getFieldsTabCount();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export default function ({ getService, getPageObjects }) {
before(async function () {
// delete .kibana index and then wait for OpenSearch Dashboards to re-create it
await opensearchDashboardsServer.uiSettings.replace({});
await PageObjects.settings.createIndexPattern('logstash-*');
await PageObjects.settings.navigateTo();
await PageObjects.settings.createIndexPattern('logstash-*');
});

after(async function afterAll() {
Expand Down
178 changes: 94 additions & 84 deletions test/functional/apps/management/_scripted_fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@

import expect from '@osd/expect';

function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}

export default function ({ getService, getPageObjects }) {
const opensearchArchiver = getService('opensearchArchiver');
const opensearchDashboardsServer = getService('opensearchDashboardsServer');
Expand Down Expand Up @@ -161,6 +165,7 @@ export default function ({ getService, getPageObjects }) {
const fromTime = 'Sep 17, 2015 @ 06:31:44.000';
const toTime = 'Sep 18, 2015 @ 18:31:44.000';
await PageObjects.common.navigateToApp('discover');
await PageObjects.discover.selectIndexPattern('logstash-*');
await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime);

await PageObjects.discover.clickFieldListItem(scriptedPainlessFieldName);
Expand All @@ -169,31 +174,31 @@ export default function ({ getService, getPageObjects }) {
});
await PageObjects.header.waitUntilLoadingHasFinished();

await retry.try(async function () {
const rowData = await PageObjects.discover.getDocTableIndex(1);
expect(rowData).to.be('Sep 18, 2015 @ 18:20:57.916\n18');
});
const rowData = await PageObjects.discover.getDataGridTableValues();
expect(rowData[0][0]).to.be('Sep 18, 2015 @ 18:20:57.916');
expect(rowData[0][1]).to.be('18');
});

//add a test to sort numeric scripted field
it('should sort scripted field value in Discover', async function () {
await testSubjects.click(`docTableHeaderFieldSort_${scriptedPainlessFieldName}`);
// after the first click on the scripted field, it becomes secondary sort after time.
// click on the timestamp twice to make it be the secondary sort key.
await testSubjects.click('docTableHeaderFieldSort_@timestamp');
await testSubjects.click('docTableHeaderFieldSort_@timestamp');
await testSubjects.click(`dataGridHeaderCell-${scriptedPainlessFieldName}`);
await PageObjects.discover.clickTableHeaderListItem(scriptedPainlessFieldName, 'Sort A-Z');
await PageObjects.header.waitUntilLoadingHasFinished();
await retry.try(async function () {
const rowData = await PageObjects.discover.getDocTableIndex(1);
expect(rowData).to.be('Sep 17, 2015 @ 10:53:14.181\n-1');
});

await testSubjects.click(`docTableHeaderFieldSort_${scriptedPainlessFieldName}`);
await testSubjects.click('dataGridHeaderCell-@timestamp');
await PageObjects.discover.clickTableHeaderListItem('@timestamp', 'Sort A-Z');
await PageObjects.header.waitUntilLoadingHasFinished();
await retry.try(async function () {
const rowData = await PageObjects.discover.getDocTableIndex(1);
expect(rowData).to.be('Sep 17, 2015 @ 06:32:29.479\n20');
});
const sortedDataByTimeField = await PageObjects.discover.getDataGridTableValues();
expect(sortedDataByTimeField[0][0]).contain('Sep 17, 2015 @ 10:53:14.181');
expect(sortedDataByTimeField[0][1]).contain('-1');

// click the column sorting button to remove painless field sort
// should sort only by time field
await testSubjects.click('dataGridColumnSortingButton');
await PageObjects.discover.removeSort(`${scriptedPainlessFieldName}`);
await PageObjects.header.waitUntilLoadingHasFinished();
const sortedDataByPainlessField = await PageObjects.discover.getDataGridTableValues();
expect(sortedDataByPainlessField[0][0]).contain('Sep 17, 2015 @ 06:32:29.479');
expect(sortedDataByPainlessField[0][1]).contain('20');
});

it('should filter by scripted field value in Discover', async function () {
Expand Down Expand Up @@ -238,6 +243,7 @@ export default function ({ getService, getPageObjects }) {
];

await inspector.open();
await sleep(10000);
await inspector.setTablePageSize(50);
await inspector.expectTableData(expectedChartValues);
} else {
Expand Down Expand Up @@ -278,6 +284,7 @@ export default function ({ getService, getPageObjects }) {
const fromTime = 'Sep 17, 2015 @ 06:31:44.000';
const toTime = 'Sep 18, 2015 @ 18:31:44.000';
await PageObjects.common.navigateToApp('discover');
await PageObjects.discover.selectIndexPattern('logstash-*');
await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime);

await PageObjects.discover.clickFieldListItem(scriptedPainlessFieldName2);
Expand All @@ -286,31 +293,31 @@ export default function ({ getService, getPageObjects }) {
});
await PageObjects.header.waitUntilLoadingHasFinished();

await retry.try(async function () {
const rowData = await PageObjects.discover.getDocTableIndex(1);
expect(rowData).to.be('Sep 18, 2015 @ 18:20:57.916\ngood');
});
const rowData = await PageObjects.discover.getDataGridTableValues();
expect(rowData[0][0]).to.be('Sep 18, 2015 @ 18:20:57.916');
expect(rowData[0][1]).to.be('good');
});

//add a test to sort string scripted field
it('should sort scripted field value in Discover', async function () {
await testSubjects.click(`docTableHeaderFieldSort_${scriptedPainlessFieldName2}`);
// after the first click on the scripted field, it becomes secondary sort after time.
// click on the timestamp twice to make it be the secondary sort key.
await testSubjects.click('docTableHeaderFieldSort_@timestamp');
await testSubjects.click('docTableHeaderFieldSort_@timestamp');
await testSubjects.click(`dataGridHeaderCell-${scriptedPainlessFieldName2}`);
await PageObjects.discover.clickTableHeaderListItem(scriptedPainlessFieldName2, 'Sort A-Z');
await PageObjects.header.waitUntilLoadingHasFinished();
await retry.try(async function () {
const rowData = await PageObjects.discover.getDocTableIndex(1);
expect(rowData).to.be('Sep 17, 2015 @ 09:48:40.594\nbad');
});

await testSubjects.click(`docTableHeaderFieldSort_${scriptedPainlessFieldName2}`);
await testSubjects.click('dataGridHeaderCell-@timestamp');
await PageObjects.discover.clickTableHeaderListItem('@timestamp', 'Sort A-Z');
await PageObjects.header.waitUntilLoadingHasFinished();
await retry.try(async function () {
const rowData = await PageObjects.discover.getDocTableIndex(1);
expect(rowData).to.be('Sep 17, 2015 @ 06:32:29.479\ngood');
});
const sortedDataByTimeField = await PageObjects.discover.getDataGridTableValues();
expect(sortedDataByTimeField[0][0]).contain('Sep 17, 2015 @ 09:48:40.594');
expect(sortedDataByTimeField[0][1]).contain('bad');

// click the column sorting button to remove painless field sort
// should sort only by time field
await testSubjects.click('dataGridColumnSortingButton');
await PageObjects.discover.removeSort(`${scriptedPainlessFieldName2}`);
await PageObjects.header.waitUntilLoadingHasFinished();
const sortedDataByPainlessField = await PageObjects.discover.getDataGridTableValues();
expect(sortedDataByPainlessField[0][0]).contain('Sep 17, 2015 @ 06:32:29.479');
expect(sortedDataByPainlessField[0][1]).contain('good');
});

it('should filter by scripted field value in Discover', async function () {
Expand Down Expand Up @@ -373,6 +380,7 @@ export default function ({ getService, getPageObjects }) {
const fromTime = 'Sep 17, 2015 @ 06:31:44.000';
const toTime = 'Sep 18, 2015 @ 18:31:44.000';
await PageObjects.common.navigateToApp('discover');
await PageObjects.discover.selectIndexPattern('logstash-*');
await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime);

await PageObjects.discover.clickFieldListItem(scriptedPainlessFieldName2);
Expand All @@ -381,10 +389,34 @@ export default function ({ getService, getPageObjects }) {
});
await PageObjects.header.waitUntilLoadingHasFinished();

await retry.try(async function () {
const rowData = await PageObjects.discover.getDocTableIndex(1);
expect(rowData).to.be('Sep 18, 2015 @ 18:20:57.916\ntrue');
});
const rowData = await PageObjects.discover.getDataGridTableValues();
expect(rowData[0][0]).to.be('Sep 18, 2015 @ 18:20:57.916');
expect(rowData[0][1]).to.be('true');
});

// existing bug: https://github.com/opensearch-project/OpenSearch-Dashboards/issues/5126 hence the issue is skipped
// TODO: replace updateExpectedResultHere with actual data value once bug is fixed
it.skip('should sort scripted field value in Discover', async function () {
await sleep(50000);
await testSubjects.click(`dataGridHeaderCell-${scriptedPainlessFieldName2}`);
await PageObjects.discover.clickTableHeaderListItem(
scriptedPainlessFieldName2,
'Sort True-False'
);
await PageObjects.header.waitUntilLoadingHasFinished();
await testSubjects.click('dataGridHeaderCell-@timestamp');
await PageObjects.discover.clickTableHeaderListItem('@timestamp', 'Sort A-Z');
await PageObjects.header.waitUntilLoadingHasFinished();
const sortedDataByTimeField = await PageObjects.discover.getDataGridTableValues();
expect(sortedDataByTimeField[0][0]).contain('updateExpectedResultHere');
expect(sortedDataByTimeField[0][1]).contain('true');

await testSubjects.click('dataGridColumnSortingButton');
await PageObjects.discover.removeSort(`${scriptedPainlessFieldName2}`);
await PageObjects.header.waitUntilLoadingHasFinished();
const sortedDataByPainlessField = await PageObjects.discover.getDataGridTableValues();
expect(sortedDataByPainlessField[0][0]).contain('updateExpectedResultHere');
expect(sortedDataByPainlessField[0][1]).contain('false');
});

it('should filter by scripted field value in Discover', async function () {
Expand All @@ -399,28 +431,6 @@ export default function ({ getService, getPageObjects }) {
await filterBar.removeAllFilters();
});

//add a test to sort boolean
//existing bug: https://github.com/elastic/kibana/issues/75519 hence the issue is skipped.
it.skip('should sort scripted field value in Discover', async function () {
await testSubjects.click(`docTableHeaderFieldSort_${scriptedPainlessFieldName2}`);
// after the first click on the scripted field, it becomes secondary sort after time.
// click on the timestamp twice to make it be the secondary sort key.
await testSubjects.click('docTableHeaderFieldSort_@timestamp');
await testSubjects.click('docTableHeaderFieldSort_@timestamp');
await PageObjects.header.waitUntilLoadingHasFinished();
await retry.try(async function () {
const rowData = await PageObjects.discover.getDocTableIndex(1);
expect(rowData).to.be('updateExpectedResultHere\ntrue');
});

await testSubjects.click(`docTableHeaderFieldSort_${scriptedPainlessFieldName2}`);
await PageObjects.header.waitUntilLoadingHasFinished();
await retry.try(async function () {
const rowData = await PageObjects.discover.getDocTableIndex(1);
expect(rowData).to.be('updateExpectedResultHere\nfalse');
});
});

it('should visualize scripted field in vertical bar chart', async function () {
await PageObjects.discover.clickFieldListItemVisualize(scriptedPainlessFieldName2);
await PageObjects.header.waitUntilLoadingHasFinished();
Expand Down Expand Up @@ -469,6 +479,7 @@ export default function ({ getService, getPageObjects }) {
const fromTime = 'Sep 17, 2015 @ 19:22:00.000';
const toTime = 'Sep 18, 2015 @ 07:00:00.000';
await PageObjects.common.navigateToApp('discover');
await PageObjects.discover.selectIndexPattern('logstash-*');
await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime);

await PageObjects.discover.clickFieldListItem(scriptedPainlessFieldName2);
Expand All @@ -477,35 +488,34 @@ export default function ({ getService, getPageObjects }) {
});
await PageObjects.header.waitUntilLoadingHasFinished();

await retry.try(async function () {
const rowData = await PageObjects.discover.getDocTableIndex(1);
expect(rowData).to.be('Sep 18, 2015 @ 06:52:55.953\n2015-09-18 07:00');
});
const rowData = await PageObjects.discover.getDataGridTableValues();
expect(rowData[0][0]).to.be('Sep 18, 2015 @ 06:52:55.953');
expect(rowData[0][1]).to.be('2015-09-18 07:00');
});

//add a test to sort date scripted field
//https://github.com/elastic/kibana/issues/75711
// existing bug: https://github.com/opensearch-project/OpenSearch-Dashboards/issues/5127 hence the issue is skipped
// TODO: replace updateExpectedResultHere with actual data value once bug is fixed
it.skip('should sort scripted field value in Discover', async function () {
await testSubjects.click(`docTableHeaderFieldSort_${scriptedPainlessFieldName2}`);
// after the first click on the scripted field, it becomes secondary sort after time.
// click on the timestamp twice to make it be the secondary sort key.
await testSubjects.click('docTableHeaderFieldSort_@timestamp');
await testSubjects.click('docTableHeaderFieldSort_@timestamp');
await testSubjects.click(`dataGridHeaderCell-${scriptedPainlessFieldName2}`);
await PageObjects.discover.clickTableHeaderListItem(scriptedPainlessFieldName2, 'Sort A-Z');
await PageObjects.header.waitUntilLoadingHasFinished();
await retry.try(async function () {
const rowData = await PageObjects.discover.getDocTableIndex(1);
expect(rowData).to.be('updateExpectedResultHere\n2015-09-18 07:00');
});
await testSubjects.click('dataGridHeaderCell-@timestamp');
await PageObjects.discover.clickTableHeaderListItem('@timestamp', 'Sort A-Z');
await PageObjects.header.waitUntilLoadingHasFinished();
const sortedDataByTimeField = await PageObjects.discover.getDataGridTableValues();
expect(sortedDataByTimeField[0][0]).contain('updateExpectedResultHere');
expect(sortedDataByTimeField[0][1]).contain('2015-09-18 07:00');

await testSubjects.click(`docTableHeaderFieldSort_${scriptedPainlessFieldName2}`);
await testSubjects.click('dataGridColumnSortingButton');
await PageObjects.discover.removeSort(`${scriptedPainlessFieldName2}`);
await PageObjects.header.waitUntilLoadingHasFinished();
await retry.try(async function () {
const rowData = await PageObjects.discover.getDocTableIndex(1);
expect(rowData).to.be('updateExpectedResultHere\n2015-09-18 07:00');
});
const sortedDataByPainlessField = await PageObjects.discover.getDataGridTableValues();
expect(sortedDataByPainlessField[0][0]).contain('updateExpectedResultHere');
expect(sortedDataByPainlessField[0][1]).contain('2015-09-18 07:00');
});

it('should filter by scripted field value in Discover', async function () {
await sleep(50000);
await PageObjects.discover.clickFieldListItemDetails(scriptedPainlessFieldName2);
await log.debug('filter by "Sep 18, 2015 @ 7:52" in the expanded scripted field list');
await PageObjects.discover.clickFieldListPlusFilter(
Expand Down
3 changes: 1 addition & 2 deletions test/functional/apps/management/_scripted_fields_preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ export default function ({ getService, getPageObjects }) {
describe('scripted fields preview', () => {
before(async function () {
await browser.setWindowSize(1200, 800);
await PageObjects.settings.createIndexPattern();

await PageObjects.settings.navigateTo();
await PageObjects.settings.createIndexPattern();
await PageObjects.settings.clickOpenSearchDashboardsIndexPatterns();
await PageObjects.settings.clickIndexPatternLogstash();
await PageObjects.settings.clickScriptedFieldsTab();
Expand Down
Loading

0 comments on commit 03e9cd1

Please sign in to comment.