Skip to content

Commit

Permalink
[TESTID-66] Add histogram tests (opensearch-project#9290)
Browse files Browse the repository at this point in the history
* Update actions/cache from v1 to v4 to address deprecation warning (opensearch-project#9366)

* build: Update actions/cache from v1 to v4 to address deprecation warning

Signed-off-by: Anan <[email protected]>

* Changeset file for PR opensearch-project#9366 created/updated

---------

Signed-off-by: Anan <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Signed-off-by: Federico Silva <[email protected]>

* Handle invalid geospatial request in region map (opensearch-project#8759)

Signed-off-by: Junqiu Lei <[email protected]>
Signed-off-by: Federico Silva <[email protected]>

* Update DEVELOPER_GUIDE.md (opensearch-project#9368)

When building the OpenSearch Dashboards artifact for Linux, the build may fail on certain distributions. This issue stems from the recent upgrade from node-sass to dart-sass. The new process uses an embeddable module from dart-sass to process Sass files, which relies on a platform-specific compiler. On Linux, this module depends on glibc. However, some distributions—like Alpine Linux—use musl libc instead, which is incompatible with this module. I'm updating the DEVELOPER_GUIDE documentation to help other developers choose the appropriate distro for Docker images and avoid the pitfalls I encountered.
See the issue I created in Github explaining this reasoning: opensearch-project#9329
Also the forum where I posted the kind of error you see when building with a Linux Distribution that is incompatible with glibc: https://forum.opensearch.org/t/docker-a-error-error-worker-exitted-unexpectedly-with-code-1-last-message-bundleid-embeddable-type-running/23214

Signed-off-by: Luis Beltrán <[email protected]>
Signed-off-by: Federico Silva <[email protected]>

* create histogram tests

Signed-off-by: Federico Silva <[email protected]>

* update callback, refactor tests

Signed-off-by: Federico Silva <[email protected]>

* fix hooks

Signed-off-by: Federico Silva <[email protected]>

* add comments to code, refactor preconditions

Signed-off-by: Federico Silva <[email protected]>

* update hooks to beforeEach and afterEach for CI/CD

Signed-off-by: Federico Silva <[email protected]>

* Changeset file for PR opensearch-project#9290 created/updated

Signed-off-by: Federico Silva <[email protected]>

* add todos

Signed-off-by: Federico Silva <[email protected]>

* add to package.json

Signed-off-by: Federico Silva <[email protected]>

* remove elements.js references

Signed-off-by: Federico Silva <[email protected]>

* [Documentation] Add alternative Docker Development Environment Setup documentation. (opensearch-project#9362)

* Add alternative Docker Development Environment Setup.

Signed-off-by: Argus Li <[email protected]>

* Changeset file for PR opensearch-project#9362 created/updated

* Use relative link

Signed-off-by: Argus Li <[email protected]>

* Address Suchit's comments.

Signed-off-by: Argus Li <[email protected]>

---------

Signed-off-by: Argus Li <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Signed-off-by: Federico Silva <[email protected]>

* [TESTID-77] Index Patterns Caching functionality for Discover (opensearch-project#9331)

* Create caching test.

Signed-off-by: Argus Li <[email protected]>

* Changeset file for PR opensearch-project#9331 created/updated

* Create caching test.

Signed-off-by: Argus Li <[email protected]>

* Changeset file for PR opensearch-project#9331 created/updated

* Refactor based on opensearch-project#9319

Signed-off-by: Argus Li <[email protected]>

* Update package.json

Signed-off-by: Suchit Sahoo <[email protected]>

* Remove element.js

Signed-off-by: Argus Li <[email protected]>

---------

Signed-off-by: Argus Li <[email protected]>
Signed-off-by: Suchit Sahoo <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Co-authored-by: Suchit Sahoo <[email protected]>
Co-authored-by: Anan Zhuang <[email protected]>
Signed-off-by: Federico Silva <[email protected]>

* [Discover] fix: Clean up sync URL subscription in Discover plugin topNav (opensearch-project#9316)

* [Discover] fix: Clean up sync URL subscription in Discover plugin topNav

Signed-off-by: Joey Liu <[email protected]>

* Changeset file for PR opensearch-project#9316 created/updated

* Update unit test

Signed-off-by: Joey Liu <[email protected]>

* Revert save modal change

Signed-off-by: Joey Liu <[email protected]>

---------

Signed-off-by: Joey Liu <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Signed-off-by: Federico Silva <[email protected]>

* skip permutation for SQL

Signed-off-by: Federico Silva <[email protected]>

* add todo

Signed-off-by: Federico Silva <[email protected]>

* [TESTID-64,80,UI] Add cypress test for autocomplete feature (opensearch-project#9322)

* [TESTID-64,80,UI] Add cypress test for autocomplete feature

Add tests related to autocomplete. This will close all the issues listed here:

https://github.com/opensearch-project/OpenSearch-Dashboards/issues/assigned/ananzh?q=is%3Aissue%20assignee%3Aananzh%20label%3A%22discover%20autocomplete%22%20

Signed-off-by: Anan <[email protected]>

* Changeset file for PR opensearch-project#9322 created/updated

---------

Signed-off-by: Anan <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Signed-off-by: Federico Silva <[email protected]>

* [Discover] chore: Update query editor loading UI (opensearch-project#9344)

* [Discover] chore: Update query editor loading UI

* Move progress bar position

Signed-off-by: Joey Liu <[email protected]>

* Update loading text font

Signed-off-by: Joey Liu <[email protected]>

* update unit test snapshot

Signed-off-by: Joey Liu <[email protected]>

* Update single line query editor

Signed-off-by: Joey Liu <[email protected]>

* Changeset file for PR opensearch-project#9344 created/updated

* pull doc update

Signed-off-by: Joey Liu <[email protected]>

---------

Signed-off-by: Joey Liu <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Signed-off-by: Federico Silva <[email protected]>

* feat(vis_type_vega): support reading time field (opensearch-project#9152)

* feat(vis_type_vega): support reading time field

Signed-off-by: Yulong Ruan <[email protected]>

* Changeset file for PR opensearch-project#9152 created/updated

* fix time format to use moment.utc

Signed-off-by: Yulong Ruan <[email protected]>

---------

Signed-off-by: Yulong Ruan <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Signed-off-by: Federico Silva <[email protected]>

* [TESTID-17] Add tests for query testing and advanced settings (opensearch-project#9384)

Issue Resolved:
opensearch-project#8934

Signed-off-by: Anan <[email protected]>
Signed-off-by: Federico Silva <[email protected]>

* add to package.json

Signed-off-by: Federico Silva <[email protected]>

---------

Signed-off-by: Anan <[email protected]>
Signed-off-by: Federico Silva <[email protected]>
Signed-off-by: Junqiu Lei <[email protected]>
Signed-off-by: Luis Beltrán <[email protected]>
Signed-off-by: Argus Li <[email protected]>
Signed-off-by: Suchit Sahoo <[email protected]>
Signed-off-by: Joey Liu <[email protected]>
Signed-off-by: Yulong Ruan <[email protected]>
Signed-off-by: Anan Zhuang <[email protected]>
Co-authored-by: Anan Zhuang <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Co-authored-by: Junqiu Lei <[email protected]>
Co-authored-by: Luis Beltrán <[email protected]>
Co-authored-by: Argus Li <[email protected]>
Co-authored-by: Suchit Sahoo <[email protected]>
Co-authored-by: Joey Liu <[email protected]>
Co-authored-by: Yulong Ruan <[email protected]>
  • Loading branch information
9 people authored and sumukhswamy committed Feb 18, 2025
1 parent 495d9b0 commit 916982d
Show file tree
Hide file tree
Showing 4 changed files with 279 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelogs/fragments/9290.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test:
- Add histogram interaction tests ([#9290](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/9290))
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import {
START_TIME,
END_TIME,
INDEX_PATTERN_WITH_TIME,
INDEX_WITH_TIME_1,
QueryLanguages,
DATASOURCE_NAME,
} from '../../../../../utils/apps/constants';
import { BASE_PATH, PATHS } from '../../../../../utils/constants';
import {
generateAllTestConfigurations,
getRandomizedWorkspaceName,
setDatePickerDatesAndSearchIfRelevant,
} from '../../../../../utils/apps/query_enhancements/shared';
import { generateHistogramTestConfigurations } from '../../../../../utils/apps/query_enhancements/histogram_interaction';
import { DatasetTypes } from '../../../../../utils/apps/query_enhancements/constants';
import { prepareTestSuite } from '../../../../../utils/helpers';

const workspace = getRandomizedWorkspaceName();

const runHistogramInteractionTests = () => {
describe('histogram interaction', { testIsolation: true }, () => {
beforeEach(() => {
// Load test data
cy.osd.setupTestData(
PATHS.SECONDARY_ENGINE,
['cypress/fixtures/query_enhancements/data_logs_1/data_logs_small_time_1.mapping.json'],
['cypress/fixtures/query_enhancements/data_logs_1/data_logs_small_time_1.data.ndjson']
);

// Add data source
cy.osd.addDataSource({
name: DATASOURCE_NAME,
url: `${PATHS.SECONDARY_ENGINE}`,
authType: 'no_auth',
});
// Create workspace
cy.deleteWorkspaceByName(workspace);
cy.visit('/app/home');
cy.osd.createInitialWorkspaceWithDataSource(DATASOURCE_NAME, workspace);
cy.createWorkspaceIndexPatterns({
workspaceName: workspace,
indexPattern: INDEX_PATTERN_WITH_TIME.replace('*', ''),
timefieldName: 'timestamp',
indexPatternHasTimefield: true,
dataSource: DATASOURCE_NAME,
isEnhancement: true,
});
cy.navigateToWorkSpaceSpecificPage({
url: BASE_PATH,
workspaceName: workspace,
page: 'discover',
isEnhancement: true,
});
});

afterEach(() => {
cy.deleteWorkspaceByName(workspace);
cy.osd.deleteDataSourceByName(DATASOURCE_NAME);
// TODO: Modify deleteIndex to handle an array of index and remove hard code
cy.osd.deleteIndex(INDEX_WITH_TIME_1);
});

generateAllTestConfigurations(generateHistogramTestConfigurations).forEach((config) => {
it(`check histogram visibility for ${config.testName}`, () => {
cy.setDataset(config.dataset, DATASOURCE_NAME, config.datasetType);
cy.setQueryLanguage(config.language);
setDatePickerDatesAndSearchIfRelevant(config.language);
if (config.isHistogramVisible) {
cy.getElementByTestId('dscChartChartheader').should('be.visible');
cy.getElementByTestId('discoverChart').should('be.visible');
} else {
cy.getElementByTestId('dscChartChartheader').should('not.exist');
cy.getElementByTestId('discoverChart').should('not.exist');
}
// check interval selection persistence across language changes.
// Only need to check for INDEX_PATTERNS because INDEXES
// only supports SQL & PPL, and only one of the two supports histogram.
if (config.isHistogramVisible && config.datasetType === DatasetTypes.INDEX_PATTERN.name) {
cy.getElementByTestId('discoverIntervalSelect').select('Week');
cy.getElementByTestId('discoverIntervalDateRange').contains(
`${START_TIME} - ${END_TIME} per`
);
for (const language of DatasetTypes.INDEX_PATTERN.supportedLanguages) {
if (language.name === QueryLanguages.SQL.name) continue;
cy.setQueryLanguage(language.name);
cy.wait(1000); // wait a bit to ensure data is loaded
if (language.supports.histogram) {
cy.getElementByTestId('discoverIntervalSelect').select('Week');
cy.getElementByTestId('discoverIntervalDateRange').contains(
`${START_TIME} - ${END_TIME} per`
);
}
}
}
});

it(`check the Auto interval value for ${config.testName}`, () => {
if (!config.isHistogramVisible) return;
cy.setDataset(config.dataset, DATASOURCE_NAME, config.datasetType);
cy.setQueryLanguage(config.language);
setDatePickerDatesAndSearchIfRelevant(config.language);
const intervals = ['auto', 'ms', 's', 'm', 'h', 'd', 'w', 'M', 'y'];
cy.getElementByTestId('discoverIntervalSelect').should('have.value', intervals[0]);
intervals.forEach((interval) => {
cy.getElementByTestId('discoverIntervalSelect').select(interval);
cy.wait(1000); // adding a wait here to ensure the data has been updated
config.langPermutation.forEach((lang) => {
if (lang === QueryLanguages.SQL.name) return; // SQL doesn't have a histogram
cy.setQueryLanguage(lang);
cy.getElementByTestId('discoverIntervalSelect').should('have.value', interval);
cy.getElementByTestId('discoverIntervalDateRange').should('be.visible');
});
});
// TODO: check histogram visualization
// Currently it's not possible to check anything INSIDE the histogram with Cypress
});

it(`check the time range selection for ${config.testName}`, () => {
const TIME = '13:00:00.000';
const START_DATE = `Jan 1, 2021 @ ${TIME}`;
const END_DATE = `Oct 1, 2021 @ ${TIME}`;
const checkIntervals = () => {
cy.getElementByTestId('discoverIntervalDateRange')
.should('be.visible')
.and('have.text', `${START_DATE} - ${END_DATE} per`);
cy.getElementByTestId('docTableExpandToggleColumn')
.eq(0)
.find('button')
.click({ force: true });
cy.getElementByTestId('tableDocViewRow-timestamp-value').then(($timestamp) => {
const timestampTxt = $timestamp.text();
const parsedDate = timestampTxt.split('@');
const date = parsedDate[0].trim();
const actualTime = parsedDate[1].trim();
const parsedExpectedTime = new Date(`1970-01-01T${TIME}`);
const parsedActualTime = new Date(`1970-01-01T${actualTime}`);
expect(timestampTxt).to.contain(date);
expect(parsedActualTime <= parsedExpectedTime).to.equal(true);
});
cy.getElementByTestId('docTableExpandToggleColumn')
.eq(0)
.find('button')
.click({ force: true }); // reset state
};
cy.setDataset(config.dataset, DATASOURCE_NAME, config.datasetType);
cy.setQueryLanguage(config.language);
if (config.isHistogramVisible) {
// TODO: related bug
// https://github.com/opensearch-project/OpenSearch-Dashboards/issues/9294
if (config.language !== 'PPL') {
// remove after the bug is fixed
cy.setTopNavDate(START_DATE, END_DATE);
cy.wait(1000); // adding a wait here to ensure the data has been updated
checkIntervals();
cy.getElementByTestId('discoverQueryHits').then(($hits) => {
const hitsTxt = $hits.text();
const langs = config.langPermutation;
langs.splice(langs.indexOf('PPL'), 1); // TODO: remove after the bug is fixed
langs.forEach((lang) => {
if (lang === QueryLanguages.SQL.name) return; // SQL doesn't have a histogram
cy.setQueryLanguage(lang);
cy.wait(1000); // adding a wait here to ensure the data has been updated
cy.getElementByTestId('discoverQueryHits').should('have.text', hitsTxt);
checkIntervals();
});
});
}
} else {
cy.getElementByTestId('discoverIntervalSelect').should('not.exist');
}
});

it(`check collapse/expand functionality and state persistence for ${config.testName}`, () => {
if (!config.isHistogramVisible) return;
cy.setDataset(config.dataset, DATASOURCE_NAME, config.datasetType);
cy.setQueryLanguage(config.language);
setDatePickerDatesAndSearchIfRelevant(config.language);

cy.getElementByTestId('dscChartChartheader').should('be.visible');
cy.getElementByTestId('discoverChart').should('be.visible');
cy.getElementByTestId('histogramCollapseBtn').should('be.visible').click();
cy.getElementByTestId('dscChartChartheader').should('be.visible');
cy.getElementByTestId('discoverChart').should('not.exist');

const permutation = {
collapse: 'not.exist',
expand: 'be.visible',
};
Object.keys(permutation).forEach((perm) => {
config.langPermutation.forEach((lang) => {
if (lang === QueryLanguages.SQL.name) return; // SQL doesn't have a histogram
cy.setQueryLanguage(lang);
cy.getElementByTestId('dscChartChartheader').should('be.visible');
cy.getElementByTestId('discoverChart').should(permutation[perm]);
// TODO: Uncomment after reload bug is fixed
//cy.reload(); // should not remove cache for the test to be meaningful
//cy.getElementByTestId('discoverChart').should(permutation[perm]);
//cy.getElementByTestId('histogramCollapseBtn').should(permutation[perm]);
});
if (perm === 'collapse') {
// start again from the beginning and expand again
cy.setQueryLanguage(config.language);
cy.getElementByTestId('histogramCollapseBtn').should('be.visible').click();
}
});
});
});
});
};

prepareTestSuite('Histogram interaction', runHistogramInteractionTests);
59 changes: 59 additions & 0 deletions cypress/utils/apps/query_enhancements/histogram_interaction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { DatasetTypes, QueryLanguages } from './constants';

export const HistogramDatasetTypes = {
INDEX_PATTERN: {
name: 'INDEX_PATTERN',
supportedLanguages: [QueryLanguages.DQL, QueryLanguages.SQL, QueryLanguages.PPL],
},
INDEXES: {
name: 'INDEXES',
supportedLanguages: [QueryLanguages.PPL],
},
};

/**
* The configurations needed for field display filtering tests
* @typedef {Object} HistogramTestConfig
* @property {string} dataset - the dataset name to use
* @property {QueryEnhancementDataset} datasetType - the type of dataset
* @property {QueryEnhancementLanguage} language - the name of query language as it appears in the dashboard app
* @property {string} testName - the phrase to add to the test case's title
*/

/**
* Returns the SavedSearchTestConfig for the provided dataset, datasetType, and language
* @param {string} dataset - the dataset name
* @param {QueryEnhancementDataset} datasetType - the type of the dataset
* @param {QueryEnhancementLanguageData} language - the relevant data for the query language to use
* @returns {HistogramTestConfig}
*/
export const generateHistogramTestConfigurations = (dataset, datasetType, language) => {
const isHistogramVisible = language.name === QueryLanguages.SQL.name ? false : true;
let langPermutation;
if (datasetType === DatasetTypes.INDEX_PATTERN.name) {
// access the supportedLanguages object and converting it into an array
// then iterate over each one of them and create a new array with just the names of the languages
// the [1] there is because Object.entries places the object we want in the second place on the array
langPermutation = Object.entries(HistogramDatasetTypes.INDEX_PATTERN.supportedLanguages).map(
(lang) => lang[1].name
);
langPermutation.splice(langPermutation.indexOf(language.name), 1); // remove current lang to iterate over the other two only
} else {
langPermutation = Object.entries(HistogramDatasetTypes.INDEXES.supportedLanguages).map(
(lang) => lang[1].name
);
}
return {
dataset,
datasetType: HistogramDatasetTypes[datasetType].name,
language: language.name,
langPermutation: langPermutation,
isHistogramVisible: isHistogramVisible,
testName: `dataset: ${datasetType} and language: ${language.name}`,
};
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"osd:ciGroup11": "echo \"cypress/integration/dashboard_sanity_test.spec.ts\"",
"osd:ciGroup12": "BASE_PATH='cypress/integration/core_opensearch_dashboards/opensearch_dashboards/apps/query_enhancements' && echo \"$BASE_PATH/language_specific_display.spec.js,$BASE_PATH/time_range_selection.spec.js,$BASE_PATH/saved_queries.spec.js,$BASE_PATH/saved_search_in_dashboards.spec.js\"",
"osd:ciGroup13": "BASE_PATH='cypress/integration/core_opensearch_dashboards/opensearch_dashboards/apps/query_enhancements' && echo \"$BASE_PATH/caching.spec.js,$BASE_PATH/field_display_filtering.spec.js,$BASE_PATH/inspect.spec.js,$BASE_PATH/shared_links.spec.js,$BASE_PATH/table.spec.js\"",
"osd:ciGroup14": "BASE_PATH='cypress/integration/core_opensearch_dashboards/opensearch_dashboards/apps/query_enhancements' && echo \"$BASE_PATH/s3_dataset.spec.js,$BASE_PATH/advanced_settings.spec.js,$BASE_PATH/queries_more.spec.js\"",
"osd:ciGroup14": "BASE_PATH='cypress/integration/core_opensearch_dashboards/opensearch_dashboards/apps/query_enhancements' && echo \"$BASE_PATH/s3_dataset.spec.js,$BASE_PATH/advanced_settings.spec.js,$BASE_PATH/queries_more.spec.js,histogram_interaction.spec.js\"",
"osd:ciGroup15": "BASE_PATH='cypress/integration/core_opensearch_dashboards/opensearch_dashboards/apps/query_enhancements' && echo \"$BASE_PATH/autocomplete_switch.spec.js,$BASE_PATH/autocomplete_ui.spec.js,$BASE_PATH/autocomplete_query.spec.js,$BASE_PATH/sidebar.spec.js,$BASE_PATH/recent_queries.spec.js\"",
"generate:opensearchsqlantlr": "./node_modules/antlr4ng-cli/index.js -Dlanguage=TypeScript -o ./src/plugins/data/public/antlr/opensearch_sql/.generated -visitor -no-listener -Xexact-output-dir ./src/plugins/data/public/antlr/opensearch_sql/grammar/OpenSearchSQLLexer.g4 ./src/plugins/data/public/antlr/opensearch_sql/grammar/OpenSearchSQLParser.g4",
"generate:opensearchpplantlr": "./node_modules/antlr4ng-cli/index.js -Dlanguage=TypeScript -o ./src/plugins/data/public/antlr/opensearch_ppl/.generated -visitor -no-listener -Xexact-output-dir ./src/plugins/data/public/antlr/opensearch_ppl/grammar/OpenSearchPPLLexer.g4 ./src/plugins/data/public/antlr/opensearch_ppl/grammar/OpenSearchPPLParser.g4"
Expand Down

0 comments on commit 916982d

Please sign in to comment.