spec/support/shared/session.rb in mongo-2.5.0 vs spec/support/shared/session.rb in mongo-2.5.1

- old
+ new

@@ -42,11 +42,11 @@ end context 'when a session from another client is provided' do let(:session) do - authorized_client.with(read: { mode: :secondary }).start_session + authorized_client_with_retry_writes.start_session end let(:operation_result) do operation end @@ -133,23 +133,13 @@ end shared_examples 'an operation supporting causally consistent reads' do let(:client) do - authorized_client.with(heartbeat_frequency: 100).tap do |cl| - cl.subscribe(Mongo::Monitoring::COMMAND, subscriber) - end + subscribed_client end - let(:subscriber) do - EventSubscriber.new - end - - after do - client.close - end - context 'when connected to a standalone', if: sessions_enabled? && standalone? do context 'when the collection specifies a read concern' do let(:collection) do @@ -570,32 +560,22 @@ let(:session) do client.start_session end let(:client) do - authorized_client.with(heartbeat_frequency: 100).tap do |cl| - cl.subscribe(Mongo::Monitoring::COMMAND, subscriber) - end + subscribed_client end - let(:subscriber) do - EventSubscriber.new - end - - after do - client.close - end - context 'when the command is run once' do context 'when the server is version 3.6' do context 'when the cluster is sharded or a replica set', if: test_sessions? do let!(:reply_cluster_time) do operation_with_session - subscriber.succeeded_events[-1].reply['$clusterTime'] + EventSubscriber.succeeded_events[-1].reply['$clusterTime'] end it 'updates the cluster time of the cluster' do expect(cluster.cluster_time).to eq(reply_cluster_time) end @@ -611,11 +591,11 @@ client.cluster.cluster_time end let!(:reply_cluster_time) do operation_with_session - subscriber.succeeded_events[-1].reply['$clusterTime'] + EventSubscriber.succeeded_events[-1].reply['$clusterTime'] end it 'does not update the cluster time of the cluster' do expect(before_cluster_time).to eq(before_cluster_time) end @@ -632,11 +612,11 @@ client.cluster.cluster_time end let!(:reply_cluster_time) do operation - subscriber.succeeded_events[-1].reply['$clusterTime'] + EventSubscriber.succeeded_events[-1].reply['$clusterTime'] end it 'does not update the cluster time of the cluster' do expect(before_cluster_time).to eq(before_cluster_time) end @@ -645,11 +625,11 @@ context 'when the command is run twice' do let!(:reply_cluster_time) do operation_with_session - subscriber.succeeded_events[-1].reply['$clusterTime'] + EventSubscriber.succeeded_events[-1].reply['$clusterTime'] end context 'when the cluster is sharded or a replica set', if: test_sessions? do context 'when the session cluster time is advanced' do @@ -658,11 +638,11 @@ session.advance_cluster_time(advanced_cluster_time) end let(:second_command_cluster_time) do second_operation - subscriber.started_events[-1].command['$clusterTime'] + EventSubscriber.started_events[-1].command['$clusterTime'] end context 'when the advanced cluster time is greater than the existing cluster time' do let(:advanced_cluster_time) do @@ -694,11 +674,11 @@ context 'when the session cluster time is not advanced' do let(:second_command_cluster_time) do second_operation - subscriber.started_events[-1].command['$clusterTime'] + EventSubscriber.started_events[-1].command['$clusterTime'] end it 'includes the received cluster time in the second command' do expect(second_command_cluster_time).to eq(reply_cluster_time) end @@ -711,10 +691,10 @@ client.cluster.cluster_time end let(:second_command_cluster_time) do second_operation - subscriber.started_events[-1].command['$clusterTime'] + EventSubscriber.started_events[-1].command['$clusterTime'] end it 'does not update the cluster time of the cluster' do second_command_cluster_time expect(before_cluster_time).to eq(before_cluster_time)