Skip to content

Commit

Permalink
corrected a problem with sdam monitoring initial previous description.
Browse files Browse the repository at this point in the history
  • Loading branch information
craiggwilson committed Apr 28, 2016
1 parent 2600b1c commit 9412480
Show file tree
Hide file tree
Showing 8 changed files with 197 additions and 45 deletions.
Expand Up @@ -63,7 +63,7 @@ public void CreateInitial_should_return_initial_description()
subject.Servers.Should().BeEmpty();
subject.State.Should().Be(ClusterState.Disconnected);
subject.ConnectionMode.Should().Be(ClusterConnectionMode.Standalone);
subject.Type.Should().Be(ClusterType.Standalone);
subject.Type.Should().Be(ClusterType.Unknown);
}

// instance member tests
Expand Down
Expand Up @@ -85,7 +85,7 @@ public void Description_should_return_correct_description_when_not_initialized(C

description.Servers.Should().BeEmpty();
description.State.Should().Be(ClusterState.Disconnected);
description.Type.Should().Be(clusterType);
description.Type.Should().Be(ClusterType.Unknown);
}

[Test]
Expand Down
Expand Up @@ -306,6 +306,7 @@
<None Include="Specifications\read-write-concern\tests\README.rst" />
<EmbeddedResource Include="Specifications\sdam-monitoring\tests\replica_set_with_removal.json" />
<EmbeddedResource Include="Specifications\sdam-monitoring\tests\standalone.json" />
<EmbeddedResource Include="Specifications\sdam-monitoring\tests\required_replica_set.json" />
<None Include="Specifications\server-discovery-and-monitoring\tests\Makefile" />
<None Include="Specifications\server-discovery-and-monitoring\tests\README.rst" />
<EmbeddedResource Include="Specifications\server-discovery-and-monitoring\tests\rs\new_primary_new_setversion.json" />
Expand Down
@@ -0,0 +1,149 @@
{
"description": "Monitoring a topology that is required to be a replica set",
"phases": [
{
"outcome": {
"events": [
{
"topology_opening_event": {
"topologyId": "42"
}
},
{
"topology_description_changed_event": {
"newDescription": {
"servers": [
{
"address": "a:27017",
"arbiters": [ ],
"hosts": [ ],
"passives": [ ],
"type": "Unknown"
},
{
"address": "b:27017",
"arbiters": [ ],
"hosts": [ ],
"passives": [ ],
"type": "Unknown"
}
],
"topologyType": "ReplicaSetNoPrimary"
},
"previousDescription": {
"servers": [ ],
"topologyType": "Unknown"
},
"topologyId": "42"
}
},
{
"server_opening_event": {
"address": "a:27017",
"topologyId": "42"
}
},
{
"server_opening_event": {
"address": "b:27017",
"topologyId": "42"
}
},
{
"server_description_changed_event": {
"address": "a:27017",
"newDescription": {
"address": "a:27017",
"arbiters": [ ],
"hosts": [
"a:27017",
"b:27017"
],
"passives": [ ],
"primary": "a:27017",
"setName": "rs",
"type": "RSPrimary"
},
"previousDescription": {
"address": "a:27017",
"arbiters": [ ],
"hosts": [ ],
"passives": [ ],
"type": "Unknown"
},
"topologyId": "42"
}
},
{
"topology_description_changed_event": {
"newDescription": {
"servers": [
{
"address": "a:27017",
"arbiters": [ ],
"hosts": [
"a:27017",
"b:27017"
],
"passives": [ ],
"primary": "a:27017",
"setName": "rs",
"type": "RSPrimary"
},
{
"address": "b:27017",
"arbiters": [ ],
"hosts": [ ],
"passives": [ ],
"type": "Unknown"
}
],
"setName": "rs",
"topologyType": "ReplicaSetWithPrimary"
},
"previousDescription": {
"servers": [
{
"address": "a:27017",
"arbiters": [ ],
"hosts": [ ],
"passives": [ ],
"type": "Unknown"
},
{
"address": "b:27017",
"arbiters": [ ],
"hosts": [ ],
"passives": [ ],
"type": "Unknown"
}
],
"topologyType": "ReplicaSetNoPrimary"
},
"topologyId": "42"
}
}
]
},
"responses": [
[
"a:27017",
{
"hosts": [
"a:27017",
"b:27017"
],
"ismaster": true,
"maxWireVersion": 4,
"minWireVersion": 0,
"ok": 1,
"primary": "a:27017",
"setName": "rs",
"setVersion": 1.0
}
]
]
}
],
"uri": "mongodb://a,b/?replicaSet=rs"
}
@@ -1,19 +1,7 @@
{
"description": "Monitoring a standalone connection",
"uri": "mongodb://a:27017",
"phases": [
{
"responses": [
[
"a:27017",
{
"ok": 1,
"ismaster": true,
"minWireVersion": 0,
"maxWireVersion": 4
}
]
],
"outcome": {
"events": [
{
Expand All @@ -23,13 +11,7 @@
},
{
"topology_description_changed_event": {
"topologyId": "42",
"previousDescription": {
"topologyType": "Unknown",
"servers": [ ]
},
"newDescription": {
"topologyType": "Single",
"servers": [
{
"address": "a:27017",
Expand All @@ -38,67 +20,85 @@
"passives": [ ],
"type": "Unknown"
}
]
}
],
"topologyType": "Single"
},
"previousDescription": {
"servers": [ ],
"topologyType": "Unknown"
},
"topologyId": "42"
}
},
{
"server_opening_event": {
"topologyId": "42",
"address": "a:27017"
"address": "a:27017",
"topologyId": "42"
}
},
{
"server_description_changed_event": {
"topologyId": "42",
"address": "a:27017",
"previousDescription": {
"newDescription": {
"address": "a:27017",
"arbiters": [ ],
"hosts": [ ],
"passives": [ ],
"type": "Unknown"
"type": "Standalone"
},
"newDescription": {
"previousDescription": {
"address": "a:27017",
"arbiters": [ ],
"hosts": [ ],
"passives": [ ],
"type": "Standalone"
}
"type": "Unknown"
},
"topologyId": "42"
}
},
{
"topology_description_changed_event": {
"topologyId": "42",
"previousDescription": {
"topologyType": "Unknown",
"newDescription": {
"servers": [
{
"address": "a:27017",
"arbiters": [ ],
"hosts": [ ],
"passives": [ ],
"type": "Unknown"
"type": "Standalone"
}
]
],
"topologyType": "Single"
},
"newDescription": {
"topologyType": "Single",
"previousDescription": {
"servers": [
{
"address": "a:27017",
"arbiters": [ ],
"hosts": [ ],
"passives": [ ],
"type": "Standalone"
"type": "Unknown"
}
]
}
],
"topologyType": "Single"
},
"topologyId": "42"
}
}
]
}
},
"responses": [
[
"a:27017",
{
"ismaster": true,
"maxWireVersion": 4,
"minWireVersion": 0,
"ok": 1
}
]
]
}
]
],
"uri": "mongodb://a:27017"
}
Expand Up @@ -35,7 +35,7 @@ internal static ClusterDescription CreateInitial(ClusterId clusterId, ClusterCon
return new ClusterDescription(
clusterId,
connectionMode,
connectionMode.ToClusterType(),
ClusterType.Unknown,
Enumerable.Empty<ServerDescription>());
}
#endregion
Expand Down
Expand Up @@ -134,7 +134,7 @@ public override void Initialize()
// are re-entrant such that this won't cause problems,
// but could prevent issues of conflicting reports
// from servers that are quick to respond.
var clusterDescription = Description;
var clusterDescription = Description.WithType(Settings.ConnectionMode.ToClusterType());
var newServers = new List<IClusterableServer>();
lock (_serversLock)
{
Expand Down
4 changes: 3 additions & 1 deletion src/MongoDB.Driver.Core/Core/Clusters/SingleServerCluster.cs
Expand Up @@ -112,7 +112,9 @@ public override void Initialize()

var stopwatch = Stopwatch.StartNew();
_server = CreateServer(Settings.EndPoints[0]);
var newClusterDescription = Description.WithServerDescription(_server.Description);
var newClusterDescription = Description
.WithType(Settings.ConnectionMode.ToClusterType())
.WithServerDescription(_server.Description);
if (_addingServerEventHandler != null)
{
_addingServerEventHandler(new ClusterAddingServerEvent(ClusterId, _server.EndPoint));
Expand Down

0 comments on commit 9412480

Please sign in to comment.