spec/support/shared/session.rb in mongo-2.9.2 vs spec/support/shared/session.rb in mongo-2.10.0.rc0

- old
+ new

@@ -139,19 +139,18 @@ expect(EventSubscriber.started_events.collect(&:command).collect { |cmd| cmd['lsid'] }.compact).to be_empty end end context 'when sessions are not supported' do - min_server_fcv '3.6' + max_server_version '3.4' let(:session) do - double('session').tap do |s| - allow(s).to receive(:validate!) - end + nil end it 'does not add a session id to the operation' do + expect(Mongo::Session).not_to receive(:new) operation expect(EventSubscriber.started_events.collect(&:command).collect { |cmd| cmd['lsid'] }.compact).to be_empty end end end @@ -170,11 +169,11 @@ expect(EventSubscriber.started_events.collect(&:command).collect { |cmd| cmd['lsid'] }.compact).to be_empty end end context 'when sessions are not supported' do - min_server_fcv '3.6' + max_server_version '3.4' it 'does not add a session id to the operation' do operation expect(EventSubscriber.started_events.collect(&:command).collect { |cmd| cmd['lsid'] }.compact).to be_empty end @@ -602,10 +601,12 @@ end end end end +# Since background operatons can advance cluster time, exact cluster time +# comparisons sometimes fail. Work around this by retrying the tests. shared_examples 'an operation updating cluster time' do let(:cluster) do client.cluster end @@ -617,11 +618,11 @@ let(:client) do subscribed_client end shared_examples_for 'does not update the cluster time of the cluster' do - it 'does not update the cluster time of the cluster' do + it 'does not update the cluster time of the cluster', retry: 3 do bct = before_cluster_time reply_cluster_time expect(client.cluster.cluster_time).to eq(before_cluster_time) end end @@ -637,16 +638,16 @@ let(:reply_cluster_time) do operation_with_session EventSubscriber.succeeded_events[-1].reply['$clusterTime'] end - it 'updates the cluster time of the cluster' do + it 'updates the cluster time of the cluster', retry: 3 do rct = reply_cluster_time expect(cluster.cluster_time).to eq(rct) end - it 'updates the cluster time of the session' do + it 'updates the cluster time of the session', retry: 3 do rct = reply_cluster_time expect(session.cluster_time).to eq(rct) end end @@ -662,11 +663,11 @@ EventSubscriber.succeeded_events[-1].reply['$clusterTime'] end it_behaves_like 'does not update the cluster time of the cluster' - it 'does not update the cluster time of the session' do + it 'does not update the cluster time of the session', retry: 3 do reply_cluster_time expect(session.cluster_time).to be_nil end end end @@ -716,11 +717,11 @@ reply_cluster_time[Mongo::Cluster::CLUSTER_TIME].increment + 1) new_cluster_time = reply_cluster_time.dup new_cluster_time.merge(Mongo::Cluster::CLUSTER_TIME => new_timestamp) end - it 'includes the advanced cluster time in the second command' do + it 'includes the advanced cluster time in the second command', retry: 3 do expect(second_command_cluster_time).to eq(advanced_cluster_time) end end context 'when the advanced cluster time is not greater than the existing cluster time' do @@ -732,11 +733,11 @@ reply_cluster_time[Mongo::Cluster::CLUSTER_TIME].increment - 1) new_cluster_time = reply_cluster_time.dup new_cluster_time.merge(Mongo::Cluster::CLUSTER_TIME => new_timestamp) end - it 'does not advance the cluster time' do + it 'does not advance the cluster time', retry: 3 do expect(second_command_cluster_time).to eq(reply_cluster_time) end end end @@ -745,10 +746,10 @@ let(:second_command_cluster_time) do second_operation EventSubscriber.started_events[-1].command['$clusterTime'] end - it 'includes the received cluster time in the second command' do + it 'includes the received cluster time in the second command', retry: 3 do reply_cluster_time expect(second_command_cluster_time).to eq(reply_cluster_time) end end end