-
Notifications
You must be signed in to change notification settings - Fork 906
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate query enhancement cypress tests to OSD repo #8986
Migrate query enhancement cypress tests to OSD repo #8986
Conversation
Signed-off-by: abbyhu2000 <[email protected]>
❌ Empty Changelog SectionThe Changelog section in your PR description is empty. Please add a valid changelog entry or entries. If you did add a changelog entry, check to make sure that it was not accidentally included inside the comment block in the Changelog section. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## cypress-unification #8986 +/- ##
======================================================
Coverage ? 60.89%
======================================================
Files ? 3802
Lines ? 91070
Branches ? 14374
======================================================
Hits ? 55456
Misses ? 32073
Partials ? 3541
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@@ -2,6 +2,21 @@ | |||
* Copyright OpenSearch Contributors | |||
* SPDX-License-Identifier: Apache-2.0 | |||
*/ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicate license
*/ | ||
|
||
Cypress.Commands.add('waitForLoaderNewHeader', () => { | ||
const opts = { log: false }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think for utilities, we need to be careful. Eventually we will move the legacy discover ftr tests back to OSD as well. So the utilities should work for both legacy and is_enhancement is true. For example if could could have both of them working, that would save us a lot of future migration efforts
Cypress.Commands.add('waitForLoader', (isEnhancement = false) => {
const opts = { log: false };
Cypress.log({
name: 'waitForPageLoad',
displayName: 'wait',
message: 'page load',
});
cy.wait(Cypress.env('WAIT_FOR_LOADER_BUFFER_MS'));
// Use recentItemsSectionButton for query enhancement, otherwise use homeIcon
cy.getElementByTestId(
isEnhancement ? 'recentItemsSectionButton' : 'homeIcon',
opts
);
});
Should we also add auth utilities and workspace utilities. Not blocker and can do these in the follow up. |
just to verify what is the goal for this pr? is it just to get it to this repo right? if so then i'm going to leave comments with the implication that we should fast follow these things but NOT block on anything |
"id": "3", | ||
"index": "timestamp-nanos", | ||
"source": { | ||
"timestamp": "2019-01-01T12:10:30.123456789Z" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should make the file name of this not data.json.txt
since that is too generic of a name and could cause confusion.
we should also have more realistic data here as in some other fields maybe even number of other timefields. the size should be more than two. this way the test results for casting a wide net of a date range will yield 2 results the same way filtering by the jan 1st of 2019 would which could maybe lead to false positives in our filtering tests
{ | ||
"type": "doc", | ||
"value": { | ||
"id": "index-pattern:timestamp-*", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this the behavior we wanna continue? i think we did this from the legacy but if we we want to add more documents to these tests to capture the cases we are running into when regressions occur
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if not then we should just consider having stored the ndjson of saved objects and then we just upload them on test start.
this way if we have massive test data we dont know need to open or modify that file to modify the saved objects
@@ -84,8 +84,9 @@ | |||
"spec_to_console": "scripts/use_node scripts/spec_to_console", | |||
"pkg-version": "scripts/use_node -e \"console.log(require('./package.json').version)\"", | |||
"release_note:generate": "scripts/use_node scripts/generate_release_note", | |||
"cypress:run-without-security": "env TZ=America/Los_Angeles NO_COLOR=1 cypress run --headless --env SECURITY_ENABLED=false", | |||
"cypress:run-with-security": "env TZ=America/Los_Angeles NO_COLOR=1 cypress run --headless --env SECURITY_ENABLED=true,openSearchUrl=https://localhost:9200,WAIT_FOR_LOADER_BUFFER_MS=500", | |||
"cypress:run-without-security": "env TZ=America/Los_Angeles NO_COLOR=1 cypress run --env SECURITY_ENABLED=false", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
follow up:
run-without-security
is long to type out
we should upate the appropriate places and here so like
cypress:run // implies it is without security
cypress:run:security // explicit with security
this follows the above structure yarn start:security
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also might need to mention in some readme to run this function with --headless
if people want to get the runner open
"cypress:run-with-security": "env TZ=America/Los_Angeles NO_COLOR=1 cypress run --headless --env SECURITY_ENABLED=true,openSearchUrl=https://localhost:9200,WAIT_FOR_LOADER_BUFFER_MS=500", | ||
"cypress:run-without-security": "env TZ=America/Los_Angeles NO_COLOR=1 cypress run --env SECURITY_ENABLED=false", | ||
"cypress:run-with-security": "env TZ=America/Los_Angeles NO_COLOR=1 cypress run --env SECURITY_ENABLED=true,openSearchUrl=https://localhost:9200,WAIT_FOR_LOADER_BUFFER_MS=500", | ||
"osd:ciGroup10": "echo \"apps/query_enhancement/*.js\"", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sync with @d-rowe . and def not a blocker for any of this but we should consider while in theprocess of migrating defining a middle ground solution at least for the tests to tag themselves instead of a package.json file. because this was only suppose to be temporary and people wont know they need to update thisfor the test to run
something like the selenium stuff https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/test/functional/apps/dashboard/index.js#L83 but even a hackier one that is not using this hack would be better imo
like i said not blocking just mentioning incase it would make the work smaller increments
* @example | ||
* cy.whenTestIdNotFound(['query', 'puery'], () => {...}) | ||
*/ | ||
whenTestIdNotFound<S = any>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also do people call this?
* cy.getElementsByTestIds(['query', 'puery']) | ||
*/ | ||
getElementsByTestIds<S = any>( | ||
testIds: string | string[], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ik carry over but too flexiable of a system is hard to keep up. i think if we have a getelementbytestid then it should just be string[] here
bulkUploadDocs<S = any>( | ||
fixturePath: string, | ||
index: string | ||
// options?: Partial<Loggable & Timeoutable & Withinable & Shadow> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shoudl this overwrite?
*/ | ||
|
||
export const clusterName = 'test_cluster'; | ||
export const clusterConnection = 'http://localhost:9200'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets not port this over imo. this should pull from a config and if that config is suppose to point to an external url then only the cypress config would be able to update so easily this constant is a constant and wont be reusable in cases
}); | ||
|
||
cy.getElementByTestId(`queryEditorLanguageSelector`).click(); | ||
cy.get(`[class~="languageSelector__menuItem"]`).contains(value).click({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could either add a test id which might be easier or access this class from the parent that has a test id of queryeditor langauge selector to ensure it doesn't grab the wrong language selector
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export const apiRequest = (url, method = 'POST', body = undefined, qs = undefined) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should make this an object after url and method so it wont get so difficutl to update if we need to add more
export const devToolsRequest = (url, method = 'POST', body = undefined, qs = undefined) => | ||
cy.request({ | ||
method: 'POST', | ||
form: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: seems like there could be a request headers constant that we can spread here
qs: qs, | ||
}); | ||
|
||
export const devToolsRequest = (url, method = 'POST', body = undefined, qs = undefined) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this is kind of the wrong name. i think it's technically proxying to the console plugin dev tools is an application that is a child of the console plugin but it is client side.
so we aren't actually firing the request to the ui we are hitting the node server api
export const INDEX_PATTERN_PATH = STACK_MANAGEMENT_PATH + '/opensearch-dashboards/indexPatterns'; | ||
export const SAVED_OBJECTS_PATH = STACK_MANAGEMENT_PATH + '/opensearch-dashboards/objects'; | ||
|
||
export * from './query_enhancement/constants'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we shouldn't export another folders constants here
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import './query_enhancement/commands'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should have global commands if needed. and then query enhancmeents and dashboards can take from it vs another plugin command
cy.log('Deleting all indices'); | ||
cy.request( | ||
'DELETE', | ||
`${Cypress.env('openSearchUrl')}/index*,sample*,opensearch_dashboards*,test*,cypress*` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we ahve to refresh?
|
||
import { BASE_PATH } from './constants'; | ||
|
||
// This function does not delete all indices |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we modify this now to actually delete all indices and not a specific string?
cy.log('Deleting all indices'); | ||
cy.request( | ||
'DELETE', | ||
`${Cypress.env('openSearchUrl')}/index*,sample*,opensearch_dashboards*,test*,cypress*` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now that we have it can we just say ENGINE_URL
anything besides the casing
method: 'PUT', | ||
url, | ||
headers: { | ||
'content-type': 'application/json;charset=UTF-8', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can modify the cy.request which i think the security plugin commands are doing to just add some of these copy and paste request headers
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
export const DE_INDEX_DATA = ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
empty?
also instead of us needing to import all these individual sometime we can namespace stuff like
DE: {
INDEX: {
ID: 'data-explorer',
DATA: '',
}
...
so then we would have to import 3 things we just import one and use dot notation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
simplify the importing using namespace, for example:
export const PATHS = {
BASE: BASE_PATH,
ENGINE: BASE_ENGINE.url,
SECONDARY_ENGINE: SECONDARY_ENGINE.url,
STACK_MANAGEMENT: BASE_PATH + '/app/management',
SECURITY_PLUGIN: BASE_PATH + '/app/security-dashboards-plugin#/',
TENANTS_MANAGE: BASE_PATH + '/app/security-dashboards-plugin#/tenants',
INDEX_PATTERNS: BASE_PATH + '/app/management/opensearch-dashboards/indexPatterns',
SAVED_OBJECTS: BASE_PATH + '/app/management/opensearch-dashboards/objects',
};
|
||
export const DE_PATH_FIXTURE = 'dashboard/opensearch_dashboards/data_explorer/'; | ||
|
||
export const DE_DEFAULT_START_TIME = 'Sep 19, 2015 @ 06:31:44.000'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a good candidate. for the above comment too but
why not have this higher up or not global defined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have to keep this folder structure?
core_opensearch_dashboards
is redudant now since we are in the opensearch dashboards repo. we can reduce the messiness now since we should only be our tests for our plugins
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@d-rowe @abbyhu2000 @ananzh did you guys before porting over want to list out what is the structure of the nested folders we should shoot for? otherwise we will just port of tech debt that is just really busy work. unless this was a drop in replacement why would be suprrising then probably we are spending the effort to keep the tech debt.
we should just quickly list out what we want the end state to kind of look like
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made the file structure a little nicer by getting rid of /core-opensearch-dashboard and /plugin
EX:
/cypress
/integration
/apps
/query_enhancements
/test files
/another_plugin
/test files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ide would be able to let us know what is a .spec
file but dataset_selector_spec.js
would just seem like a regular file. so please use dataset_selector.spec.js
also why not typescript? @d-rowe is this setup for tyupescript?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, this package is setup for typescript. It'd be great to have these be typescript files, but actually backfilling the types would be quite an effort during this migration it seems.
describe('select indices', () => { | ||
before(() => { | ||
testFixtureHandler.importJSONMapping( | ||
'cypress/fixtures/dashboard/opensearch_dashboards/query_enhancement/mappings.json.txt' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could consider a utils function that does this a little bit easier like we know we want to store in fixtures so then we just need to have the plugin define it data it wants to use.
but i dont really see why each plugin needs to define its own fixtures.
if we add a new plugin then the plugin will think it needs to keep adding more sample data that is increasing the resources taken for local development when this data could have been re-used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree on getting a utils function so importing datas can be cleaner.
Currently changing the fixture file structure so that dashboard and plugin fixtures are not seperated, instead each folder are the data name and contain one data file and one mapping file.
Ex:
/fixtures
/discover
/data.json
/mappings.json
/logstash
/data.json
/mappings.json
/timestamp
/data.json
/mappings.json
.....
close this in favor of #9048 |
Description
Migrate query enhancement cypress tests to OSD repo.
Issues Resolved
Screenshot
Testing the changes
Changelog
Check List
yarn test:jest
yarn test:jest_integration