Skip to content

Commit 1a64362

Browse files
committed
CSHARP-1931: ReIndex should ignore write concern.
1 parent d57fe7f commit 1a64362

File tree

4 files changed

+6
-70
lines changed

4 files changed

+6
-70
lines changed

src/MongoDB.Driver.Core/Core/Operations/ReIndexOperation.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2016 MongoDB Inc.
1+
/* Copyright 2016-2017 MongoDB Inc.
22
*
33
* Licensed under the Apache License, Version 2.0 (the "License");
44
* you may not use this file except in compliance with the License.
@@ -71,11 +71,12 @@ public MessageEncoderSettings MessageEncoderSettings
7171
}
7272

7373
/// <summary>
74-
/// Gets or sets the write concern.
74+
/// Gets or sets the write concern (ignored and will eventually be deprecated and later removed).
7575
/// </summary>
7676
/// <value>
7777
/// The write concern.
7878
/// </value>
79+
// TODO: deprecate in 2.5 and remove in 3.0
7980
public WriteConcern WriteConcern
8081
{
8182
get { return _writeConcern; }
@@ -120,8 +121,7 @@ internal BsonDocument CreateCommand(SemanticVersion serverVersion)
120121
{
121122
return new BsonDocument
122123
{
123-
{ "reIndex", _collectionNamespace.CollectionName },
124-
{ "writeConcern", () => _writeConcern.ToBsonDocument(), Feature.CommandsThatWriteAcceptWriteConcern.ShouldSendWriteConcern(serverVersion, _writeConcern) }
124+
{ "reIndex", _collectionNamespace.CollectionName }
125125
};
126126
}
127127

src/MongoDB.Driver.Legacy/MongoCollection.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2010-2016 MongoDB Inc.
1+
/* Copyright 2010-2017 MongoDB Inc.
22
*
33
* Licensed under the Apache License, Version 2.0 (the "License");
44
* you may not use this file except in compliance with the License.
@@ -1663,10 +1663,7 @@ public ReadOnlyCollection<IEnumerator> ParallelScanAs(Type documentType, Paralle
16631663
/// <returns>A CommandResult.</returns>
16641664
public virtual CommandResult ReIndex()
16651665
{
1666-
var operation = new ReIndexOperation(_collectionNamespace, GetMessageEncoderSettings())
1667-
{
1668-
WriteConcern = _settings.WriteConcern
1669-
};
1666+
var operation = new ReIndexOperation(_collectionNamespace, GetMessageEncoderSettings());
16701667
var result = ExecuteWriteOperation(operation);
16711668
return new CommandResult(result);
16721669
}

tests/MongoDB.Driver.Core.Tests/Core/Operations/ReIndexOperationTests.cs

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -106,30 +106,6 @@ public void Execute_should_throw_when_binding_is_null(
106106
});
107107
}
108108

109-
[SkippableTheory]
110-
[ParameterAttributeData]
111-
public void Execute_should_throw_when_a_write_concern_error_occurs(
112-
[Values(false, true)]
113-
bool async)
114-
{
115-
RequireServer.Check().Supports(Feature.CommandsThatWriteAcceptWriteConcern).ClusterType(ClusterType.ReplicaSet);
116-
var actualVersion = CoreTestConfiguration.ServerVersion;
117-
if (actualVersion.Major == 3 && actualVersion.Minor == 5 && actualVersion.Patch == 2)
118-
{
119-
// skip test on any version of 3.5.2
120-
return; // TODO: remove later
121-
}
122-
EnsureCollectionExists();
123-
var subject = new ReIndexOperation(_collectionNamespace, _messageEncoderSettings)
124-
{
125-
WriteConcern = new WriteConcern(9)
126-
};
127-
128-
var exception = Record.Exception(() => ExecuteOperation(subject, async));
129-
130-
exception.Should().BeOfType<MongoWriteConcernException>();
131-
}
132-
133109
[Fact]
134110
public void CreateCommand_should_return_expected_result()
135111
{
@@ -144,31 +120,6 @@ public void CreateCommand_should_return_expected_result()
144120
result.Should().Be(expectedResult);
145121
}
146122

147-
[Theory]
148-
[ParameterAttributeData]
149-
public void CreateCommand_should_return_expected_result_when_WriteConcern_is_set(
150-
[Values(null, 1, 2)]
151-
int? w,
152-
[Values(false, true)]
153-
bool isWriteConcernSupported)
154-
{
155-
var writeConcern = w.HasValue ? new WriteConcern(w.Value) : null;
156-
var subject = new ReIndexOperation(_collectionNamespace, _messageEncoderSettings)
157-
{
158-
WriteConcern = writeConcern
159-
};
160-
var serverVersion = Feature.CommandsThatWriteAcceptWriteConcern.SupportedOrNotSupportedVersion(isWriteConcernSupported);
161-
162-
var result = subject.CreateCommand(serverVersion);
163-
164-
var expectedResult = new BsonDocument
165-
{
166-
{ "reIndex", _collectionNamespace.CollectionName },
167-
{ "writeConcern", () => writeConcern.ToBsonDocument(), writeConcern != null && isWriteConcernSupported }
168-
};
169-
result.Should().Be(expectedResult);
170-
}
171-
172123
// private methods
173124
public void EnsureCollectionExists()
174125
{

tests/MongoDB.Driver.Legacy.Tests/MongoCollectionTests.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2945,18 +2945,6 @@ public void TestReIndex()
29452945
}
29462946
}
29472947

2948-
[SkippableFact]
2949-
public void TestReIndexWriteConcern()
2950-
{
2951-
RequireServer.Check().Supports(Feature.CommandsThatWriteAcceptWriteConcern).ClusterType(ClusterType.ReplicaSet);
2952-
EnsureCollectionExists(_collection.Name);
2953-
var writeConcern = new WriteConcern(9, wTimeout: TimeSpan.FromMilliseconds(1));
2954-
2955-
var exception = Record.Exception(() => _collection.WithWriteConcern(writeConcern).ReIndex());
2956-
2957-
exception.Should().BeOfType<MongoWriteConcernException>();
2958-
}
2959-
29602948
[Fact]
29612949
public void TestRemove()
29622950
{

0 commit comments

Comments
 (0)