Skip to content

Commit

Permalink
New Max Staleness NoKnownServers test, prohibit maxStalenessSeconds=0.
Browse files Browse the repository at this point in the history
  • Loading branch information
ajdavis committed Nov 22, 2016
1 parent f3c1a2f commit 3c3a4c1
Show file tree
Hide file tree
Showing 11 changed files with 166 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# During server selection,
# clients (drivers or mongos) MUST raise an error if ``maxStalenessSeconds`` is not zero or null,
# and any server's ``maxWireVersion`` is less than 5 (`SERVER-23893`_).
# During server selection, clients (drivers or mongos) MUST raise an error if
# maxStalenessSeconds is defined and not -1 and any server's ``maxWireVersion``
# is less than 5 (`SERVER-23893`_).
---
topology_description:
type: ReplicaSetNoPrimary
Expand Down
20 changes: 20 additions & 0 deletions source/max-staleness/tests/ReplicaSetNoPrimary/NoKnownServers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"error": true,
"read_preference": {
"maxStalenessSeconds": 1,
"mode": "Nearest"
},
"topology_description": {
"servers": [
{
"address": "a:27017",
"type": "Unknown"
},
{
"address": "b:27017",
"type": "Unknown"
}
],
"type": "ReplicaSetNoPrimary"
}
}
15 changes: 15 additions & 0 deletions source/max-staleness/tests/ReplicaSetNoPrimary/NoKnownServers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# maxStalenessSeconds must be at least 90 seconds, even with no known servers.
---
topology_description:
type: ReplicaSetNoPrimary
servers:
- &1
address: a:27017
type: Unknown
- &2
address: b:27017
type: Unknown
read_preference:
mode: Nearest
maxStalenessSeconds: 1 # Too small.
error: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"error": true,
"read_preference": {
"maxStalenessSeconds": 0,
"mode": "Nearest"
},
"topology_description": {
"servers": [
{
"address": "a:27017",
"avg_rtt_ms": 5,
"lastUpdateTime": 0,
"lastWrite": {
"lastWriteDate": {
"$numberLong": "2"
}
},
"maxWireVersion": 5,
"type": "RSSecondary"
},
{
"address": "b:27017",
"avg_rtt_ms": 5,
"lastUpdateTime": 0,
"lastWrite": {
"lastWriteDate": {
"$numberLong": "1"
}
},
"maxWireVersion": 4,
"type": "RSSecondary"
}
],
"type": "ReplicaSetNoPrimary"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# maxStalenessSeconds=0 is prohibited.
---
topology_description:
type: ReplicaSetNoPrimary
servers:
- &1
address: a:27017
type: RSSecondary
avg_rtt_ms: 5
lastUpdateTime: 0
maxWireVersion: 5
lastWrite: {lastWriteDate: {$numberLong: "2"}}
- &2
address: b:27017
type: RSSecondary
avg_rtt_ms: 5
lastUpdateTime: 0
maxWireVersion: 4 # Incompatible.
lastWrite: {lastWriteDate: {$numberLong: "1"}}
read_preference:
mode: Nearest
maxStalenessSeconds: 0
error: true
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# During server selection,
# clients (drivers or mongos) MUST raise an error if ``maxStalenessSeconds`` is not zero or null,
# and any server's ``maxWireVersion`` is less than 5 (`SERVER-23893`_).
# During server selection, clients (drivers or mongos) MUST raise an error if
# maxStalenessSeconds is defined and not -1 and any server's ``maxWireVersion``
# is less than 5 (`SERVER-23893`_).
---
topology_description:
type: ReplicaSetWithPrimary
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Drivers MUST raise an error if ``maxStalenessSeconds`` is not zero or null
# Drivers MUST raise an error if maxStalenessSeconds is defined and not -1
# and the ``mode`` field is 'primary'.
---
topology_description:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"error": true,
"read_preference": {
"maxStalenessSeconds": 0,
"mode": "Nearest"
},
"topology_description": {
"servers": [
{
"address": "a:27017",
"avg_rtt_ms": 5,
"lastUpdateTime": 0,
"lastWrite": {
"lastWriteDate": {
"$numberLong": "2"
}
},
"maxWireVersion": 5,
"type": "RSPrimary"
},
{
"address": "b:27017",
"avg_rtt_ms": 5,
"lastUpdateTime": 0,
"lastWrite": {
"lastWriteDate": {
"$numberLong": "1"
}
},
"maxWireVersion": 4,
"type": "RSSecondary"
}
],
"type": "ReplicaSetWithPrimary"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# maxStalenessSeconds=0 is prohibited.
---
topology_description:
type: ReplicaSetWithPrimary
servers:
- &1
address: a:27017
type: RSPrimary
avg_rtt_ms: 5
lastUpdateTime: 0
maxWireVersion: 5
lastWrite: {lastWriteDate: {$numberLong: "2"}}
- &2
address: b:27017
type: RSSecondary
avg_rtt_ms: 5
lastUpdateTime: 0
maxWireVersion: 4 # Incompatible.
lastWrite: {lastWriteDate: {$numberLong: "1"}}
read_preference:
mode: Nearest
maxStalenessSeconds: 0
error: true
6 changes: 3 additions & 3 deletions source/max-staleness/tests/Sharded/Incompatible.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# During server selection,
# clients (drivers or mongos) MUST raise an error if ``maxStalenessSeconds`` is not zero or null,
# and any server's ``maxWireVersion`` is less than 5 (`SERVER-23893`_).
# During server selection, clients (drivers or mongos) MUST raise an error if
# maxStalenessSeconds is defined and not -1 and any server's ``maxWireVersion``
# is less than 5 (`SERVER-23893`_).
---
topology_description:
type: Sharded
Expand Down
6 changes: 3 additions & 3 deletions source/max-staleness/tests/Single/Incompatible.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# During server selection,
# clients (drivers or mongos) MUST raise an error if ``maxStalenessSeconds`` is not zero or null,
# and any server's ``maxWireVersion`` is less than 5 (`SERVER-23893`_).
# During server selection, clients (drivers or mongos) MUST raise an error if
# maxStalenessSeconds is defined and not -1 and any server's ``maxWireVersion``
# is less than 5 (`SERVER-23893`_).
---
topology_description:
type: Single
Expand Down

0 comments on commit 3c3a4c1

Please sign in to comment.