-
Notifications
You must be signed in to change notification settings - Fork 1.5k
JAVA-5771 Add search integration tests #1616
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
Changes from 2 commits
a6e18f9
ec4a8e4
49c80c1
24d7d1e
b6d89a0
facee04
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,6 @@ echo "Running Atlas Search tests" | |
./gradlew --stacktrace --info \ | ||
-Dorg.mongodb.test.atlas.search=true \ | ||
-Dorg.mongodb.test.uri=${MONGODB_URI} \ | ||
driver-core:test --tests AggregatesSearchIntegrationTest --tests AggregatesVectorSearchIntegrationTest | ||
driver-core:test --tests AggregatesSearchIntegrationTest \ | ||
--tests AggregatesBinaryVectorSearchIntegrationTest \ | ||
--tests AggregatesSearchTest \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixes the missing |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,27 +20,24 @@ | |
import com.mongodb.annotations.Sealed; | ||
import com.mongodb.client.model.Aggregates; | ||
import com.mongodb.client.model.geojson.Point; | ||
|
||
import java.util.UUID; | ||
|
||
import org.bson.BsonBinary; | ||
import org.bson.BsonNull; | ||
import org.bson.BsonDocument; | ||
import org.bson.BsonNull; | ||
import org.bson.BsonType; | ||
import org.bson.Document; | ||
import org.bson.conversions.Bson; | ||
import org.bson.types.ObjectId; | ||
|
||
import java.time.Duration; | ||
import java.time.Instant; | ||
import java.util.Iterator; | ||
|
||
import org.bson.types.ObjectId; | ||
import java.util.UUID; | ||
|
||
import static com.mongodb.assertions.Assertions.isTrueArgument; | ||
import static com.mongodb.assertions.Assertions.notNull; | ||
import static com.mongodb.internal.Iterables.concat; | ||
import static com.mongodb.internal.client.model.Util.combineToBsonValue; | ||
import static java.util.Collections.singleton; | ||
import static com.mongodb.assertions.Assertions.notNull; | ||
|
||
/** | ||
* The core part of the {@link Aggregates#search(SearchOperator, SearchOptions) $search} pipeline stage of an aggregation pipeline. | ||
|
@@ -463,14 +460,15 @@ static PhraseSearchOperator phrase(final Iterable<? extends SearchPath> paths, f | |
} | ||
|
||
/** | ||
* Returns a {@link SearchOperator} that performs a search using a special characters in the search string that can match any character. | ||
* Returns a {@link SearchOperator} that performs a search using a special | ||
* characters in the search string that can match any character. | ||
* | ||
* @param path The indexed field to be searched. | ||
* @param query The string to search for. | ||
* @param path The indexed field to be searched. | ||
* @return The requested {@link SearchOperator}. | ||
* @mongodb.atlas.manual atlas-search/wildcard/ wildcard operator | ||
*/ | ||
static WildcardSearchOperator wildcard(final String query, final SearchPath path) { | ||
static WildcardSearchOperator wildcard(final SearchPath path, final String query) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Parameter order is inconsistent. I refactored this (in a separate commit) to match at least regex, but this is already inconsistent in the API. I left a comment on the JIRA for revisiting the API. |
||
return wildcard(singleton(notNull("query", query)), singleton(notNull("path", path))); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,6 +121,9 @@ | |
import static org.junit.jupiter.params.provider.Arguments.arguments; | ||
|
||
/** | ||
* Use this class when needing to test against MFLIX specifically. Otherwise, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nit] It might be more noticeable if placed right above |
||
* see AggregatesSearchTest. | ||
* <p> | ||
* These tests require the <a href="https://www.mongodb.com/docs/atlas/sample-data/">sample data</a> | ||
* and the following Atlas Search indices: | ||
* <table> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,11 +16,8 @@ | |
|
||
package com.mongodb.client; | ||
|
||
import com.mongodb.MongoNamespace; | ||
import com.mongodb.client.test.CollectionHelper; | ||
import com.mongodb.internal.connection.ServerHelper; | ||
import org.bson.BsonDocument; | ||
import org.bson.BsonDocumentWrapper; | ||
import org.bson.Document; | ||
import org.bson.codecs.DocumentCodec; | ||
import org.junit.jupiter.api.AfterEach; | ||
|
@@ -40,7 +37,7 @@ public class DatabaseTestCase { | |
|
||
@BeforeEach | ||
public void setUp() { | ||
client = getMongoClient(); | ||
client = getMongoClient(); | ||
database = client.getDatabase(getDefaultDatabaseName()); | ||
collection = database.getCollection(getClass().getName()); | ||
collection.drop(); | ||
|
@@ -58,23 +55,7 @@ public void tearDown() { | |
} | ||
} | ||
|
||
protected String getDatabaseName() { | ||
return database.getName(); | ||
} | ||
|
||
protected String getCollectionName() { | ||
return collection.getNamespace().getCollectionName(); | ||
} | ||
|
||
protected MongoNamespace getNamespace() { | ||
return collection.getNamespace(); | ||
} | ||
|
||
protected CollectionHelper<Document> getCollectionHelper() { | ||
return new CollectionHelper<>(new DocumentCodec(), getNamespace()); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Above removals are old (several years) dead code. |
||
|
||
protected BsonDocument wrap(final Document document) { | ||
return new BsonDocumentWrapper<>(document, new DocumentCodec()); | ||
return new CollectionHelper<>(new DocumentCodec(), collection.getNamespace()); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the renaming "
Atlas Search Index Management Tests"
to"Atlas Search Tests"
, we will have two variants with the same nameAtlas Search test
and theseAtlas Search Tests
. The only way to differentiate them would be by checking the tasks in Evergreen.To make the distinction clearer at a glance, i think we should use more explicit naming. I suggest either keeping the previous name or renaming them as:
Atlas Search Test [Static Dev Cluster] – for the test using a pre-existing, always-running cluster.
Atlas Search Tests [Dynamic Cluster] – for the test that provisions a cluster, runs tests, and shuts it down.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have merged these into one "Atlas Tests" variant, and have cleaned up related evg config. The data lake test remains on
ubuntu2004-small
; IIRC this is to ensure docker is available.There is a failure in
test-aws-lambda-deployed
, however this predates this PR. When I ran it on0e256548e6
, see patch, it failed, though it passed on that commit previously - looks like an environment change.