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

Improve the stability of SAML integ test #1237

Merged
merged 4 commits into from
Dec 14, 2022

Conversation

RyanL1997
Copy link
Collaborator

Signed-off-by: Ryan Liang [email protected]

Description

Fix the stability of SAML integ test

Category

Enhancement

Issues Resolved

Testing

[Please provide details of testing done: unit testing, integration testing and manual testing]

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.

@RyanL1997 RyanL1997 requested a review from a team December 2, 2022 21:03
@RyanL1997 RyanL1997 added the backport 2.x backport to 2.x branch label Dec 2, 2022
Copy link
Member

@peternied peternied left a comment

Choose a reason for hiding this comment

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

Could you provide more details as to why the driver.findElement(...) path didn't work out? It seems like if we can't verify this scenario from the UX something is wrong with the product

@@ -326,12 +326,14 @@ describe('start OpenSearch Dashboards server', () => {

await driver.wait(until.elementsLocated(By.xpath(tenantNameLabelXPath)), 10000);

const tenantName = await driver.findElement(By.xpath(tenantNameLabelXPath)).getText();
const localStorageItem = await driver.executeScript(
Copy link
Member

Choose a reason for hiding this comment

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

Know why the text wasn't loading? These test are suppose to make sure the UX is rendering the correct content, and this change effectively works around inspecting the UI - this is a major hit to the functionality of the test to use the localstorage state.

Copy link
Collaborator Author

@RyanL1997 RyanL1997 Dec 3, 2022

Choose a reason for hiding this comment

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

Hi @peternied, thanks for the review! I totally agree that we should test out the actual UI elements. However, according to the experiments @cwperks and I did on my local machine, it is not about the loading of that UI elements. It is something about the selenium webdriver, and I have also tried out different webdrivers such as chromedriver and they all have a very high chance for not go through the second window.reload() for updating the saved tenant according to the localstorage key. So there is nothing we can do about the webdriver for now :(

However, I'm willing to figure out a work around as an another approach if it is necessary.

Copy link
Member

@cwperks cwperks Dec 5, 2022

Choose a reason for hiding this comment

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

@RyanL1997 I was just looking at the requests that happen after login and I believe what we can do is wait for a response from http://<osd_baseurl>/api/v1/multitenancy/tenant before clicking on the user dropdown and viewing the tenant info. This endpoint is called after login to get the current tenant info from what I can see.

Copy link
Member

Choose a reason for hiding this comment

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

With playwright its possible to do a page.waitForResponse(urlOrPredicate... , but I'm not sure if selenium has something similar.

https://playwright.dev/docs/api/class-page#page-wait-for-response

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we can dig into this a little more to see what the test should do verses what is hard to do, Quickly reading the test:

  1. Go to the overview page
  2. Sign in (Not as clear how this is actually done in the test...)
  3. Select the global tenant, confirm
  4. Sign out
  5. Sign back in
  6. Skip the popup-ux
  7. Wait until the tenant label appears and show Global

Seems like knowing we are on the global tenant is a critical part of the test

Can we find an element that is blank until the tenant query has resolved? We could add an element with an ID that would be easy to find and wait for it to disappear when the tenant has loaded if that is part of the problem.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@peternied Thanks for this info. The problem we are having right now is not about the loading of the UI. We are can load and locate this UI. However, it just doesn't switch to the expected tenant (It sometimes stays as "private" [1]). For now, I am trying to implement a retry for this scenario, and I am also taking a look into @cwperks 's suggestion to see how much effort will it take us to switch to another test frame work.

Reference:
[1]:
Screenshot 2022-12-05 at 1 47 07 PM

Copy link
Member

Choose a reason for hiding this comment

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

However, it just doesn't switch to the expected tenant (It sometimes stays as "private" [1])

This sounds like a product bug?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don think so, because, based on the experiment I did so far, it wont happen to the regular browser, and it is just the webdriver we are using got a high chance to not reload the window for updating tenant information according to the local storage.

Copy link
Member

Choose a reason for hiding this comment

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

@RyanL1997 Another thought, maybe its possible to use until.elementTextIs(element, text)?

https://www.selenium.dev/selenium/docs/api/javascript/module/selenium-webdriver/lib/until.html

@peternied
Copy link
Member

Any updates for this PR, or anything we can help with?

@RyanL1997
Copy link
Collaborator Author

Any updates for this PR, or anything we can help with?

Hi @peternied I was working with @scrawfor99 for the windows support for CI. This one I may need the help from @anijain-Amazon . Since he is the author of the original SAML integ test.

@RyanL1997 RyanL1997 force-pushed the fix-saml-stability branch 2 times, most recently from d60060e to 920df4f Compare December 9, 2022 17:33
@codecov-commenter
Copy link

codecov-commenter commented Dec 9, 2022

Codecov Report

Merging #1237 (34b1087) into main (5419567) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main    #1237   +/-   ##
=======================================
  Coverage   71.78%   71.78%           
=======================================
  Files          88       88           
  Lines        2027     2027           
  Branches      269      269           
=======================================
  Hits         1455     1455           
  Misses        509      509           
  Partials       63       63           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@RyanL1997
Copy link
Collaborator Author

I updated this PR with a temporary fix/enhancement by adding another tenant switching and check if it is the scenario that the webdriver doesn't reload to update the tenant info according to local storage. This will do both of improving the stability and testing the actual UI elements.

Copy link
Member

@peternied peternied left a comment

Choose a reason for hiding this comment

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

SMART! I love that while something is busted, this will increase the reliable and remove the pressure while attempting to validate the scenario as well as we can.

@RyanL1997 RyanL1997 changed the title Fix the stability of SAML integ test Improve the stability of SAML integ test Dec 9, 2022
@DarshitChanpura
Copy link
Member

DarshitChanpura commented Dec 12, 2022

@RyanL1997 Looks like both CI checks failed due to same reason: jarHell. Can you look into it and let us know if you need any help?. I see that there is a tracking issue here: opensearch-project/OpenSearch#5526

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.

Nice workaround and for persisting through this issue! It looks like this is an issue with the headless browser and not with the actual code for switching to a tenant based on the value in local storage.

@RyanL1997 RyanL1997 merged commit 7ffbf09 into opensearch-project:main Dec 14, 2022
opensearch-trigger-bot bot pushed a commit that referenced this pull request Dec 14, 2022
Signed-off-by: Ryan Liang <[email protected]>
(cherry picked from commit 7ffbf09)
DarshitChanpura pushed a commit that referenced this pull request Dec 15, 2022
Signed-off-by: Ryan Liang <[email protected]>
(cherry picked from commit 7ffbf09)

Co-authored-by: Ryan Liang <[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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants