Skip to content

Simplify test assumptions for 4.2 minimum server support #1712

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

Merged
merged 7 commits into from
May 19, 2025

Conversation

jyemin
Copy link
Collaborator

@jyemin jyemin commented May 13, 2025

  • Remove test skips that are always false. There are old ones going back years, where we specify that tests should be skipped on, say, MongoDB 3.2 or earlier
  • Remove tests that never run anymore. Same as above, these go back years, not just due to the recent removal of 4.0 from test suite
  • Simplify test skips by removing conditionals that are always false.
  • Simplify test bodies by removing dead conditionals.

@jyemin jyemin force-pushed the test-simplifications branch from 9871a01 to a69b55e Compare May 13, 2025 12:22
@jyemin jyemin force-pushed the test-simplifications branch from a69b55e to d62c954 Compare May 13, 2025 13:51
@jyemin jyemin self-assigned this May 15, 2025
@jyemin jyemin marked this pull request as ready for review May 15, 2025 14:42
@jyemin jyemin requested a review from rozza May 15, 2025 14:42
@@ -340,13 +333,13 @@ class AggregateOperationSpecification extends OperationFunctionalSpecification {
BsonDocument explainPlan = execute(operation.asExplainableOperation(QUERY_PLANNER, new BsonDocumentCodec()), async)

then:
getKeyPattern(explainPlan.getArray('stages').get(0).asDocument().getDocument('$cursor')) == index
getKeyPattern(explainPlan) == index
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This change allows the test to pass on 4.2+ so long as it's not sharded.

@alcaeus alcaeus requested a review from Copilot May 16, 2025 15:03
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR simplifies test assumptions in preparation for a 4.2+ minimum server support by removing outdated server version checks and dead conditionals in the test suite. Key changes include eliminating skip conditions that reference obsolete server versions, simplifying branching logic in test assertions, and streamlining test annotations.

Reviewed Changes

Copilot reviewed 52 out of 52 changed files in this pull request and generated no comments.

Show a summary per file
File Description
driver-core/src/test/functional/com/mongodb/internal/operation/FindOperationSpecification.groovy Removed outdated server version based skip for hint tests.
driver-core/src/test/functional/com/mongodb/internal/operation/FindAndUpdateOperationSpecification.groovy Simplified skip conditions by removing server version checks that are now redundant.
driver-core/src/test/functional/com/mongodb/internal/operation/FindAndReplaceOperationSpecification.groovy Removed conditions that are no longer relevant with new server support assumptions.
driver-core/src/test/functional/com/mongodb/internal/operation/FindAndDeleteOperationSpecification.groovy Streamlined skip conditions to only check replica set availability.
driver-core/src/test/functional/com/mongodb/internal/operation/DropDatabaseOperationSpecification.groovy Removed legacy server version logic in write concern error tests.
driver-core/src/test/functional/com/mongodb/internal/operation/DropCollectionOperationSpecification.groovy Updated skip conditions for write concern error tests by only checking server replica set status.
driver-core/src/test/functional/com/mongodb/internal/operation/DistinctOperationSpecification.groovy Removed skip conditions for collation tests no longer relevant under minimum criteria.
driver-core/src/test/functional/com/mongodb/internal/operation/CreateViewOperationSpecification.groovy Removed tests based solely on outdated server version checks.
driver-core/src/test/functional/com/mongodb/internal/operation/CreateIndexesOperationSpecification.groovy Removed legacy conditions and simplified index creation tests.
driver-core/src/test/functional/com/mongodb/internal/operation/CreateCollectionOperationSpecification.groovy Streamlined storage engine options tests by removing redundant conditionals.
driver-core/src/test/functional/com/mongodb/internal/operation/CountDocumentsOperationSpecification.groovy Removed conditional assumptions tied to outdated server versions.
driver-core/src/test/functional/com/mongodb/internal/operation/ChangeStreamOperationSpecification.groovy Removed skip conditions now rendered obsolete by the new server support level.
driver-core/src/test/functional/com/mongodb/internal/operation/ChangeStreamOperationProseTestSpecification.groovy Simplified skip conditions to only verify replica set availability.
driver-core/src/test/functional/com/mongodb/internal/operation/AggregateToCollectionOperationSpecification.groovy Removed several skip conditions related to server versions lower than minimum support.
driver-core/src/test/functional/com/mongodb/internal/operation/AggregateOperationSpecification.groovy Simplified aggregation tests by removing legacy server version requirements.
driver-core/src/test/functional/com/mongodb/internal/connection/ScramSha256AuthenticationSpecification.groovy Updated authentication tests by removing obsolete version checks.
driver-core/src/test/functional/com/mongodb/client/model/mql/TypeMqlValuesFunctionalTest.java Removed conditional assumptions based on server version for mql value tests.
driver-core/src/test/functional/com/mongodb/client/model/FiltersFunctionalSpecification.groovy Removed outdated version-based skip annotations for filter rendering tests.
driver-core/src/test/functional/com/mongodb/client/model/AggregatesFunctionalSpecification.groovy Removed multiple skip conditions to reflect the new minimum supported server version.
Comments suppressed due to low confidence (2)

driver-core/src/test/functional/com/mongodb/internal/operation/DropDatabaseOperationSpecification.groovy:72

  • The conditional assignment based on server version was removed in favor of a constant value of 2. Please confirm that using a fixed write concern value meets the intended test assumptions for all supported server versions.
def w = 2

driver-core/src/test/functional/com/mongodb/internal/connection/ScramSha256AuthenticationSpecification.groovy:45

  • The removal of the server version check simplifies the annotation given the new minimum support, but please verify that this change does not inadvertently enable tests on unsupported server versions.
@IgnoreIf({ (!isAuthenticated()) })

Copy link

@adrian-yemin adrian-yemin left a comment

Choose a reason for hiding this comment

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

Just undelete the two tests I commented and only change their corresponding IgnoreIf statements

@jyemin jyemin requested review from adrian-yemin and Copilot May 17, 2025 01:24
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR cleans up test code by removing obsolete server version checks and related skips now that MongoDB 4.2 is the minimum supported server, and by deleting dead conditionals and unused imports.

  • Removed serverVersionLessThan/serverVersionAtLeast imports and always‐false skips
  • Simplified @IgnoreIf annotations to only check clustering conditions
  • Deleted stale test methods and comments tied to removed version logic

Reviewed Changes

Copilot reviewed 76 out of 76 changed files in this pull request and generated no comments.

Show a summary per file
File Description
FindAndReplaceOperationSpecification.groovy Removed import and dead @IgnoreIf checks for older server versions
FindAndDeleteOperationSpecification.groovy Simplified ignore conditions, dropped obsolete version import
DropIndexOperationSpecification.groovy Removed legacy version skip and import
DropDatabaseOperationSpecification.groovy Simplified ignore, removed version imports and updated dead fallback logic
DropCollectionOperationSpecification.groovy Deleted version checks and import
DistinctOperationSpecification.groovy Removed version‐based skip and import
CreateViewOperationSpecification.groovy Deleted outdated view‐version test and imports
CreateIndexesOperationSpecification.groovy Stripped obsolete version skips throughout
CreateCollectionOperationSpecification.groovy Removed old‐version skip and import
CountDocumentsOperationSpecification.groovy Cleaned out version hints and imports
ChangeStreamOperationSpecification.groovy Simplified class‐level skip, removed unused version import
ChangeStreamOperationProseTestSpecification.groovy Updated skip logic and removed version imports
AggregateToCollectionOperationSpecification.groovy Dropped outdated version checks and imports
AggregateOperationSpecification.groovy Removed version‐based skips and updated imports
ScramSha256AuthenticationSpecification.groovy Cleaned up version skip annotation and import
TypeMqlValuesFunctionalTest.java Deleted JUnit assumeTrue for removed version guard
ArithmeticMqlValuesFunctionalTest.java Removed leftover version assumption calls
FiltersFunctionalSpecification.groovy Stripped version‐based ignores and import
AggregatesTest.java Deleted version assumptions around window fields
AggregatesFunctionalSpecification.groovy Removed numerous obsolete @IgnoreIf blocks
Comments suppressed due to low confidence (4)

driver-core/src/test/functional/com/mongodb/internal/operation/DropDatabaseOperationSpecification.groovy:31

  • This static import is no longer used after removing server version checks; please remove it to keep imports tidy.
import static com.mongodb.ClusterFixture.isSharded

driver-core/src/test/functional/com/mongodb/internal/operation/DropDatabaseOperationSpecification.groovy:71

  • The comment refers to removed version logic and no longer matches the code; please update or delete this stale comment to reflect the current behavior.
// On servers older than 4.0 that don't support this failpoint, use a crazy w value instead

driver-core/src/test/functional/com/mongodb/internal/operation/CreateCollectionOperationSpecification.groovy:33

  • After deleting all version‐based conditionals, this import is unused; please remove it.
import static com.mongodb.ClusterFixture.serverVersionLessThan

driver-core/src/test/functional/com/mongodb/internal/operation/ChangeStreamOperationSpecification.groovy:59

  • This import is no longer needed now that all serverVersion-based skips have been removed; please delete it.
import static com.mongodb.ClusterFixture.serverVersionLessThan

Copy link

@adrian-yemin adrian-yemin left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@rozza rozza left a comment

Choose a reason for hiding this comment

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

LGTM!

Only nits: I added a suggestion to remove outdated comments

Co-authored-by: Ross Lawley <ross.lawley@gmail.com>
@jyemin jyemin merged commit 179bac6 into mongodb:main May 19, 2025
50 of 54 checks passed
@jyemin jyemin deleted the test-simplifications branch May 19, 2025 14:53
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.

3 participants