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 <dchanp@amazon.com>
Signed-off-by: Derek Ho <dxho@amazon.com>
Co-authored-by: Darshit Chanpura <dchanp@amazon.com>
* Add multi datasource support for internal users tab

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

* Add test coverage for front end and backend

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

* Push cypress test for users

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

* Remove extra click

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

* Consume changes in core

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

* Don't rely on public export for type

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

* Consume list changes, fix cypress test unskips auth test

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

* Fix cypress test

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

* Fix test

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

* Test fix

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

* Add timeout as well

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

* Try different way to select the option

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

* Fix test

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

* Use data test subj for more consistency

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

---------

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

Signed-off-by: Derek Ho <dxho@amazon.com>
* Adds datasource picker to Permissions tab

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Finalizes changes for Permissions tab dataSource picker

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Fixes Unit tests

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Adds integration tests

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Adds cypress test for Permission tab with remote data source

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

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

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Updates unit tests and reverts a change in cypress test

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Addresses nits to make tests more robust

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Fixes unit tests

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

---------

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
* Add multi datasource support for the tenanct and audit log tabs

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

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

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

* Add cypress test support for tenancy and audit log

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

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

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

---------

Signed-off-by: Derek Ho <dxho@amazon.com>
* Adds datasource picker for Roles tab and its sub-tabs

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Fixes jest:ui task

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Adds integration test for roles datasource picker

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Adds cypress test for roles tab

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* fixFix ResizeObserver loop error

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Makes query param required

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

---------

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
* Add selector on service accounts page

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

* Lint

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

* Fix test for service accounts

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

---------

Signed-off-by: Derek Ho <dxho@amazon.com>
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
* Add cluster info to toasts

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

* Add URL support

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

* Initial work to read/write from url

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

* Consume changes from core

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

* Lint and remove unused imports

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

* Fix edge case and test

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

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

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Try in headless mode

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

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

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

* Try experimental memory management

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

* Try to fix closeToast

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

* Fix for close toast

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

* Find by warning

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

* Fix by warning

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

* Fix tenancy test from main

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

* Fix auth test and be explicit about local datasource

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

* Test fixes

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

* Fix role flaky test

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

* Nit

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

* Makes github cypress run headless

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Enabled experimentalMemoryManagement for chromium based cypress tests

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

---------

Signed-off-by: Derek Ho <dxho@amazon.com>
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Co-authored-by: Darshit Chanpura <dchanp@amazon.com>
…rds-plugin into HEAD

Signed-off-by: Derek Ho <dxho@amazon.com>
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.

Signed-off-by: Derek Ho <dxho@amazon.com>
@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?

* Fix some state issues and try to use electron browser

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

* Try modifying numtestskeptinmemory

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

* Remove closetoast

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

* Fix flaky cypress test

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

* Run 10x

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

* Fix test

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

* Fix permissions test

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

* Move management to correct section

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

* Push up fixes for audit logs and roles

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

* Remove local cluster checks to cut length and increase stability

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

* Improves before and after handling

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Temporarily disable permissions and roles tests

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* adds delete datasource call to beforeEach

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Unskip permissions test

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Absorb changes from core

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Fixes tests

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Skips legacy browser warning

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Refactor audit logs tests

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Force page reload post creation

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Unskip auth and roles, and skip audit logs

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Skip roles tab

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Changes data source url

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Fix lint issues

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Chrome

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

* Skip users and permissions tab

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

* Revert cypress settings

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

* Modify test to make cypress request instead of UI

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

* Lint

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

* Add fix for get started and rewrite users test

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

* use tostring to be more consistent with the actual behavior

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

* Try to fix flaky tests

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

* Revert to beforeeach and aftereach

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

* Fix test

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

* Fix lint

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

* Fix roles and enable

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

* Adds retry mechanism to cypress tests

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Increases retries to 5

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

* Reverts CI runs to 1

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>

---------

Signed-off-by: Derek Ho <dxho@amazon.com>
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Co-authored-by: Derek Ho <dxho@amazon.com>
@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 <dxho@amazon.com>
@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
Signed-off-by: Derek Ho <dxho@amazon.com>
@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 <dxho@amazon.com>
@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 <dchanp@amazon.com>
Signed-off-by: Derek Ho <dxho@amazon.com>
Co-authored-by: Darshit Chanpura <dchanp@amazon.com>
Co-authored-by: Darshit Chanpura <35282393+DarshitChanpura@users.noreply.github.com>
(cherry picked from commit 154a3ba)
Signed-off-by: Derek Ho <dxho@amazon.com>
@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 <dchanp@amazon.com>
Signed-off-by: Derek Ho <dxho@amazon.com>
Co-authored-by: Darshit Chanpura <dchanp@amazon.com>
Co-authored-by: Darshit Chanpura <35282393+DarshitChanpura@users.noreply.github.com>
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