Skip to content

Commit

Permalink
Merge branch 'main' into feature/hide-query-assist-for-unsupported-type
Browse files Browse the repository at this point in the history
  • Loading branch information
AMoo-Miki authored Jan 9, 2025
2 parents 46cec9d + 82689bb commit 7dd4509
Show file tree
Hide file tree
Showing 87 changed files with 4,739 additions and 1,691 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/8906.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feat:
- Refactor the bulk_get handler in permission wrapper when item has permission error ([#8906](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8906))
2 changes: 2 additions & 0 deletions changelogs/fragments/8907.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feat:
- Add privacy levels to the workspace ([#8907](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8907))
2 changes: 2 additions & 0 deletions changelogs/fragments/8931.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- DQL autocomplete better parsing and fixes ([#8931](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8931))
2 changes: 2 additions & 0 deletions changelogs/fragments/8999.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feat:
- Add two-steps loading for associating data sources ([#8999](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8999))
2 changes: 2 additions & 0 deletions changelogs/fragments/9057.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
refactor:
- Update data source details tabs to use small buttons ([#9057](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/9057))
2 changes: 2 additions & 0 deletions changelogs/fragments/9112.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test:
- Add tests for saving search and loading it ([#9112](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/9112))
2 changes: 2 additions & 0 deletions changelogs/fragments/9153.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- 0 rendered in discover when there are no results ([#9153](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/9153))
2 changes: 2 additions & 0 deletions changelogs/fragments/9164.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feat:
- Support to dissociate data connection object since DSM list has supported to display ([#9164](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/9164))
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
START_TIME,
END_TIME,
} from '../../../../../utils/apps/constants';
import { BASE_PATH, SECONDARY_ENGINE } from '../../../../../utils/constants';
import { SECONDARY_ENGINE } from '../../../../../utils/constants';

const randomString = Math.random().toString(36).substring(7);
const workspace = `${WORKSPACE_NAME}-${randomString}`;
Expand Down Expand Up @@ -38,6 +38,11 @@ describe('dataset selector', { scrollBehavior: false }, () => {
cy.deleteWorkspaceByName(`${workspace}`);
cy.visit('/app/home');
cy.createInitialWorkspaceWithDataSource(`${DATASOURCE_NAME}`, `${workspace}`);
cy.navigateToWorkSpaceSpecificPage({
workspaceName: workspace,
page: 'discover',
isEnhancement: true,
});
});

afterEach(() => {
Expand All @@ -46,21 +51,7 @@ describe('dataset selector', { scrollBehavior: false }, () => {

describe('select indices', () => {
it('with SQL as default language', function () {
cy.getElementByTestId(`datasetSelectorButton`).click();
cy.getElementByTestId(`datasetSelectorAdvancedButton`).click();
cy.get(`[title="Indexes"]`).click();
cy.get(`[title=${DATASOURCE_NAME}]`).click();
cy.get(`[title="data_logs_small_time_1"]`).click(); // Updated to match loaded data
cy.getElementByTestId('datasetSelectorNext').click();

cy.get(`[class="euiModalHeader__title"]`).should('contain', 'Step 2: Configure data');

// Select SQL
cy.getElementByTestId('advancedSelectorLanguageSelect').select('OpenSearch SQL');
cy.getElementByTestId(`advancedSelectorTimeFieldSelect`).select('timestamp');
cy.getElementByTestId('advancedSelectorConfirmButton').click();

cy.waitForLoader(true);
cy.setIndexAsDataset('data_logs_small_time_1', DATASOURCE_NAME, 'OpenSearch SQL');

// SQL should already be selected
cy.getElementByTestId('queryEditorLanguageSelector').should('contain', 'OpenSearch SQL');
Expand All @@ -78,22 +69,7 @@ describe('dataset selector', { scrollBehavior: false }, () => {
});

it('with PPL as default language', function () {
cy.getElementByTestId(`datasetSelectorButton`).click();
cy.getElementByTestId(`datasetSelectorAdvancedButton`).click();
cy.get(`[title="Indexes"]`).click();
cy.get(`[title=${DATASOURCE_NAME}]`).click();
cy.get(`[title="data_logs_small_time_1"]`).click(); // Updated to match loaded data
cy.getElementByTestId('datasetSelectorNext').click();

cy.get(`[class="euiModalHeader__title"]`).should('contain', 'Step 2: Configure data');

// Select PPL
cy.getElementByTestId('advancedSelectorLanguageSelect').select('PPL');

cy.getElementByTestId(`advancedSelectorTimeFieldSelect`).select('timestamp');
cy.getElementByTestId('advancedSelectorConfirmButton').click();

cy.waitForLoader(true);
cy.setIndexAsDataset('data_logs_small_time_1', DATASOURCE_NAME, 'PPL');

// PPL should already be selected
cy.getElementByTestId('queryEditorLanguageSelector').should('contain', 'PPL');
Expand All @@ -119,22 +95,20 @@ describe('dataset selector', { scrollBehavior: false }, () => {
it('create index pattern and select it', function () {
// Create and select index pattern for data_logs_small_time_1*
cy.createWorkspaceIndexPatterns({
url: `${BASE_PATH}`,
workspaceName: `${workspace}`,
workspaceName: workspace,
indexPattern: 'data_logs_small_time_1',
timefieldName: 'timestamp',
indexPatternHasTimefield: true,
dataSource: DATASOURCE_NAME,
isEnhancement: true,
});

cy.navigateToWorkSpaceHomePage(`${BASE_PATH}`, `${workspace}`);
cy.navigateToWorkSpaceHomePage(workspace);

cy.waitForLoader(true);
cy.getElementByTestId(`datasetSelectorButton`).click();
cy.getElementByTestId(`datasetSelectorAdvancedButton`).click();
cy.get(`[title="Index Patterns"]`).click();
cy.get(`[title="${DATASOURCE_NAME}::data_logs_small_time_1*"]`).should('exist');
cy.setIndexPatternAsDataset('data_logs_small_time_1*', DATASOURCE_NAME);
// setting OpenSearch SQL as the code following it does not work if this test is isolated
cy.setQueryLanguage('OpenSearch SQL');

cy.waitForLoader(true);
cy.waitForSearch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
START_TIME,
END_TIME,
} from '../../../../../utils/apps/constants';
import { BASE_PATH, SECONDARY_ENGINE } from '../../../../../utils/constants';
import { SECONDARY_ENGINE } from '../../../../../utils/constants';

const randomString = Math.random().toString(36).substring(7);
const workspace = `${WORKSPACE_NAME}-${randomString}`;
Expand Down Expand Up @@ -37,22 +37,24 @@ describe('query enhancement queries', { scrollBehavior: false }, () => {

// Create and select index pattern for data_logs_small_time_1*
cy.createWorkspaceIndexPatterns({
url: `${BASE_PATH}`,
workspaceName: `${workspace}`,
workspaceName: workspace,
indexPattern: 'data_logs_small_time_1',
timefieldName: 'timestamp',
indexPatternHasTimefield: true,
dataSource: DATASOURCE_NAME,
isEnhancement: true,
});

// Go to workspace home
cy.navigateToWorkSpaceHomePage(`${BASE_PATH}`, `${workspace}`);
cy.waitForLoader(true);
// Go to discover page
cy.navigateToWorkSpaceSpecificPage({
workspaceName: workspace,
page: 'discover',
isEnhancement: true,
});
});

after(() => {
cy.deleteWorkspaceByName(`${workspace}`);
cy.deleteWorkspaceByName(workspace);
cy.deleteDataSourceByName(`${DATASOURCE_NAME}`);
cy.deleteIndex('data_logs_small_time_1');
});
Expand All @@ -63,7 +65,7 @@ describe('query enhancement queries', { scrollBehavior: false }, () => {
cy.setTopNavDate(START_TIME, END_TIME);

const query = `_id:1`;
cy.setSingleLineQueryEditor(query);
cy.setQueryEditor(query);
cy.waitForLoader(true);
cy.waitForSearch();
cy.verifyHitCount(1);
Expand All @@ -78,7 +80,7 @@ describe('query enhancement queries', { scrollBehavior: false }, () => {
cy.setTopNavDate(START_TIME, END_TIME);

const query = `_id:1`;
cy.setSingleLineQueryEditor(query);
cy.setQueryEditor(query);
cy.waitForLoader(true);
cy.waitForSearch();
cy.verifyHitCount(1);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import {
INDEX_PATTERN_WITH_TIME,
INDEX_WITH_TIME_1,
INDEX_WITH_TIME_2,
QueryLanguages,
SECONDARY_ENGINE,
} from '../../../../../utils/constants';
import {
workspaceName,
datasourceName,
generateAllTestConfigurations,
setDatePickerDatesAndSearchIfRelevant,
setSearchConfigurations,
verifyDiscoverPageState,
verifySavedSearchInAssetsPage,
postRequestSaveSearch,
} from './utils/saved_search';

export const runSavedSearchTests = () => {
describe('saved search', () => {
beforeEach(() => {
// Load test data
cy.setupTestData(
SECONDARY_ENGINE.url,
[
`cypress/fixtures/query_enhancements/data-logs-1/${INDEX_WITH_TIME_1}.mapping.json`,
`cypress/fixtures/query_enhancements/data-logs-2/${INDEX_WITH_TIME_2}.mapping.json`,
],
[
`cypress/fixtures/query_enhancements/data-logs-1/${INDEX_WITH_TIME_1}.data.ndjson`,
`cypress/fixtures/query_enhancements/data-logs-2/${INDEX_WITH_TIME_2}.data.ndjson`,
]
);
// Add data source
cy.addDataSource({
name: datasourceName,
url: SECONDARY_ENGINE.url,
authType: 'no_auth',
});

// Create workspace
cy.deleteWorkspaceByName(workspaceName);
cy.visit('/app/home');
cy.createInitialWorkspaceWithDataSource(datasourceName, workspaceName);
cy.createWorkspaceIndexPatterns({
workspaceName: workspaceName,
indexPattern: INDEX_PATTERN_WITH_TIME.replace('*', ''),
timefieldName: 'timestamp',
dataSource: datasourceName,
isEnhancement: true,
});
});

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

generateAllTestConfigurations().forEach((config) => {
it(`should successfully create a saved search for ${config.testName}`, () => {
cy.navigateToWorkSpaceSpecificPage({
workspaceName,
page: 'discover',
isEnhancement: true,
});

cy.setDataset(config.dataset, datasourceName, config.datasetType);

cy.setQueryLanguage(config.language);
setDatePickerDatesAndSearchIfRelevant(config.language);

setSearchConfigurations(config);
verifyDiscoverPageState(config);
cy.saveSearch(config.saveName);

// There is a small chance where if we go to assets page,
// the saved search does not appear. So adding this wait
cy.wait(2000);

verifySavedSearchInAssetsPage(config);
});

// We are starting from various languages
// to guard against: https://github.com/opensearch-project/OpenSearch-Dashboards/issues/9078
Object.values(QueryLanguages)
.map((queryLanguage) => queryLanguage.name)
.forEach((startingLanguage) => {
// TODO: Remove this line once bugs are fixed
// https://github.com/opensearch-project/OpenSearch-Dashboards/issues/9078
if (startingLanguage !== config.language) return;

it(`should successfully load a saved search for ${config.testName} starting from ${startingLanguage}`, () => {
postRequestSaveSearch(config);

cy.navigateToWorkSpaceSpecificPage({
workspaceName,
page: 'discover',
isEnhancement: true,
});
cy.getElementByTestId('discoverNewButton').click();

// Intentionally setting INDEX_PATTERN dataset here so that
// we have access to all four languages that INDEX_PATTERN allows.
// This means that we are only testing loading a saved search
// starting from an INDEX_PATTERN dataset, but I think testing where the
// start is a permutation of other dataset is overkill
cy.setIndexPatternAsDataset(INDEX_PATTERN_WITH_TIME, datasourceName);

cy.setQueryLanguage(startingLanguage);
cy.loadSaveSearch(config.saveName, false);
setDatePickerDatesAndSearchIfRelevant(config.language);
verifyDiscoverPageState(config);
});
});
});
});
};

runSavedSearchTests();
Loading

0 comments on commit 7dd4509

Please sign in to comment.