Skip to content

Commit 0331a8b

Browse files
authored
CSHARP-5642: Temporary disable mongocryptd tests on latest, windows (#1723)
1 parent f271d6d commit 0331a8b

File tree

6 files changed

+63
-5
lines changed

6 files changed

+63
-5
lines changed

tests/MongoDB.Driver.TestHelpers/Core/CoreTestConfiguration.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
using MongoDB.Driver.Core.Operations;
3030
using MongoDB.Driver.Core.Servers;
3131
using MongoDB.Driver.Core.WireProtocol.Messages.Encoders;
32+
using MongoDB.Driver.Encryption;
33+
using MongoDB.Driver.TestHelpers;
34+
using Xunit.Sdk;
3235

3336
namespace MongoDB.Driver
3437
{
@@ -344,6 +347,19 @@ public static BsonDocument GetServerParameters()
344347
}
345348
}
346349

350+
public static bool ShouldSkipMongocryptdTests_SERVER_106469() =>
351+
RequirePlatform.GetCurrentOperatingSystem() == SupportedOperatingSystem.Windows &&
352+
ServerVersion >= new SemanticVersion(8, 1, 9999);
353+
354+
public static void SkipMongocryptdTests_SERVER_106469(bool checkForSharedLib = false)
355+
{
356+
if (ShouldSkipMongocryptdTests_SERVER_106469() &&
357+
(!checkForSharedLib || GetCryptSharedLibPath() == null))
358+
{
359+
throw new SkipException("Test skipped because of SERVER-106469.");
360+
}
361+
}
362+
347363
internal static ICoreSessionHandle StartSession()
348364
{
349365
return StartSession(__cluster.Value);

tests/MongoDB.Driver.Tests/Encryption/AutoEncryptionTests.cs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
using MongoDB.Driver.Core.TestHelpers.Logging;
2525
using MongoDB.Driver.Core.TestHelpers.XunitExtensions;
2626
using MongoDB.Driver.Encryption;
27+
using MongoDB.Driver.TestHelpers;
2728
using MongoDB.Driver.Tests.Specifications.client_side_encryption;
2829
using MongoDB.TestHelpers.XunitExtensions;
2930
using Xunit;
@@ -87,13 +88,28 @@ public async Task Mongocryptd_should_be_initialized_when_auto_encryption([Values
8788

8889
var coll = client.GetDatabase(__collectionNamespace.DatabaseNamespace.DatabaseName).GetCollection<BsonDocument>(__collectionNamespace.CollectionName);
8990

90-
if (async)
91+
try
9192
{
92-
await coll.InsertOneAsync(new BsonDocument());
93+
if (async)
94+
{
95+
await coll.InsertOneAsync(new BsonDocument());
96+
}
97+
else
98+
{
99+
coll.InsertOne(new BsonDocument());
100+
}
93101
}
94-
else
102+
catch (Exception ex)
95103
{
96-
coll.InsertOne(new BsonDocument());
104+
if (CoreTestConfiguration.ShouldSkipMongocryptdTests_SERVER_106469())
105+
{
106+
ex.Should().BeOfType<MongoEncryptionException>();
107+
return;
108+
}
109+
else
110+
{
111+
throw;
112+
}
97113
}
98114

99115
mongocryptdClient.IsValueCreated.Should().BeTrue();

tests/MongoDB.Driver.Tests/Specifications/client-side-encryption/ClientSideEncryptionTestRunner.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public class ClientSideEncryptionTestRunner : MongoClientJsonDrivenTestRunnerBas
4040
public ClientSideEncryptionTestRunner(ITestOutputHelper testOutputHelper)
4141
: base(testOutputHelper)
4242
{
43+
CoreTestConfiguration.SkipMongocryptdTests_SERVER_106469();
4344
}
4445

4546
[Theory]

tests/MongoDB.Driver.Tests/Specifications/client-side-encryption/prose-tests/ClientEncryptionProseTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ public ClientEncryptionProseTests(ITestOutputHelper testOutputHelper)
8686
: base(testOutputHelper)
8787
{
8888
_cluster = CoreTestConfiguration.Cluster;
89+
90+
CoreTestConfiguration.SkipMongocryptdTests_SERVER_106469(checkForSharedLib: true);
8991
}
9092

9193
// public methods

tests/MongoDB.Driver.Tests/Specifications/sessions/SessionsProseTests.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
using System;
1717
using System.Collections.Generic;
18+
using System.ComponentModel.DataAnnotations;
1819
using System.Linq;
1920
using System.Threading.Tasks;
2021
using FluentAssertions;
@@ -27,6 +28,7 @@
2728
using MongoDB.Driver.Core.TestHelpers.Logging;
2829
using MongoDB.Driver.Core.TestHelpers.XunitExtensions;
2930
using MongoDB.Driver.Encryption;
31+
using MongoDB.Driver.TestHelpers;
3032
using MongoDB.TestHelpers.XunitExtensions;
3133
using Xunit;
3234
using Xunit.Abstractions;
@@ -63,15 +65,17 @@ public void Snapshot_and_causal_consistent_session_is_not_allowed()
6365
public async Task Ensure_explicit_session_raises_error_if_connection_does_not_support_sessions([Values(true, false)] bool async)
6466
{
6567
RequireServer.Check().Supports(Feature.ClientSideEncryption);
68+
CoreTestConfiguration.SkipMongocryptdTests_SERVER_106469();
6669

6770
using var mongocryptdContext = GetMongocryptdContext();
6871
using var session = mongocryptdContext.MongoClient.StartSession();
6972

7073
var exception = async ?
7174
await Record.ExceptionAsync(() => mongocryptdContext.MongocryptdCollection.FindAsync(session, FilterDefinition<BsonDocument>.Empty)) :
7275
Record.Exception(() => mongocryptdContext.MongocryptdCollection.Find(session, FilterDefinition<BsonDocument>.Empty).ToList());
73-
exception.Should().BeOfType<MongoClientException>().Subject.Message.Should().Be("Sessions are not supported.");
7476

77+
78+
exception.Should().BeOfType<MongoClientException>().Subject.Message.Should().Be("Sessions are not supported.");
7579
exception = async ?
7680
await Record.ExceptionAsync(() => mongocryptdContext.MongocryptdCollection.InsertOneAsync(session, new BsonDocument())) :
7781
Record.Exception(() => mongocryptdContext.MongocryptdCollection.InsertOne(session, new BsonDocument()));
@@ -84,6 +88,7 @@ await Record.ExceptionAsync(() => mongocryptdContext.MongocryptdCollection.FindA
8488
public async Task Ensure_implicit_session_is_ignored_if_connection_does_not_support_sessions([Values(true, false)] bool async)
8589
{
8690
RequireServer.Check().Supports(Feature.ClientSideEncryption);
91+
CoreTestConfiguration.SkipMongocryptdTests_SERVER_106469();
8792

8893
using var mongocryptdContext = GetMongocryptdContext();
8994

tests/SmokeTests/MongoDB.Driver.SmokeTests.Sdk/LibmongocryptTests.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@
1515

1616
using System;
1717
using System.Collections.Generic;
18+
using System.Runtime.InteropServices;
1819
using System.Threading;
20+
using FluentAssertions;
1921
using Microsoft.Extensions.Logging;
2022
using MongoDB.Bson;
2123
using MongoDB.Driver.Core.Configuration;
24+
using MongoDB.Driver.Core.Misc;
2225
using MongoDB.Driver.Encryption;
2326
using Xunit;
2427
using Xunit.Abstractions;
@@ -112,6 +115,21 @@ public void Explicit_encryption_with_libmongocrypt_package_works()
112115
var result = collection.Find(FilterDefinition<BsonDocument>.Empty).First();
113116
_output.WriteLine(result.ToJson());
114117
}
118+
catch (Exception ex)
119+
{
120+
// SERVER-106469
121+
#pragma warning disable CS0618 // Type or member is obsolete
122+
var serverVersion = client.Cluster.Description.Servers[0].Version;
123+
#pragma warning restore CS0618 // Type or member is obsolete
124+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) &&
125+
serverVersion >= new SemanticVersion(8, 1, 9999))
126+
{
127+
ex.Should().BeOfType<MongoEncryptionException>();
128+
return;
129+
}
130+
131+
throw;
132+
}
115133
finally
116134
{
117135
ClusterRegistry.Instance.UnregisterAndDisposeCluster(client.Cluster);

0 commit comments

Comments
 (0)