Skip to content

Commit ef4e942

Browse files
authored
CSHARP-5592: Separate unit tests into dedicated variants (#1695)
1 parent fcbc397 commit ef4e942

File tree

116 files changed

+286
-100
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+286
-100
lines changed

build.cake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ Task("Test")
128128
Console.WriteLine($"MONGO_X509_CLIENT_CERTIFICATE_PASSWORD={mongoX509ClientCertificatePassword}");
129129
}
130130

131-
RunTests(buildConfig, testProject);
131+
RunTests(buildConfig, testProject, filter: "Category=\"Integration\"");
132132
})
133133
.DeferOnError();
134134

evergreen/evergreen.yml

Lines changed: 84 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,13 @@ functions:
9898
install-dotnet:
9999
- command: shell.exec
100100
params:
101+
include_expansions_in_env:
102+
- "OS"
103+
- "DOTNET_SDK_VERSION"
104+
- "FRAMEWORK"
101105
script: |
102106
${PREPARE_SHELL}
103-
OS=${OS} DOTNET_SDK_VERSION=${DOTNET_SDK_VERSION} bash ${PROJECT_DIRECTORY}/evergreen/install-dotnet.sh
107+
bash ${PROJECT_DIRECTORY}/evergreen/install-dotnet.sh
104108
105109
prepare-resources:
106110
- command: shell.exec
@@ -352,6 +356,18 @@ functions:
352356
cd ${DRIVERS_TOOLS}/.evergreen
353357
DRIVERS_TOOLS=${DRIVERS_TOOLS} MONGODB_URI=${MONGODB_URI} bash ${DRIVERS_TOOLS}/.evergreen/run-load-balancer.sh stop
354358
359+
run-unit-tests:
360+
- command: shell.exec
361+
type: test
362+
params:
363+
working_dir: mongo-csharp-driver
364+
shell: "bash"
365+
include_expansions_in_env:
366+
- "FRAMEWORK"
367+
script: |
368+
${PREPARE_SHELL}
369+
bash evergreen/run-unit-tests.sh
370+
355371
run-tests:
356372
- command: shell.exec
357373
type: test
@@ -508,7 +524,7 @@ functions:
508524
509525
echo "Response Body: $response_body"
510526
echo "HTTP Status: $http_status"
511-
527+
512528
assume-ec2-role:
513529
- command: ec2.assume_role
514530
params:
@@ -1031,6 +1047,36 @@ post:
10311047
- func: cleanup
10321048

10331049
tasks:
1050+
- name: unit-tests-net472
1051+
commands:
1052+
- command: expansions.update
1053+
params:
1054+
updates:
1055+
- key: 'FRAMEWORK'
1056+
value: 'net472'
1057+
- func: install-dotnet
1058+
- func: run-unit-tests
1059+
1060+
- name: unit-tests-netstandard21
1061+
commands:
1062+
- command: expansions.update
1063+
params:
1064+
updates:
1065+
- key: 'FRAMEWORK'
1066+
value: 'netstandard2.1'
1067+
- func: install-dotnet
1068+
- func: run-unit-tests
1069+
1070+
- name: unit-tests-net60
1071+
commands:
1072+
- command: expansions.update
1073+
params:
1074+
updates:
1075+
- key: 'FRAMEWORK'
1076+
value: 'net6.0'
1077+
- func: install-dotnet
1078+
- func: run-unit-tests
1079+
10341080
- name: test-net472
10351081
commands:
10361082
- func: setup-csfle-secrets
@@ -2179,6 +2225,42 @@ task_groups:
21792225
- validate-apicompat
21802226

21812227
buildvariants:
2228+
- name: unit-tests-windows
2229+
display_name: Unit Tests on Windows
2230+
run_on: windows-64-vs2017-test
2231+
expansions:
2232+
OS: "windows-64"
2233+
tasks:
2234+
- name: unit-tests-net472
2235+
- name: unit-tests-netstandard21
2236+
- name: unit-tests-net60
2237+
2238+
- name: unit-tests-ubuntu
2239+
display_name: Unit Tests on Ubuntu
2240+
run_on: ubuntu2004-small
2241+
expansions:
2242+
OS: "ubuntu-2004"
2243+
tasks:
2244+
- name: unit-tests-netstandard21
2245+
- name: unit-tests-net60
2246+
2247+
- name: unit-tests-macos
2248+
display_name: Unit Tests on MacOs
2249+
run_on: macos-14
2250+
expansions:
2251+
OS: "macos-14"
2252+
tasks:
2253+
- name: unit-tests-netstandard21
2254+
- name: unit-tests-net60
2255+
2256+
- name: unit-tests-macos-arm
2257+
display_name: Unit Tests on MacOs Arm
2258+
run_on: macos-14-arm64
2259+
expansions:
2260+
OS: "macos-14-arm64"
2261+
tasks:
2262+
- name: unit-tests-net60
2263+
21822264
- matrix_name: stable-api-tests
21832265
matrix_spec: { version: ["5.0", "6.0", "7.0", "8.0", "rapid", "latest"], topology: "standalone", auth: "auth", ssl: "nossl", os: "windows-64" }
21842266
display_name: "Stable API ${version} ${topology} ${auth} ${ssl} ${os}"

evergreen/install-dotnet.sh

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,32 @@ set -o errexit # Exit the script with error if any of the commands fail
44
DOTNET_SDK_PATH="${DOTNET_SDK_PATH:-./.dotnet}"
55
DOTNET_SDK_VERSION="${DOTNET_SDK_VERSION:-8.0}"
66

7+
echo "runtime: $FRAMEWORK"
8+
9+
if [ -n "$FRAMEWORK" ]; then
10+
if [ "$FRAMEWORK" = "net6.0" ]; then
11+
RUNTIME_VERSION="6.0"
12+
elif [ "$FRAMEWORK" = "netstandard2.1" ]; then
13+
RUNTIME_VERSION="3.1"
14+
fi
15+
fi
16+
717
if [[ $OS =~ [Ww]indows.* ]]; then
818
echo "Downloading Windows .NET SDK installer into $DOTNET_SDK_PATH folder..."
919
curl -Lfo ./dotnet-install.ps1 https://builds.dotnet.microsoft.com/dotnet/scripts/v1/dotnet-install.ps1
10-
echo "Installing .NET 8.0 SDK..."
20+
echo "Installing .NET ${DOTNET_SDK_VERSION} SDK..."
1121
powershell.exe ./dotnet-install.ps1 -Channel "$DOTNET_SDK_VERSION" -InstallDir "$DOTNET_SDK_PATH" -NoPath
22+
if [ -n "$RUNTIME_VERSION" ]; then
23+
echo "Installing .NET ${RUNTIME_VERSION} runtime..."
24+
powershell.exe ./dotnet-install.ps1 -Channel "$RUNTIME_VERSION" -Runtime dotnet -InstallDir "$DOTNET_SDK_PATH" -NoPath
25+
fi
1226
else
1327
echo "Downloading .NET SDK installer into $DOTNET_SDK_PATH folder..."
1428
curl -Lfo ./dotnet-install.sh https://builds.dotnet.microsoft.com/dotnet/scripts/v1/dotnet-install.sh
15-
echo "Installing .NET 8.0 SDK..."
29+
echo "Installing .NET ${DOTNET_SDK_VERSION} SDK..."
1630
bash ./dotnet-install.sh --channel "$DOTNET_SDK_VERSION" --install-dir "$DOTNET_SDK_PATH" --no-path
31+
if [ -n "$RUNTIME_VERSION" ]; then
32+
echo "Installing .NET ${RUNTIME_VERSION} runtime..."
33+
bash ./dotnet-install.sh --channel "$RUNTIME_VERSION" --runtime dotnet --install-dir "$DOTNET_SDK_PATH" --no-path
34+
fi
1735
fi

evergreen/run-unit-tests.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
set -o errexit # Exit the script with error if any of the commands fail
3+
4+
FRAMEWORK=${FRAMEWORK:-net6.0}
5+
6+
if [ "$FRAMEWORK" = "netstandard2.1" ]; then
7+
FRAMEWORK="netcoreapp3.1"
8+
fi
9+
10+
dotnet build
11+
dotnet test --no-build --filter "Category!=Integration" -f "$FRAMEWORK" --results-directory ./build/test-results --logger "junit;verbosity=detailed;LogFileName=TEST-{assembly}.xml;FailureBodyFormat=Verbose" --logger "console;verbosity=detailed"

tests/AtlasConnectivity.Tests/ConnectivityTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
namespace AtlasConnectivity.Tests
2525
{
26+
[Trait("Category", "Integration")]
2627
public class ConnectivityTests : LoggableTestClass
2728
{
2829
// public constructors

tests/MongoDB.Bson.TestHelpers/MongoDB.Bson.TestHelpers.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<Import Project="..\BuildProps\Tests.Build.props" />
33

44
<PropertyGroup>
5+
<IsTestProject>false</IsTestProject>
56
<CodeAnalysisRuleSet>..\..\MongoDBLegacyTest.ruleset</CodeAnalysisRuleSet>
67
</PropertyGroup>
78

tests/MongoDB.Driver.Examples/Aws/AwsAuthenticationExamples.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ namespace MongoDB.Driver.Examples.Aws
5353
/// 4. To work with EC2 container credentials from EC2 instance metadata make sure a test is launched on EC2 env and AWS_CONTAINER_CREDENTIALS_* is not set
5454
/// 5. To work with Aws WebIdentityToken make sure that AWS_WEB_IDENTITY_TOKEN_FILE, AWS_ROLE_ARN and AWS_ROLE_SESSION_NAME are configured
5555
/// </summary>
56+
[Trait("Category", "Integration")]
5657
public class AwsAuthenticationExamples
5758
{
5859
private static readonly string __connectionStringHosts = "<host_address>";

tests/MongoDB.Driver.Examples/CausalConsistencyExamples.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
namespace MongoDB.Driver.Examples
2424
{
25+
[Trait("Category", "Integration")]
2526
public class CausalConsistencyExamples
2627
{
2728
[Fact]

tests/MongoDB.Driver.Examples/ChangeStreamExamples.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
namespace MongoDB.Driver.Examples
2727
{
28+
[Trait("Category", "Integration")]
2829
public class ChangeStreamExamples
2930
{
3031
[Fact]

tests/MongoDB.Driver.Examples/ClientEncryptionExamples.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
namespace MongoDB.Driver.Examples
2727
{
28+
[Trait("Category", "Integration")]
2829
public class ClientEncryptionExamples
2930
{
3031
private const string LocalMasterKey = "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk";

tests/MongoDB.Driver.Examples/ClientSideEncryption2Examples.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
namespace MongoDB.Driver.Examples
2929
{
30+
[Trait("Category", "Integration")]
3031
public class ClientSideEncryption2Examples
3132
{
3233
private const string LocalMasterKey = "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk";

tests/MongoDB.Driver.Examples/DocumentationExamples.cs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
namespace MongoDB.Driver.Examples
2525
{
26+
[Trait("Category", "Integration")]
2627
public class DocumentationExamples
2728
{
2829
private readonly IMongoClient client;
@@ -41,7 +42,7 @@ public DocumentationExamples()
4142
[Fact]
4243
public void Example_1()
4344
{
44-
// db.inventory.insertOne( { item: "canvas", qty: 100, tags: ["cotton"], size: { h: 28, w: 35.5, uom: "cm" } } )
45+
// db.inventory.insertOne( { item: "canvas", qty: 100, tags: ["cotton"], size: { h: 28, w: 35.5, uom: "cm" } } )
4546

4647
// Start Example 1
4748
var document = new BsonDocument
@@ -76,10 +77,10 @@ public void Example_2()
7677
[Fact]
7778
public void Example_3()
7879
{
79-
// db.inventory.insertMany([
80+
// db.inventory.insertMany([
8081
// { item: "journal", qty: 25, tags: ["blank", "red"], size: { h: 14, w: 21, uom: "cm" } },
8182
// { item: "mat", qty: 85, tags: ["gray"], size: { h: 27.9, w: 35.5, uom: "cm" } },
82-
// { item: "mousepad", qty: 25, tags: ["gel", "blue"], size: { h: 19, w: 22.85, uom: "cm" } } ])
83+
// { item: "mousepad", qty: 25, tags: ["gel", "blue"], size: { h: 19, w: 22.85, uom: "cm" } } ])
8384

8485
// Start Example 3
8586
var documents = new BsonDocument[]
@@ -125,7 +126,7 @@ public void Example_6()
125126
// { item: "notebook", qty: 50, size: { h: 8.5, w: 11, uom: "in" }, status: "A" },
126127
// { item: "paper", qty: 100, size: { h: 8.5, w: 11, uom: "in" }, status: "D" },
127128
// { item: "planner", qty: 75, size: { h: 22.85, w: 30, uom: "cm" }, status: "D" },
128-
// { item: "postcard", qty: 45, size: { h: 10, w: 15.25, uom: "cm" }, status: "A" } ])
129+
// { item: "postcard", qty: 45, size: { h: 10, w: 15.25, uom: "cm" }, status: "A" } ])
129130

130131
// Start Example 6
131132
var documents = new BsonDocument[]
@@ -265,7 +266,7 @@ public void Example_13()
265266
[Fact]
266267
public void Example_14()
267268
{
268-
// db.inventory.insertMany( [
269+
// db.inventory.insertMany( [
269270
// { item: "journal", qty: 25, size: { h: 14, w: 21, uom: "cm" }, status: "A" },
270271
// { item: "notebook", qty: 50, size: { h: 8.5, w: 11, uom: "in" }, status: "A" },
271272
// { item: "paper", qty: 100, size: { h: 8.5, w: 11, uom: "in" }, status: "D" },
@@ -392,7 +393,7 @@ public void Example_19()
392393
[Fact]
393394
public void Example_20()
394395
{
395-
// db.inventory.insertMany([
396+
// db.inventory.insertMany([
396397
// { item: "journal", qty: 25, tags: ["blank", "red"], dim_cm: [ 14, 21 ] },
397398
// { item: "notebook", qty: 50, tags: ["red", "blank"], dim_cm: [ 14, 21 ] },
398399
// { item: "paper", qty: 100, tags: ["red", "blank", "plain"], dim_cm: [ 14, 21 ] },
@@ -559,7 +560,7 @@ public void Example_28()
559560
[Fact]
560561
public void Example_29()
561562
{
562-
// db.inventory.insertMany( [
563+
// db.inventory.insertMany( [
563564
// { item: "journal", instock: [ { warehouse: "A", qty: 5 }, { warehouse: "C", qty: 15 } ] },
564565
// { item: "notebook", instock: [ { warehouse: "C", qty: 5 } ] },
565566
// { item: "paper", instock: [ { warehouse: "A", qty: 60 }, { warehouse: "B", qty: 15 } ] },
@@ -795,7 +796,7 @@ public void Example_41()
795796
[Fact]
796797
public void Example_42()
797798
{
798-
// db.inventory.insertMany( [
799+
// db.inventory.insertMany( [
799800
// { item: "journal", status: "A", size: { h: 14, w: 21, uom: "cm" }, instock: [ { warehouse: "A", qty: 5 } ] },
800801
// { item: "notebook", status: "A", size: { h: 8.5, w: 11, uom: "in" }, instock: [ { warehouse: "C", qty: 5 } ] },
801802
// { item: "paper", status: "D", size: { h: 8.5, w: 11, uom: "in" }, instock: [ { warehouse: "A", qty: 60 } ] },
@@ -992,7 +993,7 @@ public void Example_50()
992993
[Fact]
993994
public void Example_51()
994995
{
995-
// db.inventory.insertMany( [
996+
// db.inventory.insertMany( [
996997
// { item: "canvas", qty: 100, size: { h: 28, w: 35.5, uom: "cm" }, status: "A" },
997998
// { item: "journal", qty: 25, size: { h: 14, w: 21, uom: "cm" }, status: "A" },
998999
// { item: "mat", qty: 85, size: { h: 27.9, w: 35.5, uom: "cm" }, status: "A" },
@@ -1002,7 +1003,7 @@ public void Example_51()
10021003
// { item: "planner", qty: 75, size: { h: 22.85, w: 30, uom: "cm" }, status: "D" },
10031004
// { item: "postcard", qty: 45, size: { h: 10, w: 15.25, uom: "cm" }, status: "A" },
10041005
// { item: "sketchbook", qty: 80, size: { h: 14, w: 21, uom: "cm" }, status: "A" },
1005-
// { item: "sketch pad", qty: 95, size: { h: 22.85, w: 30.5, uom: "cm" }, status: "A" } ]);
1006+
// { item: "sketch pad", qty: 95, size: { h: 22.85, w: 30.5, uom: "cm" }, status: "A" } ]);
10061007

10071008
// Start Example 51
10081009
var documents = new[]
@@ -1149,12 +1150,12 @@ public void Example_54()
11491150
[Fact]
11501151
public void Example_55()
11511152
{
1152-
// db.inventory.insertMany( [
1153+
// db.inventory.insertMany( [
11531154
// { item: "journal", qty: 25, size: { h: 14, w: 21, uom: "cm" }, status: "A" },
11541155
// { item: "notebook", qty: 50, size: { h: 8.5, w: 11, uom: "in" }, status: "P" },
11551156
// { item: "paper", qty: 100, size: { h: 8.5, w: 11, uom: "in" }, status: "D" },
11561157
// { item: "planner", qty: 75, size: { h: 22.85, w: 30, uom: "cm" }, status: "D" },
1157-
// { item: "postcard", qty: 45, size: { h: 10, w: 15.25, uom: "cm" }, status: "A" }, ]);
1158+
// { item: "postcard", qty: 45, size: { h: 10, w: 15.25, uom: "cm" }, status: "A" }, ]);
11581159

11591160
// Start Example 55
11601161
var documents = new[]
@@ -1252,7 +1253,7 @@ public void Aggregation_Example_1()
12521253
{
12531254
RequireServer.Check();
12541255

1255-
//db.sales.aggregate([
1256+
//db.sales.aggregate([
12561257
// { $match : { "items.fruit":"banana" } },
12571258
// { $sort : { "date" : 1 } }
12581259
//])
@@ -1347,7 +1348,7 @@ public void Aggregation_Example_3()
13471348
// }
13481349
//},
13491350
//{
1350-
// $project: { day: "$_id.day", revenue: 1, items_sold: 1,
1351+
// $project: { day: "$_id.day", revenue: 1, items_sold: 1,
13511352
// discount: { $cond: { if : { $lte: ["$revenue", 250] }, then: 25, else : 0 }}
13521353
// }
13531354
//}])
@@ -1421,7 +1422,7 @@ public void Aggregation_Example_4()
14211422
// $project : {
14221423
// "_id" : 0,
14231424
// "name" : 1,
1424-
// airlines : {
1425+
// airlines : {
14251426
// $filter : {
14261427
// input : "$airlines",
14271428
// as : "airline",

tests/MongoDB.Driver.Examples/ExplicitEncryptionExamples.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
namespace MongoDB.Driver.Examples
2727
{
28+
[Trait("Category", "Integration")]
2829
public class ExplicitEncryptionExamples
2930
{
3031
private const string LocalMasterKey = "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk";

tests/MongoDB.Driver.Examples/PrimerTestFixture.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818
using System.IO;
1919
using System.Reflection;
2020
using MongoDB.Bson;
21+
using Xunit;
2122

2223
namespace MongoDB.Driver.Examples
2324
{
25+
[Trait("Category", "Integration")]
2426
public abstract class PrimerTestFixture
2527
{
2628
protected static IMongoClient __client;

tests/MongoDB.Driver.Examples/StableApiExamples.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
namespace MongoDB.Driver.Examples
2121
{
22+
[Trait("Category", "Integration")]
2223
public class StableApiExamples
2324
{
2425
[Fact]

0 commit comments

Comments
 (0)