-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* add reload to PPL Signed-off-by: Qingyang(Abby) Hu <[email protected]> * Add initial query enhancement tests Signed-off-by: Qingyang(Abby) Hu <[email protected]> * Add ciGroup10 Signed-off-by: Qingyang(Abby) Hu <[email protected]> * modify queries test Signed-off-by: Qingyang(Abby) Hu <[email protected]> * fix tests Signed-off-by: Qingyang(Abby) Hu <[email protected]> * fix one more test Signed-off-by: Qingyang(Abby) Hu <[email protected]> * address comments Signed-off-by: Qingyang(Abby) Hu <[email protected]> * remove deleteAll Signed-off-by: Qingyang(Abby) Hu <[email protected]> * delete data source connection Signed-off-by: Qingyang(Abby) Hu <[email protected]> --------- Signed-off-by: Qingyang(Abby) Hu <[email protected]> (cherry picked from commit c3abd79) Co-authored-by: Qingyang(Abby) Hu <[email protected]>
- Loading branch information
1 parent
cfbadee
commit 9faba32
Showing
10 changed files
with
529 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
cypress/fixtures/dashboard/opensearch_dashboards/query_enhancement/data.json.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"type": "doc", | ||
"value": { | ||
"id": "3", | ||
"index": "timestamp-nanos", | ||
"source": { | ||
"timestamp": "2019-01-01T12:10:30.123456789Z" | ||
}, | ||
"type": "_doc" | ||
} | ||
} | ||
|
||
{ | ||
"type": "doc", | ||
"value": { | ||
"id": "4", | ||
"index": "timestamp-nanos", | ||
"source": { | ||
"timestamp": "2019-01-01T12:10:30.123498765Z" | ||
}, | ||
"type": "_doc" | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
...xtures/dashboard/opensearch_dashboards/query_enhancement/data_with_index_pattern.json.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
{ | ||
"type": "doc", | ||
"value": { | ||
"id": "index-pattern:timestamp-*", | ||
"index": ".kibana", | ||
"source": { | ||
"index-pattern": { | ||
"fields": "[{\"name\":\"_id\",\"type\":\"string\",\"esTypes\":[\"_id\"],\"count\":1,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"_index\",\"type\":\"string\",\"esTypes\":[\"_index\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"_score\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"_source\",\"type\":\"_source\",\"esTypes\":[\"_source\"],\"count\":0,\"scripted\":false,\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"_type\",\"type\":\"string\",\"esTypes\":[\"_type\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"timestamp\",\"type\":\"date\",\"esTypes\":[\"date\",\"date_nanos\"],\"count\":2,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true}]", | ||
"timeFieldName": "timestamp", | ||
"title": "timestamp-*", | ||
"fieldFormatMap": "{\"timestamp\":{\"id\":\"date_nanos\"}}" | ||
}, | ||
"type": "index-pattern" | ||
}, | ||
"type": "_doc" | ||
} | ||
} | ||
|
||
{ | ||
"type": "doc", | ||
"value": { | ||
"id": "2", | ||
"index": "timestamp-millis", | ||
"source": { | ||
"timestamp": "2019-01-01T12:10:30.124Z" | ||
}, | ||
"type": "_doc" | ||
} | ||
} | ||
|
||
{ | ||
"type": "doc", | ||
"value": { | ||
"id": "1", | ||
"index": "timestamp-millis", | ||
"source": { | ||
"timestamp": "2019-01-01T12:10:30.123Z" | ||
}, | ||
"type": "_doc" | ||
} | ||
} | ||
|
||
{ | ||
"type": "doc", | ||
"value": { | ||
"id": "3", | ||
"index": "timestamp-nanos", | ||
"source": { | ||
"timestamp": "2019-01-01T12:10:30.123456789Z" | ||
}, | ||
"type": "_doc" | ||
} | ||
} | ||
|
||
{ | ||
"type": "doc", | ||
"value": { | ||
"id": "4", | ||
"index": "timestamp-nanos", | ||
"source": { | ||
"timestamp": "2019-01-02T12:10:30.123498765Z" | ||
}, | ||
"type": "_doc" | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
cypress/fixtures/dashboard/opensearch_dashboards/query_enhancement/mappings.json.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"type": "index", | ||
"value": { | ||
"aliases": { | ||
}, | ||
"index": "timestamp-millis", | ||
"mappings": { | ||
"properties": { | ||
"timestamp": { | ||
"type": "date" | ||
} | ||
} | ||
}, | ||
"settings": { | ||
"index": { | ||
"number_of_replicas": "1", | ||
"number_of_shards": "1", | ||
"codec": "best_compression" | ||
} | ||
} | ||
} | ||
} | ||
|
||
{ | ||
"type": "index", | ||
"value": { | ||
"aliases": { | ||
}, | ||
"index": "timestamp-nanos", | ||
"mappings": { | ||
"properties": { | ||
"timestamp": { | ||
"type": "date_nanos" | ||
} | ||
} | ||
}, | ||
"settings": { | ||
"index": { | ||
"number_of_replicas": "1", | ||
"number_of_shards": "1", | ||
"codec": "best_compression" | ||
} | ||
} | ||
} | ||
} |
213 changes: 213 additions & 0 deletions
213
...nsearch-dashboards/opensearch-dashboards/apps/query_enhancement/dataset_navigator.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,213 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
import { | ||
MiscUtils, | ||
TestFixtureHandler, | ||
} from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; | ||
import { CURRENT_TENANT } from '../../../../../utils/commands'; | ||
import { clusterName, clusterConnection } from '../../../../../utils/constants'; | ||
|
||
const miscUtils = new MiscUtils(cy); | ||
const testFixtureHandler = new TestFixtureHandler( | ||
cy, | ||
Cypress.env('openSearchUrl') | ||
); | ||
|
||
const indexSet = [ | ||
'logstash-2015.09.22', | ||
'logstash-2015.09.21', | ||
'logstash-2015.09.20', | ||
]; | ||
|
||
describe('dataset navigator', { scrollBehavior: false }, () => { | ||
before(() => { | ||
CURRENT_TENANT.newTenant = 'global'; | ||
cy.fleshTenantSettings(); | ||
}); | ||
|
||
describe('empty state', () => { | ||
it('no index pattern', function () { | ||
// Go to the Discover page | ||
miscUtils.visitPage( | ||
`app/data-explorer/discover#/?_g=(filters:!(),time:(from:'2015-09-19T13:31:44.000Z',to:'2015-09-24T01:31:44.000Z'))` | ||
); | ||
|
||
cy.waitForLoaderNewHeader(); | ||
cy.getElementByTestId('discoverNoIndexPatterns'); | ||
}); | ||
}); | ||
|
||
describe('select indices', () => { | ||
before(() => { | ||
testFixtureHandler.importJSONMapping( | ||
'cypress/fixtures/dashboard/opensearch_dashboards/query_enhancement/mappings.json.txt' | ||
); | ||
|
||
testFixtureHandler.importJSONDoc( | ||
'cypress/fixtures/dashboard/opensearch_dashboards/query_enhancement/data.json.txt' | ||
); | ||
|
||
// Since default cluster is removed, need to create a data source connection | ||
miscUtils.visitPage( | ||
'app/management/opensearch-dashboards/dataSources/create' | ||
); | ||
cy.intercept('POST', '/api/saved_objects/data-source').as( | ||
'createDataSourceRequest' | ||
); | ||
cy.getElementByTestId(`datasource_card_opensearch`).click(); | ||
cy.get('[name="dataSourceTitle"]').type(clusterName); | ||
cy.get('[name="endpoint"]').type(clusterConnection); | ||
cy.getElementByTestId('createDataSourceFormAuthTypeSelect').click(); | ||
cy.get(`button[id="no_auth"]`).click(); | ||
|
||
cy.getElementByTestId('createDataSourceButton').click(); | ||
cy.wait('@createDataSourceRequest').then((interception) => { | ||
expect(interception.response.statusCode).to.equal(200); | ||
}); | ||
cy.location('pathname', { timeout: 6000 }).should( | ||
'include', | ||
'app/management/opensearch-dashboards/dataSources' | ||
); | ||
|
||
// Go to the Discover page | ||
miscUtils.visitPage(`app/data-explorer/discover#/`); | ||
|
||
cy.waitForLoaderNewHeader(); | ||
}); | ||
|
||
it('with SQL as default language', function () { | ||
cy.getElementByTestId(`datasetSelectorButton`).click(); | ||
cy.getElementByTestId(`datasetSelectorAdvancedButton`).click(); | ||
cy.get(`[title="Indexes"]`).click(); | ||
cy.get(`[title=${clusterName}]`).click(); | ||
cy.get(`[title="timestamp-nanos"]`).click(); | ||
cy.getElementByTestId('datasetSelectorNext').click(); | ||
|
||
cy.get(`[class="euiModalHeader__title"]`).should( | ||
'contain', | ||
'Step 2: Configure data' | ||
); | ||
// should have two options: SQL and PPL | ||
cy.getElementByTestId('advancedSelectorLanguageSelect') | ||
.get('option') | ||
.should('have.length', 2); | ||
|
||
//select SQL | ||
cy.getElementByTestId('advancedSelectorLanguageSelect').select( | ||
'OpenSearch SQL' | ||
); | ||
cy.getElementByTestId('advancedSelectorConfirmButton').click(); | ||
|
||
cy.waitForLoaderNewHeader(); | ||
|
||
// SQL should already be selected | ||
cy.getElementByTestId('queryEditorLanguageSelector').should( | ||
'contain', | ||
'OpenSearch SQL' | ||
); | ||
cy.waitForLoaderNewHeader(); | ||
|
||
// SQL query should be executed and sending back result | ||
cy.get(`[data-test-subj="queryResultCompleteMsg"]`).should('be.visible'); | ||
|
||
// Switch language to PPL | ||
cy.setQueryLanguage('PPL'); | ||
cy.waitForLoaderNewHeader(); | ||
cy.get(`[data-test-subj="queryResultCompleteMsg"]`).should('be.visible'); | ||
}); | ||
|
||
it('with PPL as default language', function () { | ||
cy.getElementByTestId(`datasetSelectorButton`).click(); | ||
cy.getElementByTestId(`datasetSelectorAdvancedButton`).click(); | ||
cy.get(`[title="Indexes"]`).click(); | ||
cy.get(`[title=${clusterName}]`).click(); | ||
cy.get(`[title="timestamp-nanos"]`).click(); | ||
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.waitForLoaderNewHeader(); | ||
|
||
// PPL should already be selected | ||
cy.getElementByTestId('queryEditorLanguageSelector').should( | ||
'contain', | ||
'PPL' | ||
); | ||
|
||
const fromTime = 'Sep 19, 2018 @ 00:00:00.000'; | ||
const toTime = 'Sep 21, 2019 @ 00:00:00.000'; | ||
cy.setTopNavDate(fromTime, toTime); | ||
|
||
cy.waitForLoaderNewHeader(); | ||
|
||
// Query should finish running with timestamp and finish time in the footer | ||
cy.getElementByTestId('queryResultCompleteMsg').should('be.visible'); | ||
cy.getElementByTestId('queryEditorFooterTimestamp').should( | ||
'contain', | ||
'timestamp' | ||
); | ||
|
||
// Switch language to SQL | ||
cy.setQueryLanguage('OpenSearch SQL'); | ||
|
||
cy.waitForLoaderNewHeader(); | ||
cy.getElementByTestId('queryResultCompleteMsg').should('be.visible'); | ||
cy.getElementByTestId('queryEditorFooterTimestamp').should( | ||
'contain', | ||
'timestamp' | ||
); | ||
}); | ||
}); | ||
|
||
describe('index pattern', () => { | ||
it('create index pattern and select it', function () { | ||
// import logstash functional | ||
testFixtureHandler.importJSONDocIfNeeded( | ||
indexSet, | ||
'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/logstash/logstash.mappings.json.txt', | ||
'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/logstash/logstash.json.txt' | ||
); | ||
testFixtureHandler.importJSONMapping( | ||
'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/discover/discover.mappings.json.txt' | ||
); | ||
|
||
testFixtureHandler.importJSONDoc( | ||
'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/discover/discover.json.txt' | ||
); | ||
|
||
// Go to the Discover page | ||
miscUtils.visitPage( | ||
`app/data-explorer/discover#/?_g=(filters:!(),time:(from:'2015-09-19T13:31:44.000Z',to:'2015-09-24T01:31:44.000Z'))` | ||
); | ||
|
||
cy.get(`[class~="datasetSelector__button"]`).click(); | ||
cy.getElementByTestId(`datasetOption-logstash-*`).click(); | ||
|
||
cy.waitForLoaderNewHeader(); | ||
cy.waitForSearch(); | ||
cy.verifyHitCount('14,004'); | ||
}); | ||
}); | ||
|
||
after(() => { | ||
cy.deleteIndex('timestamp-nanos'); | ||
// delete the data source connection | ||
miscUtils.visitPage('app/management/opensearch-dashboards/dataSources/'); | ||
cy.get(`[class="euiTableRowCell"]`).contains(clusterName).click(); | ||
cy.getElementByTestId('editDatasourceDeleteIcon').click(); | ||
cy.getElementByTestId('confirmModalConfirmButton').click(); | ||
}); | ||
}); |
Oops, something went wrong.