Skip to content
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

Follow up on #9048 by updating data and utilities #9060

Merged
merged 6 commits into from
Dec 18, 2024

Conversation

ananzh
Copy link
Member

@ananzh ananzh commented Dec 16, 2024

Description

To Run

// Download opensearch artifact and unzip
wget https://artifacts.opensearch.org/releases/bundle/opensearch/2.17.0/opensearch-2.17.0-linux-x64.tar.gz
tar -xvf opensearch-2.17.0-linux-x64.tar.gz
// remove security
./bin/opensearch-plugin remove opensearch-security
./opensearch-tar-install.sh
// enable workspace in confid/opensearch_dashboards.yml
workspace.enabled: true
opensearch.ignoreVersionMismatch: true
// run osd
yarn start:enhancements --no-base-path

Issues Resolved

NA

Changelog

  • skip

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

Copy link

codecov bot commented Dec 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 60.86%. Comparing base (442e11e) to head (474c2e5).
Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #9060   +/-   ##
=======================================
  Coverage   60.86%   60.86%           
=======================================
  Files        3808     3808           
  Lines       91209    91209           
  Branches    14410    14410           
=======================================
  Hits        55516    55516           
+ Misses      32156    32153    -3     
- Partials     3537     3540    +3     
Flag Coverage Δ
Linux_1 29.02% <ø> (ø)
Linux_2 56.38% <ø> (ø)
Linux_3 37.93% <ø> (ø)
Linux_4 29.01% <ø> (ø)
Windows_1 29.03% <ø> (ø)
Windows_2 56.34% <ø> (ø)
Windows_3 37.93% <ø> (+<0.01%) ⬆️
Windows_4 29.01% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


export const BASE_PATH = Cypress.config().baseUrl;
export const DATASOURCE_NAME = 'test_cluster';
export const DATASOURCE_URL = 'http://localhost:9200';
Copy link
Collaborator

@LDrago27 LDrago27 Dec 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can update the DataSource_URL to use the openSearchUrl: 'http://localhost:9200' defined within this file

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will clean out all the base path and url in another follow-up

@@ -90,7 +90,7 @@ jobs:
options: --user 1001
env:
START_CMD: ${{ matrix.config == 'query_enhanced' &&
'node scripts/opensearch_dashboards --dev --no-base-path --no-watch --savedObjects.maxImportPayloadBytes=10485760 --server.maxPayloadBytes=1759977 --logging.json=false --data.search.aggs.shardDelay.enabled=true --csp.warnLegacyBrowsers=false --uiSettings.overrides["query:enhancements:enabled"]=true --uiSettings.overrides[''home:useNewHomePage'']=true --data_source.enabled=true --opensearch.ignoreVersionMismatch=true' ||
'node scripts/opensearch_dashboards --dev --no-base-path --no-watch --savedObjects.maxImportPayloadBytes=10485760 --server.maxPayloadBytes=1759977 --logging.json=false --data.search.aggs.shardDelay.enabled=true --csp.warnLegacyBrowsers=false --uiSettings.overrides["query:enhancements:enabled"]=true --uiSettings.overrides[''home:useNewHomePage'']=true --data_source.enabled=true --workspace.enable=true --opensearch.ignoreVersionMismatch=true' ||
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo --workspace.enable=true should be --workspace.enabled=true

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice. thanks a lot.

Copy link
Collaborator

@AMoo-Miki AMoo-Miki Dec 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to have tests run with and without workspaces being enabled.

// Load test data
cy.setupTestData(
[
'cypress/fixtures/query_enhancements/data-logs-1/data_logs_small_time_1.mapping.json',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we refactor the structure of the fixtures to not care about the plugin for example cypress/fixtures/{file name}

we could make setupTestData just automatically set the path so that all we have to do is pass the file name for example

setupTestData('small_time_range_1.mapping.json')

then in the setupTestData we automatically just preprend cypress/fixtures/ to it. this would make it easier and less prone to error if the file path is too long

* @param {string} [options.credentials.username] Username for basic auth
* @param {string} [options.credentials.password] Password for basic auth
*/
Cypress.Commands.add('addDataSource', (options) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whats specific about query enhancements ? this seems like it should be globally used

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why workspace-plugin ? query_enhancements is a plugin as well so we should just remove the plugin

@@ -5,3 +5,28 @@

import '../utils/commands';
import '../utils/apps/commands';
import '../utils/dashboards/workspace-plugin/commands';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imo the commands should be exported in dashboards/commands and then we just import it instead of nesting a plugin

const { TestDataGenerator } = require('./test_data_generator');

// Need to update different path for multiple clusters
const DEFAULT_PATH =
Copy link
Member

@kavilla kavilla Dec 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nested default path that points to a plugin fixture. we shouldn't do this we should use cypress configuration to set these values in the env this will likely get lost

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what javascript?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we moving to integration/core-opensearch-dashboards/opensearch-dashboards

this is too long and what other tests would exist in this repo besides the core opensearch dashboards tests?

*/

export class TestFixtureHandler {
constructor(inputTestRunner, openSearchUrl = 'localhost:9200') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we aren't we pulling from the cypyress environment variable ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

}

_extractIndexNameFromPath(filepath) {
const filename = filepath.split('/').pop();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont think this is worth it and requires knowing the system. to the point where it might just be easier to require the index name as apart of the file fixture

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't use this one. it is for easy migration.

* SPDX-License-Identifier: Apache-2.0
*/

Cypress.Commands.add('selectFromDataSourceSelector', (dataSourceTitle, dataSourceId) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seeing this as a datasource command as well im not positive what goes into utils/commands and what goes into query_enhancements/commands which all have a data source command

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't use this one. it is for easy migration.


Cypress.Commands.add('selectFromDataSourceSelector', (dataSourceTitle, dataSourceId) => {
// clean up the input field
cy.wait(1000);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:( cy.wait make tests flaky

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't use this one. it is for easy migration.

* SPDX-License-Identifier: Apache-2.0
*/

export function removeSampleDataAndWorkspace(url, workspaceName) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems like util functions but they are tests. if this helper functions fail does the entire test fail?

if so this seems wrong. we shouldn't use E2E testing if we are doing test setup. it's too slow and flaky. we should use the saved objects api which workspaces supports and just execute queries.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't use this one. it is for easy migration.

@@ -86,7 +86,7 @@
"release_note:generate": "scripts/use_node scripts/generate_release_note",
"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 \"cypress/integration/apps/query_enhancements/queries.spec.js,cypress/integration/apps/query_enhancements/dataset_selector.spec.js\"",
"osd:ciGroup10": "echo \"cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/query_enhancements/a_check.spec.js\"",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so we are not gunna execute the queries.spec and dataset_selector.spec?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

explained below


import { TestFixtureHandler } from '../lib/test-fixture-handler';

Cypress.Commands.add('setupTestData', (mappingFiles, dataFiles) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be in the utils/commands

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did the linter not catch this file name? i think we are suppose to use _

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

Copy link
Member

@kavilla kavilla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blocking because this will no longer run the existing tests. it just runs the check spec file

Screenshot 2024-12-17 at 5 51 16 PM

@ananzh
Copy link
Member Author

ananzh commented Dec 18, 2024

blocking because this will no longer run the existing tests. it just runs the check spec file

Screenshot 2024-12-17 at 5 51 16 PM

I think this is expected. The two tests are written when we haven't enable workspace. We will modify these two tests:

cypress/integration/apps/query_enhancements/dataset_selector.spec.js
cypress/integration/apps/query_enhancements/queries.spec.js

  1. enable workspace 2) modify utilities to use endpoint 3) migrate test lib to main (TestFixtureHandler and MiscUtils)

LDrago27
LDrago27 previously approved these changes Dec 18, 2024
Signed-off-by: Anan <[email protected]>
@kavilla kavilla dismissed their stale review December 18, 2024 20:24

tests will be re-added.

@ananzh ananzh merged commit f9c463d into opensearch-project:main Dec 18, 2024
69 checks passed
@ananzh ananzh added the discover_2.0-test Issues that are specific to the Discover 2.0 testing initiative label Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discover_2.0-test Issues that are specific to the Discover 2.0 testing initiative distinguished-contributor Skip-Changelog PRs that are too trivial to warrant a changelog or release notes entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants