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

Adds Multiple Datasources Support for Security Dashboards Plugin #1888

Merged
merged 25 commits into from
Apr 26, 2024

Conversation

derek-ho
Copy link
Collaborator

@derek-ho derek-ho commented Apr 12, 2024

Description

This PR merges the feature branch feature/supporting-multiple-datasources to main. It adds support for multiple datasources within the security dashboards plugin. This means that for each page (minus tenancy and service accounts which are both locked to the local cluster), users can choose between different clusters that they added as a datasource and perform CRUD operations on that cluster's security backend plugin. If multi datasources is not enabled, then the security dashboards plugin will behave in the same way as before.

Category

New feature

Why these changes are required?

To support multiple datasources in the security dashboards plugin.

What is the old behavior before changes and new behavior after changes?

Old behavior: no support for multiple datasources (all CRUD operations done on local cluster)
New behavior: support for multiple datasources (users can choose which cluster to do CRUD operations on)

Video of security plugin with these changes, with/without multi datasources feature enabled:

Screen.Recording.2024-04-22.at.5.03.07.PM.mov

Issues Resolved

Close: #1794

Testing

Adds unit tests where appropriate, adds cypress tests (currently flaky), adds integration tests against a matrix of prior versions of OpenSearch to ensure compatibility with linux and windows.

Check List

  • New functionality includes testing
  • New functionality has been documented
  • 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.

derek-ho and others added 11 commits March 20, 2024 10:52
…1818)



Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Derek Ho <[email protected]>
Co-authored-by: Darshit Chanpura <[email protected]>
* Add multi datasource support for internal users tab

Signed-off-by: Derek Ho <[email protected]>

* Add test coverage for front end and backend

Signed-off-by: Derek Ho <[email protected]>

* Push cypress test for users

Signed-off-by: Derek Ho <[email protected]>

* Remove extra click

Signed-off-by: Derek Ho <[email protected]>

* Consume changes in core

Signed-off-by: Derek Ho <[email protected]>

* Don't rely on public export for type

Signed-off-by: Derek Ho <[email protected]>

* Consume list changes, fix cypress test unskips auth test

Signed-off-by: Derek Ho <[email protected]>

* Fix cypress test

Signed-off-by: Derek Ho <[email protected]>

* Fix test

Signed-off-by: Derek Ho <[email protected]>

* Test fix

Signed-off-by: Derek Ho <[email protected]>

* Add timeout as well

Signed-off-by: Derek Ho <[email protected]>

* Try different way to select the option

Signed-off-by: Derek Ho <[email protected]>

* Fix test

Signed-off-by: Derek Ho <[email protected]>

* Use data test subj for more consistency

Signed-off-by: Derek Ho <[email protected]>

---------

Signed-off-by: Derek Ho <[email protected]>
* Adds datasource picker to Permissions tab

Signed-off-by: Darshit Chanpura <[email protected]>

* Finalizes changes for Permissions tab dataSource picker

Signed-off-by: Darshit Chanpura <[email protected]>

* Fixes Unit tests

Signed-off-by: Darshit Chanpura <[email protected]>

* Adds integration tests

Signed-off-by: Darshit Chanpura <[email protected]>

* Adds cypress test for Permission tab with remote data source

Signed-off-by: Darshit Chanpura <[email protected]>

* Completes cypress test for Permissions tab, fixes cypress test for Users tab and fixes a spelling error

Signed-off-by: Darshit Chanpura <[email protected]>

* Updates unit tests and reverts a change in cypress test

Signed-off-by: Darshit Chanpura <[email protected]>

* Addresses nits to make tests more robust

Signed-off-by: Darshit Chanpura <[email protected]>

* Fixes unit tests

Signed-off-by: Darshit Chanpura <[email protected]>

---------

Signed-off-by: Darshit Chanpura <[email protected]>
* Add multi datasource support for the tenanct and audit log tabs

Signed-off-by: Derek Ho <[email protected]>

* Add integraiton tests for audit log with and without multi datasource

Signed-off-by: Derek Ho <[email protected]>

* Add cypress test support for tenancy and audit log

Signed-off-by: Derek Ho <[email protected]>

* Add toast support and assert existance of page element to make test unflaky

Signed-off-by: Derek Ho <[email protected]>

---------

Signed-off-by: Derek Ho <[email protected]>
* Adds datasource picker for Roles tab and its sub-tabs

Signed-off-by: Darshit Chanpura <[email protected]>

* Fixes jest:ui task

Signed-off-by: Darshit Chanpura <[email protected]>

* Adds integration test for roles datasource picker

Signed-off-by: Darshit Chanpura <[email protected]>

* Adds cypress test for roles tab

Signed-off-by: Darshit Chanpura <[email protected]>

* fixFix ResizeObserver loop error

Signed-off-by: Darshit Chanpura <[email protected]>

* Makes query param required

Signed-off-by: Darshit Chanpura <[email protected]>

---------

Signed-off-by: Darshit Chanpura <[email protected]>
* Add selector on service accounts page

Signed-off-by: Derek Ho <[email protected]>

* Lint

Signed-off-by: Derek Ho <[email protected]>

* Fix test for service accounts

Signed-off-by: Derek Ho <[email protected]>

---------

Signed-off-by: Derek Ho <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
* Add cluster info to toasts

Signed-off-by: Derek Ho <[email protected]>

* Add URL support

Signed-off-by: Derek Ho <[email protected]>

* Initial work to read/write from url

Signed-off-by: Derek Ho <[email protected]>

* Consume changes from core

Signed-off-by: Derek Ho <[email protected]>

* Lint and remove unused imports

Signed-off-by: Derek Ho <[email protected]>

* Fix edge case and test

Signed-off-by: Derek Ho <[email protected]>

* Refactors tests to accomodate changes to dataSource value consumption from URL

Signed-off-by: Darshit Chanpura <[email protected]>

* Try in headless mode

Signed-off-by: Derek Ho <[email protected]>

* Make closeToast better and revert to admin password for matrix going back to 2.4

Signed-off-by: Derek Ho <[email protected]>

* Try experimental memory management

Signed-off-by: Derek Ho <[email protected]>

* Try to fix closeToast

Signed-off-by: Derek Ho <[email protected]>

* Fix for close toast

Signed-off-by: Derek Ho <[email protected]>

* Find by warning

Signed-off-by: Derek Ho <[email protected]>

* Fix by warning

Signed-off-by: Derek Ho <[email protected]>

* Fix tenancy test from main

Signed-off-by: Derek Ho <[email protected]>

* Fix auth test and be explicit about local datasource

Signed-off-by: Derek Ho <[email protected]>

* Test fixes

Signed-off-by: Derek Ho <[email protected]>

* Fix role flaky test

Signed-off-by: Derek Ho <[email protected]>

* Nit

Signed-off-by: Derek Ho <[email protected]>

* Makes github cypress run headless

Signed-off-by: Darshit Chanpura <[email protected]>

* Enabled experimentalMemoryManagement for chromium based cypress tests

Signed-off-by: Darshit Chanpura <[email protected]>

---------

Signed-off-by: Derek Ho <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Co-authored-by: Darshit Chanpura <[email protected]>
Copy link

codecov bot commented Apr 12, 2024

Codecov Report

Attention: Patch coverage is 51.07296% with 114 lines in your changes are missing coverage. Please review.

Project coverage is 69.60%. Comparing base (a35d7c1) to head (ec0d269).

Files Patch % Lines
public/apps/configuration/app-router.tsx 12.76% 41 Missing ⚠️
public/apps/configuration/utils/request-utils.ts 45.45% 16 Missing and 2 partials ⚠️
...ublic/apps/configuration/utils/role-list-utils.tsx 0.00% 7 Missing ⚠️
...c/apps/configuration/utils/action-groups-utils.tsx 0.00% 5 Missing ⚠️
public/apps/configuration/utils/tenant-utils.tsx 44.44% 5 Missing ⚠️
public/apps/account/utils.tsx 0.00% 4 Missing ⚠️
public/apps/configuration/top-nav-menu.tsx 71.42% 2 Missing and 2 partials ⚠️
...c/apps/configuration/utils/audit-logging-utils.tsx 0.00% 4 Missing ⚠️
...lic/apps/configuration/utils/role-detail-utils.tsx 0.00% 4 Missing ⚠️
...configuration/utils/internal-user-detail-utils.tsx 0.00% 3 Missing ⚠️
... and 14 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1888      +/-   ##
==========================================
+ Coverage   68.37%   69.60%   +1.23%     
==========================================
  Files          94       96       +2     
  Lines        2416     2481      +65     
  Branches      330      332       +2     
==========================================
+ Hits         1652     1727      +75     
+ Misses        687      673      -14     
- Partials       77       81       +4     

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

@cwperks
Copy link
Member

cwperks commented Apr 17, 2024

@derek-ho Can you please fill out the description of this PR?

What is remaining before it is flipped from Draft?

@derek-ho
Copy link
Collaborator Author

@derek-ho Can you please fill out the description of this PR?

What is remaining before it is flipped from Draft?

@cwperks working on cypress test stability - see draft PR: #1894. Cypress tests consistently working on @DarshitChanpura and I's local, but failing on github runner due to space issues, we are seeing if we can find the root case.

@derek-ho derek-ho changed the title Feature/supporting multiple datasources Adds Multiple Datasources Support for Security Dashboards Plugin Apr 17, 2024
Copy link
Member

@cwperks cwperks left a comment

Choose a reason for hiding this comment

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

Left some initial comments.

Would it be possible to capture a recording of the cypress tests that are run that test the MDS functionality?

cypress.config.js Outdated Show resolved Hide resolved
public/utils/datasource-utils.ts Show resolved Hide resolved
public/utils/datasource-utils.ts Show resolved Hide resolved
public/utils/datasource-utils.ts Show resolved Hide resolved
* Fix some state issues and try to use electron browser

Signed-off-by: Derek Ho <[email protected]>

* Try modifying numtestskeptinmemory

Signed-off-by: Derek Ho <[email protected]>

* Remove closetoast

Signed-off-by: Derek Ho <[email protected]>

* Fix flaky cypress test

Signed-off-by: Derek Ho <[email protected]>

* Run 10x

Signed-off-by: Derek Ho <[email protected]>

* Fix test

Signed-off-by: Derek Ho <[email protected]>

* Fix permissions test

Signed-off-by: Derek Ho <[email protected]>

* Move management to correct section

Signed-off-by: Derek Ho <[email protected]>

* Push up fixes for audit logs and roles

Signed-off-by: Derek Ho <[email protected]>

* Remove local cluster checks to cut length and increase stability

Signed-off-by: Derek Ho <[email protected]>

* Improves before and after handling

Signed-off-by: Darshit Chanpura <[email protected]>

* Temporarily disable permissions and roles tests

Signed-off-by: Darshit Chanpura <[email protected]>

* adds delete datasource call to beforeEach

Signed-off-by: Darshit Chanpura <[email protected]>

* Unskip permissions test

Signed-off-by: Darshit Chanpura <[email protected]>

* Absorb changes from core

Signed-off-by: Darshit Chanpura <[email protected]>

* Fixes tests

Signed-off-by: Darshit Chanpura <[email protected]>

* Skips legacy browser warning

Signed-off-by: Darshit Chanpura <[email protected]>

* Refactor audit logs tests

Signed-off-by: Darshit Chanpura <[email protected]>

* Force page reload post creation

Signed-off-by: Darshit Chanpura <[email protected]>

* Unskip auth and roles, and skip audit logs

Signed-off-by: Darshit Chanpura <[email protected]>

* Skip roles tab

Signed-off-by: Darshit Chanpura <[email protected]>

* Changes data source url

Signed-off-by: Darshit Chanpura <[email protected]>

* Fix lint issues

Signed-off-by: Darshit Chanpura <[email protected]>

* Chrome

Signed-off-by: Derek Ho <[email protected]>

* Skip users and permissions tab

Signed-off-by: Derek Ho <[email protected]>

* Revert cypress settings

Signed-off-by: Derek Ho <[email protected]>

* Modify test to make cypress request instead of UI

Signed-off-by: Derek Ho <[email protected]>

* Lint

Signed-off-by: Derek Ho <[email protected]>

* Add fix for get started and rewrite users test

Signed-off-by: Derek Ho <[email protected]>

* use tostring to be more consistent with the actual behavior

Signed-off-by: Derek Ho <[email protected]>

* Try to fix flaky tests

Signed-off-by: Derek Ho <[email protected]>

* Revert to beforeeach and aftereach

Signed-off-by: Derek Ho <[email protected]>

* Fix test

Signed-off-by: Derek Ho <[email protected]>

* Fix lint

Signed-off-by: Derek Ho <[email protected]>

* Fix roles and enable

Signed-off-by: Derek Ho <[email protected]>

* Adds retry mechanism to cypress tests

Signed-off-by: Darshit Chanpura <[email protected]>

* Increases retries to 5

Signed-off-by: Darshit Chanpura <[email protected]>

* Reverts CI runs to 1

Signed-off-by: Darshit Chanpura <[email protected]>

---------

Signed-off-by: Derek Ho <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Co-authored-by: Derek Ho <[email protected]>
@derek-ho derek-ho marked this pull request as ready for review April 22, 2024 20:37
Copy link
Member

@cwperks cwperks left a comment

Choose a reason for hiding this comment

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

Took a second pass. This looks very close. Thanks for fixing the issues with the tests!

@derek-ho
Copy link
Collaborator Author

Cypress test failures resolved by: opensearch-project/opensearch-dashboards-functional-test#1239

@peternied peternied mentioned this pull request Apr 25, 2024
23 tasks
@cwperks
Copy link
Member

cwperks commented Apr 25, 2024

@derek-ho Is this blocked until opensearch-project/opensearch-dashboards-functional-test#1239 is merged?

Signed-off-by: Derek Ho <[email protected]>
@derek-ho
Copy link
Collaborator Author

@derek-ho Is this blocked until opensearch-project/opensearch-dashboards-functional-test#1239 is merged?

It was merged, and I also updated some of the datasource specific tests to incorporate upstream core changes, CI is green now, and ready for re-review 👍

peternied
peternied previously approved these changes Apr 26, 2024
@derek-ho derek-ho dismissed stale reviews from DarshitChanpura and peternied via 9d60f4f April 26, 2024 15:42
peternied
peternied previously approved these changes Apr 26, 2024
Signed-off-by: Derek Ho <[email protected]>
@derek-ho derek-ho dismissed stale reviews from DarshitChanpura and peternied via ec0d269 April 26, 2024 16:01
@DarshitChanpura DarshitChanpura merged commit 154a3ba into main Apr 26, 2024
29 of 30 checks passed
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.x 2.x
# Navigate to the new working tree
cd .worktrees/backport-2.x
# Create a new branch
git switch --create backport/backport-1888-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 154a3ba08828b36a8dae684651f25c8d72f584be
# Push it to GitHub
git push --set-upstream origin backport/backport-1888-to-2.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-1888-to-2.x.

derek-ho added a commit to derek-ho/security-dashboards-plugin that referenced this pull request Apr 26, 2024
…nsearch-project#1888)

Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Derek Ho <[email protected]>
Co-authored-by: Darshit Chanpura <[email protected]>
Co-authored-by: Darshit Chanpura <[email protected]>
(cherry picked from commit 154a3ba)
Signed-off-by: Derek Ho <[email protected]>
@peternied peternied deleted the feature/supporting-multiple-datasources branch April 26, 2024 18:29
peternied pushed a commit that referenced this pull request Apr 26, 2024
…rds Plugin (#1888) (#1911)

Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Derek Ho <[email protected]>
Co-authored-by: Darshit Chanpura <[email protected]>
Co-authored-by: Darshit Chanpura <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x backport to 2.x branch v2.14.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[META] Multiple Datasources Support for Security Dashboards Plugin
6 participants