Skip to content

Commit 952f45f

Browse files
committed
Tweak cluster conditions
1 parent 12f5257 commit 952f45f

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

tests/MongoDB.Driver.Examples/ClientSideEncryption2Examples.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class ClientSideEncryption2Examples
3737
[Fact]
3838
public void FLE2AutomaticEncryption()
3939
{
40-
RequireServer.Check().Supports(Feature.Csfle2).ClusterTypes(ClusterType.ReplicaSet, ClusterType.Sharded, ClusterType.LoadBalanced, ClusterType.Standalone);
40+
RequireServer.Check().Supports(Feature.Csfle2);
4141

4242
var unencryptedClient = DriverTestConfiguration.Client;
4343

tests/MongoDB.Driver.Examples/TransactionExamplesForDocs/WithTransactionExample1.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
using System.Threading;
1717
using FluentAssertions;
1818
using MongoDB.Bson;
19-
using MongoDB.Driver.Core.Clusters;
2019
using MongoDB.Driver.Core.Misc;
2120
using MongoDB.Driver.Core.TestHelpers.XunitExtensions;
2221
using Xunit;
@@ -29,7 +28,7 @@ public class WithTransactionExample1
2928
[Fact]
3029
public void Example1()
3130
{
32-
RequireServer.Check().ClusterTypes(ClusterType.ReplicaSet, ClusterType.Sharded, ClusterType.Standalone).Supports(Feature.Transactions);
31+
RequireServer.Check().Supports(Feature.Transactions);
3332

3433
var connectionString = CoreTestConfiguration.ConnectionString.ToString();
3534
DropCollections(

tests/MongoDB.Driver.TestHelpers/Core/XunitExtensions/RequireServer.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,18 @@ public RequireServer Supports(params Feature[] features)
171171
}
172172

173173
public RequireServer SupportsCausalConsistency()
174-
{
175-
return ClusterTypes(Clusters.ClusterType.Sharded, Clusters.ClusterType.ReplicaSet, Clusters.ClusterType.Standalone).SupportsSessions();
176-
}
174+
// Determine if we are running against Atlas local by determining if the Atlas connection
175+
// string is the same as the regular connection string when the cluster is standalone.
176+
// This means that if someone has setup Atlas specific tests locally, then these tests will
177+
// also run, otherwise we will skip them on a standalone cluster.
178+
=> CoreTestConfiguration.Cluster.Description.Type == Clusters.ClusterType.Standalone
179+
&& string.Equals(
180+
CoreTestConfiguration.ConnectionString.ToString(),
181+
Environment.GetEnvironmentVariable("ATLAS_SEARCH_URI"),
182+
StringComparison.Ordinal)
183+
? this
184+
// If the server is not standalone, then use the previous logic.
185+
: ClusterTypes(Clusters.ClusterType.Sharded, Clusters.ClusterType.ReplicaSet).SupportsSessions();
177186

178187
public RequireServer SupportsSessions()
179188
{

0 commit comments

Comments
 (0)