Skip to content

Commit 24ec76f

Browse files
committed
- EG Atlas search tests added
1 parent 76b3de5 commit 24ec76f

File tree

5 files changed

+586
-0
lines changed

5 files changed

+586
-0
lines changed

build.cake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,13 @@ Task("TestAtlasDataLake")
240240
action: (BuildConfig buildConfig, Path testProject) =>
241241
RunTests(buildConfig, testProject, filter: "Category=\"AtlasDataLake\""));
242242

243+
Task("TestAtlasSearch")
244+
.IsDependentOn("Build")
245+
.DoesForEach(
246+
items: GetFiles("./**/MongoDB.Driver.Tests.csproj"),
247+
action: (BuildConfig buildConfig, Path testProject) =>
248+
RunTests(buildConfig, testProject, filter: "Category=\"AtlasSearch\""));
249+
243250
Task("TestOcsp")
244251
.IsDependentOn("Build")
245252
.DoesForEach(

evergreen/evergreen.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,15 @@ functions:
679679
${PREPARE_SHELL}
680680
evergreen/run-atlas-data-lake-test.sh
681681
682+
run-atlas-search-test:
683+
- command: shell.exec
684+
type: test
685+
params:
686+
working_dir: mongo-csharp-driver
687+
script: |
688+
${PREPARE_SHELL}
689+
ATLAS_SEARCH="${ATLAS_SEARCH}" evergreen/run-atlas-search-test.sh
690+
682691
run-ocsp-test:
683692
- command: shell.exec
684693
type: test
@@ -1179,6 +1188,10 @@ tasks:
11791188
- func: bootstrap-mongohoused
11801189
- func: run-atlas-data-lake-test
11811190

1191+
- name: atlas-search-test
1192+
commands:
1193+
- func: run-atlas-search-test
1194+
11821195
- name: test-serverless-net472
11831196
exec_timeout_secs: 2700 # 45 minutes: 15 for setup + 30 for tests
11841197
commands:
@@ -2045,6 +2058,13 @@ buildvariants:
20452058
tasks:
20462059
- name: atlas-data-lake-test
20472060

2061+
- name: atlas-search-test
2062+
display_name: "Atlas Search Tests"
2063+
run_on:
2064+
- windows-64-vs2017-test
2065+
tasks:
2066+
- name: atlas-search-test
2067+
20482068
- name: gssapi-auth-tests-windows
20492069
run_on:
20502070
- windows-64-vs2017-test

evergreen/run-atlas-search-test.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
3+
set -o xtrace
4+
set -o errexit # Exit the script with error if any of the commands fail
5+
6+
# Environment variables produced as output
7+
# ATLAS_SEARCH_TESTS_ENABLED Enable atlas search tests.
8+
9+
############################################
10+
# Main Program #
11+
############################################
12+
13+
echo "Running Atlas Search driver tests"
14+
15+
export ATLAS_SEARCH_TESTS_ENABLED=true
16+
17+
powershell.exe .\\build.ps1 --target TestAtlasSearch

src/MongoDB.Driver/Search/SearchHighlightOptions.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
* limitations under the License.
1414
*/
1515

16+
using System;
17+
using System.Linq.Expressions;
1618
using MongoDB.Bson;
1719
using MongoDB.Bson.Serialization;
1820
using MongoDB.Driver.Core.Misc;
@@ -43,6 +45,27 @@ public SearchHighlightOptions(SearchPathDefinition<TDocument> path, int? maxChar
4345
_maxNumPassages = maxNumPassages;
4446
}
4547

48+
/// <summary>
49+
/// Creates highlighting options.
50+
/// </summary>
51+
/// <param name="path">The document field to search.</param>
52+
/// <param name="maxCharsToExamine">
53+
/// The maximum number of characters to examine on a document when performing highlighting
54+
/// for a field.
55+
/// </param>
56+
/// <param name="maxNumPassages">
57+
/// The number of high-scoring passages to return per document in the highlighting results
58+
/// for each field.
59+
/// </param>
60+
/// <returns>Highlighting options.</returns>
61+
public SearchHighlightOptions(
62+
Expression<Func<TDocument, object>> path,
63+
int? maxCharsToExamine = null,
64+
int? maxNumPassages = null) :
65+
this(new ExpressionFieldDefinition<TDocument>(path), maxCharsToExamine, maxNumPassages)
66+
{
67+
}
68+
4669
/// <summary>
4770
/// Gets or sets the maximum number of characters to examine on a document when performing
4871
/// highlighting for a field.

0 commit comments

Comments
 (0)