Skip to content

Commit

Permalink
SDAM test: primary steps down and changes setName.
Browse files Browse the repository at this point in the history
Noticed a bug in C Driver's updateRSWithPrimaryFromMember that wasn't
revealed by any SDAM test:

1. Discover primary, topology type is ReplicaSetWithPrimary
2. In next ismaster response from primary it has become secondary *and*
   changed setName

Expected: server removed, topology type changes to ReplicaSetNoPrimary

Actual: server removed but topology type remains ReplicaSetWithPrimary
  • Loading branch information
ajdavis committed Jul 15, 2015
1 parent 3d3f07f commit eec1b98
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"description": "Primary becomes a secondary with wrong setName",
"phases": [
{
"outcome": {
"servers": {
"a:27017": {
"setName": "rs",
"type": "RSPrimary"
}
},
"setName": "rs",
"topologyType": "ReplicaSetWithPrimary"
},
"responses": [
[
"a:27017",
{
"hosts": [
"a:27017"
],
"ismaster": true,
"ok": 1,
"setName": "rs"
}
]
]
},
{
"outcome": {
"servers": {},
"setName": "rs",
"topologyType": "ReplicaSetNoPrimary"
},
"responses": [
[
"a:27017",
{
"hosts": [
"a:27017"
],
"ismaster": false,
"ok": 1,
"secondary": true,
"setName": "wrong"
}
]
]
}
],
"uri": "mongodb://a/?replicaSet=rs"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
description: "Primary becomes a secondary with wrong setName"

uri: "mongodb://a/?replicaSet=rs"

phases: [

# Primary is discovered normally.
{
responses: [

["a:27017", {

ok: 1,
ismaster: true,
hosts: ["a:27017"],
setName: "rs"
}]
],

outcome: {

servers: {

"a:27017": {

type: "RSPrimary",
setName: "rs"
}
},

topologyType: "ReplicaSetWithPrimary",
setName: "rs"
}
},

# Primary changes its setName and becomes secondary.
# Remove it and change the topologyType.
{
responses: [

["a:27017", {

ok: 1,
ismaster: false,
secondary: true,
hosts: ["a:27017"],
setName: "wrong"
}]
],

outcome: {

servers: {},

topologyType: "ReplicaSetNoPrimary",
setName: "rs"
}
}
]

0 comments on commit eec1b98

Please sign in to comment.