1description: "Replica set discovery" 2 3uri: "mongodb://a/?replicaSet=rs" 4 5phases: [ 6 7 # At first, a, b, and c are secondaries. 8 { 9 responses: [ 10 11 ["a:27017", { 12 13 ok: 1, 14 ismaster: false, 15 secondary: true, 16 setName: "rs", 17 hosts: ["a:27017", "b:27017", "c:27017"], 18 minWireVersion: 0, 19 maxWireVersion: 6 20 }] 21 ], 22 23 outcome: { 24 25 servers: { 26 27 "a:27017": { 28 29 type: "RSSecondary", 30 setName: "rs" 31 }, 32 33 "b:27017": { 34 35 type: "Unknown", 36 setName: 37 }, 38 39 "c:27017": { 40 41 type: "Unknown", 42 setName: 43 } 44 }, 45 topologyType: "ReplicaSetNoPrimary", 46 logicalSessionTimeoutMinutes: null, 47 setName: "rs" 48 } 49 }, 50 51 # Admin removes a, adds a high-priority member d which becomes primary. 52 { 53 responses: [ 54 55 ["b:27017", { 56 57 ok: 1, 58 ismaster: false, 59 secondary: true, 60 setName: "rs", 61 primary: "d:27017", 62 hosts: ["b:27017", "c:27017", "d:27017"], 63 minWireVersion: 0, 64 maxWireVersion: 6 65 }] 66 ], 67 68 outcome: { 69 70 servers: { 71 72 "a:27017": { 73 74 type: "RSSecondary", 75 setName: "rs" 76 }, 77 78 "b:27017": { 79 80 type: "RSSecondary", 81 setName: "rs" 82 }, 83 84 "c:27017": { 85 86 type: "Unknown", 87 setName: 88 }, 89 90 "d:27017": { 91 92 type: "PossiblePrimary", 93 setName: 94 } 95 }, 96 topologyType: "ReplicaSetNoPrimary", 97 logicalSessionTimeoutMinutes: null, 98 setName: "rs" 99 } 100 }, 101 102 # Primary responds. 103 { 104 responses: [ 105 106 ["d:27017", { 107 108 ok: 1, 109 ismaster: true, 110 setName: "rs", 111 hosts: ["b:27017", "c:27017", "d:27017", "e:27017"], 112 minWireVersion: 0, 113 maxWireVersion: 6 114 }] 115 ], 116 117 outcome: { 118 119 # e is new. 120 servers: { 121 122 "b:27017": { 123 124 type: "RSSecondary", 125 setName: "rs" 126 }, 127 128 "c:27017": { 129 130 type: "Unknown", 131 setName: 132 }, 133 134 "d:27017": { 135 136 type: "RSPrimary", 137 setName: "rs" 138 }, 139 140 "e:27017": { 141 142 type: "Unknown", 143 setName: 144 } 145 }, 146 topologyType: "ReplicaSetWithPrimary", 147 logicalSessionTimeoutMinutes: null, 148 setName: "rs" 149 } 150 }, 151 152 # Stale response from c. 153 { 154 responses: [ 155 156 ["c:27017", { 157 158 ok: 1, 159 ismaster: false, 160 secondary: true, 161 setName: "rs", 162 hosts: ["a:27017", "b:27017", "c:27017"], 163 minWireVersion: 0, 164 maxWireVersion: 6 165 }] 166 ], 167 168 outcome: { 169 170 # We don't add a back. 171 # We don't remove e. 172 servers: { 173 174 "b:27017": { 175 176 type: "RSSecondary", 177 setName: "rs" 178 }, 179 180 "c:27017": { 181 182 type: "RSSecondary", 183 setName: "rs" 184 }, 185 186 "d:27017": { 187 188 type: "RSPrimary", 189 setName: "rs" 190 }, 191 192 "e:27017": { 193 194 type: "Unknown", 195 setName: 196 } 197 }, 198 topologyType: "ReplicaSetWithPrimary", 199 logicalSessionTimeoutMinutes: null, 200 setName: "rs" 201 } 202 } 203] 204