Skip to content

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

Merged
merged 6 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
161 changes: 57 additions & 104 deletions .evergreen/.evg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -509,24 +509,6 @@ functions:
mongo --nodb setup.js aws_e2e_ecs.js
cd -

"run atlas data lake test":
- command: shell.exec
type: test
params:
working_dir: "src"
script: |
${PREPARE_SHELL}
JAVA_VERSION=${JAVA_VERSION} .evergreen/run-atlas-data-lake-test.sh

"run atlas search test":
- command: shell.exec
type: test
params:
working_dir: "src"
script: |
${PREPARE_SHELL}
MONGODB_URI="${atlas_search_uri}" .evergreen/run-atlas-search-tests.sh

"run-ocsp-test":
- command: shell.exec
type: test
Expand Down Expand Up @@ -627,19 +609,6 @@ functions:
${PREPARE_SHELL}
PROJECT_DIRECTORY=${PROJECT_DIRECTORY} JAVA_VERSION=${JAVA_VERSION} TOPOLOGY=${TOPOLOGY} STORAGE_ENGINE=${STORAGE_ENGINE} MONGODB_URI="${MONGODB_URI}" .evergreen/run-mmapv1-storage-test.sh

"run atlas test":
- command: shell.exec
type: test
params:
silent: true
working_dir: "src"
script: |
# DO NOT ECHO WITH XTRACE (which PREPARE_SHELL does)
# The connection strings are pipe-delimited
JAVA_VERSION="8" \
MONGODB_URIS="${atlas_free_tier_uri}|${atlas_replica_set_uri}|${atlas_sharded_uri}|${atlas_tls_v11_uri}|${atlas_tls_v12_uri}|${atlas_free_tier_uri_srv}|${atlas_replica_set_uri_srv}|${atlas_sharded_uri_srv}|${atlas_tls_v11_uri_srv}|${atlas_tls_v12_uri_srv}|${atlas_serverless_uri}|${atlas_serverless_uri_srv}" \
.evergreen/run-connectivity-tests.sh

run socks5 tests:
- command: shell.exec
type: test
Expand Down Expand Up @@ -1462,14 +1431,50 @@ tasks:
OCSP_MUST_STAPLE: "false"
OCSP_TLS_SHOULD_SUCCEED: "0"

- name: "atlas-data-lake-test"
- name: "atlas-data-lake-task"
commands:
- func: "bootstrap mongohoused"
- func: "run atlas data lake test"
- command: shell.exec
type: test
params:
working_dir: "src"
script: |
${PREPARE_SHELL}
JAVA_VERSION=${JAVA_VERSION} .evergreen/run-atlas-data-lake-test.sh

- name: "atlas-search-test"
- name: "atlas-search-task"
commands:
- func: "run atlas search test"
- command: shell.exec
type: test
params:
working_dir: "src"
script: |
${PREPARE_SHELL}
MONGODB_URI="${atlas_search_uri}" .evergreen/run-atlas-search-tests.sh

- name: "atlas-connectivity-task"
commands:
- command: shell.exec
type: test
params:
silent: true
working_dir: "src"
script: |
# DO NOT ECHO WITH XTRACE (which PREPARE_SHELL does)
# The connection strings are pipe-delimited
MONGODB_URIS="${atlas_free_tier_uri}|${atlas_replica_set_uri}|${atlas_sharded_uri}|${atlas_tls_v11_uri}|${atlas_tls_v12_uri}|${atlas_free_tier_uri_srv}|${atlas_replica_set_uri_srv}|${atlas_sharded_uri_srv}|${atlas_tls_v11_uri_srv}|${atlas_tls_v12_uri_srv}|${atlas_serverless_uri}|${atlas_serverless_uri_srv}" \
JAVA_VERSION="8" \
.evergreen/run-connectivity-tests.sh

- name: "atlas-search-index-management-task"
commands:
- command: subprocess.exec
params:
working_dir: src
binary: bash
add_expansions_to_env: true
args:
- .evergreen/run-atlas-search-index-management-tests.sh

- name: "gssapi-auth-test"
commands:
Expand All @@ -1490,20 +1495,6 @@ tasks:
- func: "bootstrap mongo-orchestration"
- func: "run netty tests"

- name: "atlas-test"
commands:
- func: "run atlas test"

- name: "test-atlas-search-index-helpers"
commands:
- command: subprocess.exec
params:
working_dir: src
binary: bash
add_expansions_to_env: true
args:
- .evergreen/run-atlas-search-index-management-tests.sh

- name: publish-snapshot
depends_on:
- variant: "static-checks"
Expand Down Expand Up @@ -1536,7 +1527,7 @@ tasks:
- func: "run perf tests"
- func: "send dashboard data"

- name: "test-aws-lambda-deployed"
- name: "aws-lambda-deployed-task"
commands:
- command: ec2.assume_role
params:
Expand Down Expand Up @@ -1630,7 +1621,6 @@ tasks:
echo "Untarring file ... begin"
GCPKMS_CMD="tar xf mongo-java-driver.tgz" $DRIVERS_TOOLS/.evergreen/csfle/gcpkms/run-command.sh
echo "Untarring file ... end"

- command: shell.exec
type: test
params:
Expand Down Expand Up @@ -1918,11 +1908,12 @@ axes:
batchtime: 10080 # 7 days

task_groups:
- name: test_atlas_task_group_search_indexes
- name: "atlas-deployed-task-group"
setup_group:
- func: fetch source
- func: prepare resources
- command: subprocess.exec
type: setup
params:
working_dir: src
binary: bash
Expand All @@ -1934,6 +1925,7 @@ task_groups:
file: src/atlas-expansion.yml
teardown_group:
- command: subprocess.exec
type: setup
params:
working_dir: src
binary: bash
Expand All @@ -1943,7 +1935,9 @@ task_groups:
setup_group_can_fail_task: true
setup_group_timeout_secs: 1800
tasks:
- test-atlas-search-index-helpers
- "atlas-search-index-management-task"
- "aws-lambda-deployed-task"

- name: testgcpkms_task_group
setup_group_can_fail_task: true
setup_group_timeout_secs: 1800 # 30 minutes
Expand Down Expand Up @@ -1979,6 +1973,7 @@ task_groups:
$DRIVERS_TOOLS/.evergreen/csfle/gcpkms/delete-instance.sh
tasks:
- testgcpkms-task

- name: testazurekms_task_group
setup_group_can_fail_task: true
setup_group_timeout_secs: 1800 # 30 minutes
Expand Down Expand Up @@ -2023,32 +2018,6 @@ task_groups:
$DRIVERS_TOOLS/.evergreen/csfle/azurekms/delete-vm.sh
tasks:
- testazurekms-task
- name: test_atlas_task_group
setup_group:
- func: fetch source
- func: prepare resources
- command: subprocess.exec
params:
working_dir: src
binary: bash
add_expansions_to_env: true
args:
- ${DRIVERS_TOOLS}/.evergreen/atlas/setup-atlas-cluster.sh
- command: expansions.update
params:
file: src/atlas-expansion.yml
teardown_group:
- command: subprocess.exec
params:
working_dir: src
binary: bash
add_expansions_to_env: true
args:
- ${DRIVERS_TOOLS}/.evergreen/atlas/teardown-atlas-cluster.sh
setup_group_can_fail_task: true
setup_group_timeout_secs: 1800
tasks:
- test-aws-lambda-deployed

- name: testoidc_task_group
setup_group:
Expand Down Expand Up @@ -2283,24 +2252,12 @@ buildvariants:
tasks:
- name: "perf"

- name: rhel8-test-atlas
display_name: Atlas Cluster Tests
run_on: rhel80-large
tasks:
- test_atlas_task_group

- name: plain-auth-test
display_name: "PLAIN (LDAP) Auth test"
run_on: rhel80-small
tasks:
- name: "plain-auth-test"

- name: rhel80-test-search-indexes
display_name: Atlas Search Index Management Tests
run_on: rhel80-small
tasks:
- name: "test_atlas_task_group_search_indexes"

- name: "oidc-auth-test"
display_name: "OIDC Auth"
run_on: ubuntu2204-small
Expand Down Expand Up @@ -2355,23 +2312,19 @@ buildvariants:
tasks:
- name: ".ocsp"

- name: atlas-data-lake-test
display_name: "Atlas Data Lake test"
run_on: ubuntu2004-small
tasks:
- name: "atlas-data-lake-test"

- name: atlas-test
display_name: "Atlas test"
- name: "atlas-search-variant"
display_name: "Atlas Tests"
run_on: rhel80-small
tasks:
- name: "atlas-test"
- name: "atlas-deployed-task-group"
- name: "atlas-search-task"
- name: "atlas-connectivity-task"

- name: atlas-search-test
display_name: "Atlas Search test"
run_on: rhel80-small
- name: atlas-data-lake-test
display_name: "Atlas Data Lake test"
run_on: ubuntu2004-small
tasks:
- name: "atlas-search-test"
- name: "atlas-data-lake-task"

- name: "reactive-streams-tck-test"
display_name: "Reactive Streams TCK tests"
Expand Down
4 changes: 3 additions & 1 deletion .evergreen/run-atlas-search-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixes the missing Binary in AggregatesBinaryVectorSearchIntegrationTest. The tests were not previously being run.

Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import com.mongodb.client.model.geojson.Point;
import org.bson.BsonArray;
import org.bson.BsonBinary;
import org.bson.BsonBoolean;
import org.bson.BsonDocument;
import org.bson.BsonNull;
import org.bson.BsonBoolean;
import org.bson.BsonType;
import org.bson.Document;
import org.bson.conversions.Bson;
Expand Down Expand Up @@ -573,14 +573,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) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import com.mongodb.annotations.Sealed;

/**
* @see SearchOperator#wildcard(String, SearchPath)
* @see SearchOperator#wildcard(SearchPath, String)
* @see SearchOperator#wildcard(Iterable, Iterable)
* @since 4.7
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import com.mongodb.client.model.SearchIndexType;
import com.mongodb.client.test.CollectionHelper;
import com.mongodb.internal.operation.SearchIndexRequest;
import org.bson.BinaryVector;
import org.bson.BsonDocument;
import org.bson.Document;
import org.bson.BinaryVector;
import org.bson.codecs.DocumentCodec;
import org.bson.conversions.Bson;
import org.junit.jupiter.api.AfterAll;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@
* </tr>
* </tbody>
* </table>
* <p>
* Use this class when needing to test against MFLIX specifically. Otherwise,
* see AggregatesSearchTest.
*/
final class AggregatesSearchIntegrationTest {
private static final MongoNamespace MFLIX_MOVIES_NS = new MongoNamespace("sample_mflix", "movies");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -833,8 +833,8 @@ void wildcard() {
.append("path", fieldPath("fieldName").toBsonValue())
),
SearchOperator.wildcard(
"term",
fieldPath("fieldName"))
fieldPath("fieldName"), "term"
)
.toBsonDocument()
),
() -> assertEquals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ object SearchOperator {
* @return The requested `SearchOperator`.
* @see [[https://www.mongodb.com/docs/atlas/atlas-search/wildcard/ wildcard operator]]
*/
def wildcard(query: String, path: SearchPath): WildcardSearchOperator = JSearchOperator.wildcard(query, path)
def wildcard(query: String, path: SearchPath): WildcardSearchOperator = JSearchOperator.wildcard(path, query)

/**
* Returns a `SearchOperator` that enables queries which use special characters in the search string that can match any character.
Expand Down
Loading