spec/support/shared/session.rb in mongo-2.7.0 vs spec/support/shared/session.rb in mongo-2.7.1
- old
+ new
@@ -1,9 +1,9 @@
shared_examples 'an operation using a session' do
describe 'operation execution' do
- min_server_version '3.6'
+ min_server_fcv '3.6'
require_topology :replica_set, :sharded
context 'when the session is created from the same client used for the operation' do
let(:session) do
@@ -84,11 +84,11 @@
end
shared_examples 'a failed operation using a session' do
context 'when the operation fails' do
- min_server_version '3.6'
+ min_server_fcv '3.6'
require_topology :replica_set, :sharded
let!(:before_last_use) do
session.instance_variable_get(:@server_session).last_use
end
@@ -125,11 +125,12 @@
before do
EventSubscriber.clear_events!
end
- context 'when sessions are supported', if: sessions_enabled? do
+ context 'when sessions are supported' do
+ min_server_fcv '3.6'
let(:session) do
client.start_session
end
@@ -137,11 +138,12 @@
operation
expect(EventSubscriber.started_events.collect(&:command).collect { |cmd| cmd['lsid'] }.compact).to be_empty
end
end
- context 'when sessions are not supported', if: !sessions_enabled? do
+ context 'when sessions are not supported' do
+ min_server_fcv '3.6'
let(:session) do
double('session').tap do |s|
allow(s).to receive(:validate!)
end
@@ -158,19 +160,21 @@
before do
EventSubscriber.clear_events!
end
- context 'when sessions are supported', if: sessions_enabled? do
+ context 'when sessions are supported' do
+ min_server_fcv '3.6'
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
end
- context 'when sessions are not supported', if: !sessions_enabled? do
+ context 'when sessions are not supported' do
+ min_server_fcv '3.6'
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
@@ -181,11 +185,13 @@
let(:client) do
subscribed_client
end
- context 'when connected to a standalone', if: sessions_enabled? && standalone? do
+ context 'when connected to a standalone' do
+ min_server_fcv '3.6'
+ require_topology :single
context 'when the collection specifies a read concern' do
let(:collection) do
client[TEST_COLL, read_concern: { level: 'majority' }]
@@ -265,11 +271,11 @@
end
end
end
context 'when connected to replica set or sharded cluster' do
- min_server_version '3.6'
+ min_server_fcv '3.6'
require_topology :replica_set, :sharded
context 'when the collection specifies a read concern' do
let(:collection) do
@@ -621,11 +627,11 @@
end
context 'when the command is run once' do
context 'when the server is version 3.6' do
- min_server_version '3.6'
+ min_server_fcv '3.6'
context 'when the cluster is sharded or a replica set' do
require_topology :replica_set, :sharded
let(:reply_cluster_time) do
@@ -687,11 +693,11 @@
operation_with_session
EventSubscriber.succeeded_events[-1].reply['$clusterTime']
end
context 'when the cluster is sharded or a replica set' do
- min_server_version '3.6'
+ min_server_fcv '3.6'
require_topology :replica_set, :sharded
context 'when the session cluster time is advanced' do
before do
@@ -718,10 +724,12 @@
end
context 'when the advanced cluster time is not greater than the existing cluster time' do
let(:advanced_cluster_time) do
+ expect(reply_cluster_time[Mongo::Cluster::CLUSTER_TIME].increment > 0).to be true
+
new_timestamp = BSON::Timestamp.new(reply_cluster_time[Mongo::Cluster::CLUSTER_TIME].seconds,
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
@@ -744,11 +752,13 @@
expect(second_command_cluster_time).to eq(reply_cluster_time)
end
end
end
- context 'when the server is a standalone', if: (standalone? && sessions_enabled?) do
+ context 'when the server is a standalone' do
+ min_server_fcv '3.6'
+ require_topology :single
let(:before_cluster_time) do
client.cluster.cluster_time
end
@@ -763,11 +773,12 @@
expect(client.cluster.cluster_time).to eq(bct)
end
end
end
- context 'when the server is less than version 3.6', if: !sessions_enabled? do
+ context 'when the server is less than version 3.6' do
+ max_server_version '3.4'
let(:before_cluster_time) do
client.cluster.cluster_time
end
@@ -778,11 +789,11 @@
end
end
end
shared_examples 'an operation not using a session' do
- require_sessions
+ min_server_fcv '3.6'
describe 'operation execution' do
context 'when the client has a session' do
@@ -848,10 +859,10 @@
end
end
end
shared_examples 'a failed operation not using a session' do
- require_sessions
+ min_server_fcv '3.6'
context 'when the operation fails' do
let!(:before_last_use) do
session.instance_variable_get(:@server_session).last_use