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

Speeding up tests #1715

Merged
merged 1 commit into from
Mar 30, 2022
Merged

Conversation

peternied
Copy link
Member

Description

Sleep statements should rarely be used, instead apis should allow for
blocking/non-blocking calling patterns. Attempting to remove and clean
up these statements to speed up PR workflows.

Github Action workflows for this repo were 75+ minutes, with this change 40 minutes. 47% reduction in time.

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.

Sleep statements should rarely be used, instead apis should allow for
blocking/non-blocking calling patterns.  Attempting to remove and clean
up these statements to speed up PR workflows.

Signed-off-by: Peter Nied <[email protected]>
@peternied peternied requested a review from a team March 29, 2022 22:33
@peternied peternied self-assigned this Mar 29, 2022
@peternied peternied added the enhancement New feature or request label Mar 29, 2022
@codecov-commenter
Copy link

Codecov Report

Merging #1715 (97c1bae) into main (51e492c) will increase coverage by 0.00%.
The diff coverage is n/a.

@@            Coverage Diff            @@
##               main    #1715   +/-   ##
=========================================
  Coverage     62.86%   62.87%           
- Complexity     3262     3264    +2     
=========================================
  Files           253      253           
  Lines         18089    18096    +7     
  Branches       3243     3246    +3     
=========================================
+ Hits          11372    11377    +5     
- Misses         5063     5064    +1     
- Partials       1654     1655    +1     
Impacted Files Coverage Δ
.../dlic/auth/ldap2/LDAPConnectionFactoryFactory.java 56.48% <0.00%> (-1.53%) ⬇️
...search/security/configuration/DlsFlsValveImpl.java 59.25% <0.00%> (+1.08%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 51e492c...97c1bae. Read the comment docs.

@cliu123
Copy link
Member

cliu123 commented Mar 30, 2022

The sleep was introduced by the removal of TransportClient PR. The intent is to make sure all configurations are loaded into security index, which used to be done as following. Sleep is not the best idea and doesn't really ensure that. Is there a better/faster way to ensure the existense of the configurations?

            Assert.assertTrue(tc.get(new GetRequest(".opendistro_security", type, "config")).actionGet().isExists());
            Assert.assertTrue(tc.get(new GetRequest(".opendistro_security", type,"internalusers")).actionGet().isExists());
            Assert.assertTrue(tc.get(new GetRequest(".opendistro_security", type,"roles")).actionGet().isExists());
            Assert.assertTrue(tc.get(new GetRequest(".opendistro_security", type,"rolesmapping")).actionGet().isExists());
            Assert.assertTrue(tc.get(new GetRequest(".opendistro_security", type,"actiongroups")).actionGet().isExists());
            Assert.assertFalse(tc.get(new GetRequest(".opendistro_security", type,"rolesmapping_xcvdnghtu165759i99465")).actionGet().isExists());
            Assert.assertTrue(tc.get(new GetRequest(".opendistro_security", type,"config")).actionGet().isExists());
            if (indexRequests.stream().anyMatch(i -> CType.NODESDN.toLCString().equals(i.id()))) {
                Assert.assertTrue(tc.get(new GetRequest(".opendistro_security", type,"nodesdn")).actionGet().isExists());

@cliu123
Copy link
Member

cliu123 commented Mar 30, 2022

Long running CI is a huge pain of security plugin. This is a nice area to improve! Great contribution! 👍

@peternied peternied merged commit ebdaaaa into opensearch-project:main Mar 30, 2022
@peternied peternied deleted the no-sleep-base branch March 30, 2022 17:48
@peternied
Copy link
Member Author

First when I noticed and removed this sleep I had the same concern about stability. In the test setup OpenSearch nodes are created on a couple of threads, these communicate via http. From what I've seen when our tests cases are running, we are making calls via http which is out of process communication.

When moving across the process boundary layer to the network the jvm stops processing work on the test thread and can resume work on any other busy node threads. This boundary layer means a busy cpu operation is very likely to complete on the nodes within that same process before the network connection of the test's inbound request is processed.

This is not reliable protection on a production system; however, this seems to be working well with our JVM selections and our different environments. We might notice issues in the future - I imagine certain classes of tests might need additional checks, but we can deal with them as they present themselves.

Is there a better/faster way to ensure the existence of the configurations?

In OpenSearch there is a task api that can be used to track work that is in progress or complete. If we needed additional assurance that the configuration was complete, I would advocate for a way to get the task id associated with this so we can use GET _tasks/<task_id>?wait_for_completion=true to ensure that work has finished making sure the system is stable.

Alternatively we could add into those nodes that would give us an in-process signaling channel such as Object.wait(...) with a plugin that is designed to make this information available.

wuychn pushed a commit to ochprince/security that referenced this pull request Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants