|
152 | 152 | context 'when an implicit session is created and the topology is then updated and the server does not support sessions' do |
153 | 153 |
|
154 | 154 | let(:expected_global_args) do |
155 | | - global_args.delete(:lsid) |
156 | | - global_args |
| 155 | + global_args.dup.tap do |args| |
| 156 | + args.delete(:lsid) |
| 157 | + end |
157 | 158 | end |
158 | 159 |
|
159 | 160 | before do |
160 | 161 | session.instance_variable_set(:@options, { implicit: true }) |
161 | | - allow(authorized_primary.features).to receive(:sessions_enabled?).and_return(false) |
| 162 | + # Topology is standalone, hence there is exactly one server |
| 163 | + authorized_client.cluster.servers.first.monitor.stop!(true) |
| 164 | + expect(authorized_primary.features).to receive(:sessions_enabled?).at_least(:once).and_return(false) |
162 | 165 | end |
163 | 166 |
|
164 | 167 | it 'creates the correct OP_MSG message' do |
165 | 168 | authorized_client.command(ping:1) |
| 169 | + expect(expected_global_args).not_to have_key(:lsid) |
166 | 170 | expect(Mongo::Protocol::Msg).to receive(:new).with([:none], |
167 | 171 | { validating_keys: true }, |
168 | 172 | expected_global_args, |
|
188 | 192 | context 'when the topology is replica set or sharded', if: test_sessions? do |
189 | 193 |
|
190 | 194 | let(:expected_global_args) do |
191 | | - global_args.delete(:lsid) |
192 | | - global_args.merge(Mongo::Operation::CLUSTER_TIME => authorized_client.cluster.cluster_time) |
| 195 | + global_args.dup.tap do |args| |
| 196 | + args.delete(:lsid) |
| 197 | + args.merge!(Mongo::Operation::CLUSTER_TIME => authorized_client.cluster.cluster_time) |
| 198 | + end |
193 | 199 | end |
194 | 200 |
|
195 | 201 | it 'does not send a session id in the command' do |
|
205 | 211 | context 'when the topology is standalone', if: standalone? && sessions_enabled? do |
206 | 212 |
|
207 | 213 | let(:expected_global_args) do |
208 | | - global_args.delete(:lsid) |
209 | | - global_args |
| 214 | + global_args.dup.tap do |args| |
| 215 | + args.delete(:lsid) |
| 216 | + end |
210 | 217 | end |
211 | 218 |
|
212 | 219 | it 'creates the correct OP_MSG message' do |
|
227 | 234 | end |
228 | 235 |
|
229 | 236 | let(:expected_global_args) do |
230 | | - global_args.delete(:lsid) |
231 | | - global_args.merge(Mongo::Operation::CLUSTER_TIME => authorized_client.cluster.cluster_time) |
| 237 | + global_args.dup.tap do |args| |
| 238 | + args.delete(:lsid) |
| 239 | + args.merge!(Mongo::Operation::CLUSTER_TIME => authorized_client.cluster.cluster_time) |
| 240 | + end |
232 | 241 | end |
233 | 242 |
|
234 | 243 | it 'does not send a session id in the command' do |
|
0 commit comments