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

[BUG-1402] Return HTTP 409 on version confict when creating & updating tenants - added relevant unit test #3580

Conversation

prabhask5
Copy link
Contributor

@prabhask5 prabhask5 commented Oct 20, 2023

Description

Added new TenantsActionApiTest file to put api unit tests for the /api/tenants api call- additionally wrote new unit test to test for parallel PUT /tenant/{name} calls, that they successfully return a 409 call and retry the call.

  • Category (Enhancement, New feature, Bug fix, Test fix, Refactoring, Maintenance, Documentation)
    Test fix

  • Why these changes are required?
    There was no test that checked for the behavior mentioned in the linked ticket, so previously we didn't know if the issue still existed or not (it apparently was fixed before), to make sure this doesn't happen again for this particular case, I decided to write a concrete test for it.

  • What is the old behavior before changes and new behavior after changes?
    Test was added, there's no behavior change?

Issues Resolved

Testing

Added new tenant action unit test to test parallel tenant api calls.

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.

@prabhask5
Copy link
Contributor Author

@cwperks This PR was created to address the comment you left under #1402

@peternied
Copy link
Member

@prabhask5 Thanks for the contribution of the test - much appreciated! I've left feedback please address and let me know and I'll take another look.

@prabhask5
Copy link
Contributor Author

@peternied Alright I refactored the added test to test only two parallel requests and I'm getting a consistent one 409 and one 201 codes, which should be good. The only thing that changes from test run to test run is which request is the "conflict" one, but I think I account for this when checking the description with the get request. Let me know if you need me to make any other changes! TY!

@codecov
Copy link

codecov bot commented Oct 25, 2023

Codecov Report

Merging #3580 (3b3cf82) into main (905c97d) will increase coverage by 63.14%.
The diff coverage is n/a.

❗ Current head 3b3cf82 differs from pull request most recent head 6791c7a. Consider uploading reports for the commit 6791c7a to get more accurate results

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #3580       +/-   ##
===========================================
+ Coverage        0   63.14%   +63.14%     
- Complexity      0     3561     +3561     
===========================================
  Files           0      284      +284     
  Lines           0    20618    +20618     
  Branches        0     3390     +3390     
===========================================
+ Hits            0    13019    +13019     
- Misses          0     5923     +5923     
- Partials        0     1676     +1676     

see 284 files with indirect coverage changes

Copy link
Member

@DarshitChanpura DarshitChanpura left a comment

Choose a reason for hiding this comment

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

Thank you for adding this test @prabhask5.

@peternied
Copy link
Member

Async tests are on my mind today, see this PR [1] for an example of how I've implemented async tests + validation. Those utilities might be useful, feel free to merge my branch onto this change if it helps your development.

@stephen-crawford stephen-crawford self-requested a review October 26, 2023 13:15
@prabhask5 prabhask5 requested a review from peternied October 28, 2023 02:39
@prabhask5
Copy link
Contributor Author

I restructured the test using streams and the AsyncActions.java file from #3601 - let me know of other changes, ty!

@DarshitChanpura
Copy link
Member

We can wait until #3601 merge to ensure any conflicts are resolved.

Copy link
Member

@DarshitChanpura DarshitChanpura left a comment

Choose a reason for hiding this comment

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

Ty for adding the test @prabhask5.

@peternied
Copy link
Member

@prabhask5 please take a look at the test failures, I'm going to hold off on another review until those are passing. Please let us know if you need help with an issue.

@davidlago
Copy link

@prabhask5 if you are not ready to continue work on this PR, we can go ahead and close it, and re-open at a later time. Please let us know!

@prabhask5
Copy link
Contributor Author

@prabhask5 please take a look at the test failures, I'm going to hold off on another review until those are passing. Please let us know if you need help with an issue.

@peternied The errors that I was getting in the test were related to java not being able to find import org.opensearch.test.framework.AsyncActions; when it does exist (which is used in your PR as well), I merged main into this PR to try to solve this error, but if it does not fix it, do you have any fixes going forward?

@peternied
Copy link
Member

@prabhask5 Checkout this guide [1] on rebasing it might help you get unblocked.

Signed-off-by: Prabhas Kurapati <[email protected]>
Signed-off-by: Prabhas Kurapati <[email protected]>
Signed-off-by: Prabhas Kurapati <[email protected]>
@prabhask5 prabhask5 force-pushed the pk-add-parallel-tenant-creation-test branch from 3d3c6d5 to 6791c7a Compare November 8, 2023 22:54
@prabhask5
Copy link
Contributor Author

@peternied I think I rebased so feel free to unblock the tests. TY!

@prabhask5
Copy link
Contributor Author

I'm going to make a new PR to see if that fixes things.

@prabhask5 prabhask5 closed this Nov 9, 2023
@prabhask5 prabhask5 deleted the pk-add-parallel-tenant-creation-test branch November 9, 2023 08:40
@peternied
Copy link
Member

@prabhask5 Could you link the new PR?

@prabhask5
Copy link
Contributor Author

@prabhask5 Could you link the new PR?

Here: #3673

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants