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

Add infra support and helper function to create real datasource #1146

Merged
merged 27 commits into from
Apr 22, 2024

Conversation

derek-ho
Copy link
Contributor

@derek-ho derek-ho commented Mar 14, 2024

Description

Currently, there is no common support for creating real datasource connection to other opensearch instances. This adds this support in a helper function that other plugins can call when setting up their own multi datasources tests. In github workflow, it will spin up a cluster with no security running on port 9201 that it can connect to. TODO: add cluster supports for security enabled (basic auth and sigv4 auth). This is currently slightly blocked on opensearch-project/OpenSearch-Dashboards#4524

Issues Resolved

Fix: #1230

Check List

  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Derek Ho <dxho@amazon.com>
Signed-off-by: Derek Ho <dxho@amazon.com>
Signed-off-by: Derek Ho <dxho@amazon.com>
Signed-off-by: Derek Ho <dxho@amazon.com>
@derek-ho
Copy link
Contributor Author

@BionIT can you review/suggest direction this should go? Any plugins that can use this POC to write some tests for the repo to establish a pattern?

@kavilla
Copy link
Member

kavilla commented Apr 2, 2024

Does this need backports?

Signed-off-by: Derek Ho <dxho@amazon.com>
Signed-off-by: Derek Ho <dxho@amazon.com>
@wanglam
Copy link
Collaborator

wanglam commented Apr 16, 2024

@derek-ho How can we add test data to the added data sources? For ml-commons, we may need to call /_plugins/_ml/models related API to construct test models. Is there any examples to do it?

@BionIT
Copy link

BionIT commented Apr 18, 2024

Thanks @derek-ho for this change! Sorry for the late reply! Pulling in @zhongnansu to take a look at the PR as well, since this can save the efforts for other plugins as well

cc @seraphjiang

Signed-off-by: Derek Ho <dxho@amazon.com>
Signed-off-by: Derek Ho <dxho@amazon.com>
Signed-off-by: Derek Ho <dxho@amazon.com>
Signed-off-by: Derek Ho <dxho@amazon.com>
Signed-off-by: Derek Ho <dxho@amazon.com>
…oards-functional-test into multi-datasources-support
Signed-off-by: Derek Ho <dxho@amazon.com>
Copy link
Member

@zhongnansu zhongnansu left a comment

Choose a reason for hiding this comment

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

thanks for the change! left some comments

Signed-off-by: Derek Ho <dxho@amazon.com>
Signed-off-by: Derek Ho <dxho@amazon.com>
Signed-off-by: Derek Ho <dxho@amazon.com>
Signed-off-by: Derek Ho <dxho@amazon.com>
Signed-off-by: Derek Ho <dxho@amazon.com>
Signed-off-by: Derek Ho <dxho@amazon.com>
Signed-off-by: Derek Ho <dxho@amazon.com>
Signed-off-by: Derek Ho <dxho@amazon.com>
@derek-ho
Copy link
Contributor Author

Dashboard failures are coming from notification dashboards:

curl: (7) Failed to connect to localhost port 5601 after 0 ms: Connection refused
{"type":"log","@timestamp":"2024-04-19T18:52:41Z","tags":["fatal","root"],"pid":2551,"message":"Error: Cannot find module '../../public/utils/constants'\nRequire stack:\n- /home/runner/work/opensearch-dashboards-functional-test/opensearch-dashboards-functional-test/opensearch-dashboards-3.0.0/plugins/notificationsDashboards/server/routes/configRoutes.js\n- /home/runner/work/opensearch-dashboards-functional-test/opensearch-dashboards-functional-test/opensearch-dashboards-3.0.0/plugins/notificationsDashboards/server/routes/index.js\n- /home/runner/work/opensearch-dashboards-functional-test/opensearch-dashboards-functional-test/opensearch-dashboards-3.0.0/plugins/notificationsDashboards/server/plugin.js\n- /home/runner/work/opensearch-dashboards-functional-test/opensearch-dashboards-functional-test/opensearch-dashboards-3.0.0/plugins/notificationsDashboards/server/index.js\n- /home/runner/work/opensearch-dashboards-functional-test/opensearch-dashboards-functional-test/opensearch-dashboards-3.0.0/src/core/server/
 FATAL  Error: Cannot find module '../../public/utils/constants'
Require stack:
- /home/runner/work/opensearch-dashboards-functional-test/opensearch-dashboards-functional-test/opensearch-dashboards-3.0.0/plugins/notificationsDashboards/server/routes/configRoutes.js
- ```

Signed-off-by: Derek Ho <dxho@amazon.com>
Signed-off-by: Derek Ho <dxho@amazon.com>
Signed-off-by: Derek Ho <dxho@amazon.com>
@BionIT
Copy link

BionIT commented Apr 19, 2024

@CCongWang @tianleh Could you help to review this PR? Thanks in advance!

@derek-ho
Copy link
Contributor Author

derek-ho commented Apr 19, 2024

@derek-ho How can we add test data to the added data sources? For ml-commons, we may need to call /_plugins/_ml/models related API to construct test models. Is there any examples to do it?

@wanglam I modified this PR to download the full distribution. See the helper function I introduced and the README. Once you get the id of the created datasource via the helper function, you should be able to make a regular request with cy.request(ENDPOINT?dataSourceId=${id}), or whichever way the ML plugin implemented request routing for the external datasource, or via UI and cypress actions.

@wanglam
Copy link
Collaborator

wanglam commented Apr 22, 2024

@derek-ho How can we add test data to the added data sources? For ml-commons, we may need to call /_plugins/_ml/models related API to construct test models. Is there any examples to do it?

@wanglam I modified this PR to download the full distribution. See the helper function I introduced and the README. Once you get the id of the created datasource via the helper function, you should be able to make a regular request with cy.request(ENDPOINT?dataSourceId=${id}), or whichever way the ML plugin implemented request routing for the external datasource, or via UI and cypress actions.

We need to call our opensearch plugin directly in our functional tests repo. Could we store the endpoint to the cypress.json? So we can reference the environment variable in cy.request.

Signed-off-by: Derek Ho <dxho@amazon.com>
Signed-off-by: Derek Ho <dxho@amazon.com>
@tianleh tianleh merged commit df38e30 into opensearch-project:main Apr 22, 2024
36 of 40 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Apr 23, 2024
* Add infra support and helper function to create real datasource

Signed-off-by: Derek Ho <dxho@amazon.com>

* Remove logs from previous change

Signed-off-by: Derek Ho <dxho@amazon.com>

* Add test that uses the helper function to verify functionality

Signed-off-by: Derek Ho <dxho@amazon.com>

* Change to request and add it to appropriate workflows

Signed-off-by: Derek Ho <dxho@amazon.com>

* Add basic auth remote cluster

Signed-off-by: Derek Ho <dxho@amazon.com>

* Call function

Signed-off-by: Derek Ho <dxho@amazon.com>

* Move action

Signed-off-by: Derek Ho <dxho@amazon.com>

* Update action and usage in docs

Signed-off-by: Derek Ho <dxho@amazon.com>

* Checkout before access

Signed-off-by: Derek Ho <dxho@amazon.com>

* Add relative path

Signed-off-by: Derek Ho <dxho@amazon.com>

* Fix spelling

Signed-off-by: Derek Ho <dxho@amazon.com>

* Remove -d

Signed-off-by: Derek Ho <dxho@amazon.com>

* Move port logic

Signed-off-by: Derek Ho <dxho@amazon.com>

* Cat log

Signed-off-by: Derek Ho <dxho@amazon.com>

* Allow modification

Signed-off-by: Derek Ho <dxho@amazon.com>

* Duplicate download

Signed-off-by: Derek Ho <dxho@amazon.com>

* Change directory

Signed-off-by: Derek Ho <dxho@amazon.com>

* Change name

Signed-off-by: Derek Ho <dxho@amazon.com>

* Remove extra chmod

Signed-off-by: Derek Ho <dxho@amazon.com>

* Within test directory

Signed-off-by: Derek Ho <dxho@amazon.com>

* Fix

Signed-off-by: Derek Ho <dxho@amazon.com>

* Fix for windows, add helper function, show usage

Signed-off-by: Derek Ho <dxho@amazon.com>

* Remove pwd

Signed-off-by: Derek Ho <dxho@amazon.com>

* Move to temp dire

Signed-off-by: Derek Ho <dxho@amazon.com>

* Address PR feedback and try to spin up an instance with security

Signed-off-by: Derek Ho <dxho@amazon.com>

* Small action change and documentation add

Signed-off-by: Derek Ho <dxho@amazon.com>

---------

Signed-off-by: Derek Ho <dxho@amazon.com>
(cherry picked from commit df38e30)
tianleh pushed a commit that referenced this pull request Apr 23, 2024
… (#1225)

* Add infra support and helper function to create real datasource

Signed-off-by: Derek Ho <dxho@amazon.com>

* Remove logs from previous change

Signed-off-by: Derek Ho <dxho@amazon.com>

* Add test that uses the helper function to verify functionality

Signed-off-by: Derek Ho <dxho@amazon.com>

* Change to request and add it to appropriate workflows

Signed-off-by: Derek Ho <dxho@amazon.com>

* Add basic auth remote cluster

Signed-off-by: Derek Ho <dxho@amazon.com>

* Call function

Signed-off-by: Derek Ho <dxho@amazon.com>

* Move action

Signed-off-by: Derek Ho <dxho@amazon.com>

* Update action and usage in docs

Signed-off-by: Derek Ho <dxho@amazon.com>

* Checkout before access

Signed-off-by: Derek Ho <dxho@amazon.com>

* Add relative path

Signed-off-by: Derek Ho <dxho@amazon.com>

* Fix spelling

Signed-off-by: Derek Ho <dxho@amazon.com>

* Remove -d

Signed-off-by: Derek Ho <dxho@amazon.com>

* Move port logic

Signed-off-by: Derek Ho <dxho@amazon.com>

* Cat log

Signed-off-by: Derek Ho <dxho@amazon.com>

* Allow modification

Signed-off-by: Derek Ho <dxho@amazon.com>

* Duplicate download

Signed-off-by: Derek Ho <dxho@amazon.com>

* Change directory

Signed-off-by: Derek Ho <dxho@amazon.com>

* Change name

Signed-off-by: Derek Ho <dxho@amazon.com>

* Remove extra chmod

Signed-off-by: Derek Ho <dxho@amazon.com>

* Within test directory

Signed-off-by: Derek Ho <dxho@amazon.com>

* Fix

Signed-off-by: Derek Ho <dxho@amazon.com>

* Fix for windows, add helper function, show usage

Signed-off-by: Derek Ho <dxho@amazon.com>

* Remove pwd

Signed-off-by: Derek Ho <dxho@amazon.com>

* Move to temp dire

Signed-off-by: Derek Ho <dxho@amazon.com>

* Address PR feedback and try to spin up an instance with security

Signed-off-by: Derek Ho <dxho@amazon.com>

* Small action change and documentation add

Signed-off-by: Derek Ho <dxho@amazon.com>

---------

Signed-off-by: Derek Ho <dxho@amazon.com>
(cherry picked from commit df38e30)

Co-authored-by: Derek Ho <dxho@amazon.com>
LDrago27 pushed a commit to LDrago27/opensearch-dashboards-functional-test that referenced this pull request May 3, 2024
…search-project#1146)

* Add infra support and helper function to create real datasource

Signed-off-by: Derek Ho <dxho@amazon.com>

* Remove logs from previous change

Signed-off-by: Derek Ho <dxho@amazon.com>

* Add test that uses the helper function to verify functionality

Signed-off-by: Derek Ho <dxho@amazon.com>

* Change to request and add it to appropriate workflows

Signed-off-by: Derek Ho <dxho@amazon.com>

* Add basic auth remote cluster

Signed-off-by: Derek Ho <dxho@amazon.com>

* Call function

Signed-off-by: Derek Ho <dxho@amazon.com>

* Move action

Signed-off-by: Derek Ho <dxho@amazon.com>

* Update action and usage in docs

Signed-off-by: Derek Ho <dxho@amazon.com>

* Checkout before access

Signed-off-by: Derek Ho <dxho@amazon.com>

* Add relative path

Signed-off-by: Derek Ho <dxho@amazon.com>

* Fix spelling

Signed-off-by: Derek Ho <dxho@amazon.com>

* Remove -d

Signed-off-by: Derek Ho <dxho@amazon.com>

* Move port logic

Signed-off-by: Derek Ho <dxho@amazon.com>

* Cat log

Signed-off-by: Derek Ho <dxho@amazon.com>

* Allow modification

Signed-off-by: Derek Ho <dxho@amazon.com>

* Duplicate download

Signed-off-by: Derek Ho <dxho@amazon.com>

* Change directory

Signed-off-by: Derek Ho <dxho@amazon.com>

* Change name

Signed-off-by: Derek Ho <dxho@amazon.com>

* Remove extra chmod

Signed-off-by: Derek Ho <dxho@amazon.com>

* Within test directory

Signed-off-by: Derek Ho <dxho@amazon.com>

* Fix

Signed-off-by: Derek Ho <dxho@amazon.com>

* Fix for windows, add helper function, show usage

Signed-off-by: Derek Ho <dxho@amazon.com>

* Remove pwd

Signed-off-by: Derek Ho <dxho@amazon.com>

* Move to temp dire

Signed-off-by: Derek Ho <dxho@amazon.com>

* Address PR feedback and try to spin up an instance with security

Signed-off-by: Derek Ho <dxho@amazon.com>

* Small action change and documentation add

Signed-off-by: Derek Ho <dxho@amazon.com>

---------

Signed-off-by: Derek Ho <dxho@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Create infrastructure to test E2E flow for multiple datasource feature
8 participants