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

Clean up unified tests via skipping API #1551

Merged
merged 5 commits into from
Nov 1, 2024
Merged

Clean up unified tests via skipping API #1551

merged 5 commits into from
Nov 1, 2024

Conversation

katcharov
Copy link
Contributor

This is a lightweight wrapper API for organizing assumptions ("skips") in unified tests. Offers a consistent and clearer mechanism for specifying why tests are being skipped.

* @param skip reason for skipping the test; must start with a Jira URL
*/
public Skip skipJira(final String skip) {
Assertions.assertTrue(skip.startsWith("https://jira.mongodb.org/browse/JAVA-"));
Copy link
Contributor

Choose a reason for hiding this comment

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

Can the skip be due to a DRIVER-XXX ticket? I think checking against https://jira.mongodb.org/browse/ is enough to make sure a valid JIRA link is provided

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I considered this, but I think we need to have something our team is tracking. If a good counterexample comes up, we can remove the constraint at the time?

/**
* Test skipped if the test description contains the fragment as a substring
*/
public Skip testContains(final String dir, final String fragment) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be used carefully as it has the potential risk of skipping new tests matching the fragment...
I accidentally used updateOne with sort option with contains which matched also BulkWrite updateOne with sort option

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will add a note.

I think we should stop it from being used in non-dev, but this will be more work, since existing tests use this pattern.

.file("server-discovery-and-monitoring", "connect with serverMonitoringMode=stream >=4.4");

def.skipJira("https://jira.mongodb.org/browse/JAVA-4770")
.file("server-discovery-and-monitoring", "standalone-logging")
Copy link
Contributor

@nhachicha nhachicha Oct 31, 2024

Choose a reason for hiding this comment

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

The standalone-logging here is the description of the test(s) https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/tests/unified/logging-standalone.json#L2 and not the JSON file name. The method defines the second parameter as the file https://github.com/mongodb/mongo-java-driver/pull/1551/files#diff-c703183de18b785f0df010e4d1dc57464f07946ae7e350533c507d4232801374R85

I was under the impression that If one wants to exclude all tests under logging-standalone.json I could call

def.skipJira("https://jira.mongodb.org/browse/JAVA-4770")
                .file("server-discovery-and-monitoring", "logging-standalone") 
// logging-standalone is the name of JSON file 
// standalone-logging is the top description of all tests under  logging-standalone.json 

In contrary in https://github.com/mongodb/mongo-java-driver/pull/1551/files#diff-20c83c94232058f9e9a6b35b2c2825e600f5dba0cbc5a4c64bfd0aa78053cd28R46
serverMonitoringMode is the actual JSON file name (which also matches its description)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Having the description used as an identifier is unfortunate. Probably tests should have an id field that matches their file name.

Added param docs.

/**
* Test skipped if the test description contains the fragment as a substring
*/
public Skip testContains(final String dir, final String fragment) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a use case where we want to filter by dir and test description as well? Thinking whether we should add an optional testDef.file parameter to the method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's add it if we run into it (hopefully we don't, since as you say the contains methods seem risky).

@katcharov katcharov requested a review from nhachicha November 1, 2024 13:38
Copy link
Contributor

@nhachicha nhachicha left a comment

Choose a reason for hiding this comment

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

Nice 👍

@katcharov katcharov merged commit 1725e65 into main Nov 1, 2024
55 of 60 checks passed
@katcharov katcharov deleted the unified-test-skips branch November 1, 2024 15:45
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.

None yet

2 participants