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";

0 commit comments

Comments
 (0)