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

Modified TESTING instructions to clarify use of testing classes #1930

Merged

Conversation

davidlago
Copy link

Signed-off-by: Dave Lago davelago@amazon.com

Description

Updated testing guide to clarify guidance on when to use the different testing classes. This PR is intended to be a vehicle for discussion as this will become the guidance for new tests.

Issues Resolved

N/A

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • 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.

@davidlago davidlago requested a review from a team as a code owner January 18, 2022 17:46
@opensearch-ci-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@dblock
Copy link
Member

dblock commented Jan 18, 2022

The stuff in doc-tools should not be checked in. I think it's missing a .gitignore too.

@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Check success 2343307b061a3ef0ede99bcb2889207eb4d532c9
Log 1966

Reports 1966

@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Check success 42280bc2b878845d84b237d31bb3d37bdb8f029c
Log 1967

Reports 1967

Signed-off-by: Dave Lago <davelago@amazon.com>
@davidlago davidlago force-pushed the change-testing-recommendations branch from 42280bc to 6bf9713 Compare January 18, 2022 18:45
@davidlago
Copy link
Author

Fixed! Completely missed those when creating the commit.

@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Check success 6bf9713
Log 1969

Reports 1969

@@ -421,9 +421,11 @@ Unit tests are the preferred way to test some functionality: most of the time th

The reason why `OpenSearchSingleNodeTestCase` exists is that all our components used to be very hard to set up in isolation, which had led us to having a number of integration tests but close to no unit tests. `OpenSearchSingleNodeTestCase` is a workaround for this issue which provides an easy way to spin up a node and get access to components that are hard to instantiate like `IndicesService`. Whenever practical, you should prefer unit tests.

Many tests extend `OpenSearchIntegTestCase`, mostly because this is how most tests used to work in the early days of Elasticsearch. However, the complexity of these tests tends to make them hard to debug. Whenever the functionality that is being tested isn’t intimately dependent on how OpenSearch behaves as a cluster, it is recommended to write unit tests or REST tests instead.
Finally, if the the functionality under test needs to be run in a cluster, there are two test classes to consider:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we retain language that communicates how integ tests are very costly and should only be used when cluster testing is unavoidable?

We really want to keep the number of integ tests minimal so check can complete in a "reasonable" time. Long running tests should be marked for nightly only.

Copy link
Author

Choose a reason for hiding this comment

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

the language is still there in some way in the next paragraph (In short, most new functionality should come with unit tests, and optionally integration tests using either an external cluster or a local one if there's a need for more specific cluster configurations) but perhaps we can make a mention of cost there to emphasize the point... let me update.

Signed-off-by: Dave Lago <davelago@amazon.com>
@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Check success 6150306
Log 1971

Reports 1971

@peternied
Copy link
Member

@dreamer-89 here is the pull request I mentioned about test guidance updates. If you have further questions or considerations for your scenarios these are passionate folks and this part of the documentation would be good places to start.

Copy link
Collaborator

@nknize nknize left a comment

Choose a reason for hiding this comment

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

LGTM! Thx!

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.

5 participants