diff --git a/spec/integration/bulk_write_spec.rb b/spec/integration/bulk_write_spec.rb index a586a7b3bb..a931f13945 100644 --- a/spec/integration/bulk_write_spec.rb +++ b/spec/integration/bulk_write_spec.rb @@ -21,7 +21,7 @@ end context 'when bulk write needs to be split' do - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } let(:max_bson_size) { Mongo::Server::ConnectionBase::DEFAULT_MAX_BSON_OBJECT_SIZE } diff --git a/spec/integration/change_stream_spec.rb b/spec/integration/change_stream_spec.rb index d64efd49a6..3adada7e59 100644 --- a/spec/integration/change_stream_spec.rb +++ b/spec/integration/change_stream_spec.rb @@ -53,7 +53,7 @@ def clear_fail_point_before it 'raises an exception and does not attempt to resume' do change_stream - subscriber = EventSubscriber.new + subscriber = Mrss::EventSubscriber.new authorized_client.subscribe(Mongo::Monitoring::COMMAND, subscriber) expect do @@ -523,7 +523,7 @@ def clear_fail_point_before let(:events) do start_after - subscriber = EventSubscriber.new + subscriber = Mrss::EventSubscriber.new authorized_client.subscribe(Mongo::Monitoring::COMMAND, subscriber) use_stream @@ -582,7 +582,7 @@ def clear_fail_point_before let(:stream) { authorized_collection.watch } let(:events) do - subscriber = EventSubscriber.new + subscriber = Mrss::EventSubscriber.new authorized_client.subscribe(Mongo::Monitoring::COMMAND, subscriber) use_stream subscriber.succeeded_events.select { |e| diff --git a/spec/integration/client_side_encryption/auto_encryption_bulk_writes_spec.rb b/spec/integration/client_side_encryption/auto_encryption_bulk_writes_spec.rb index f13c3bffd7..b8792be684 100644 --- a/spec/integration/client_side_encryption/auto_encryption_bulk_writes_spec.rb +++ b/spec/integration/client_side_encryption/auto_encryption_bulk_writes_spec.rb @@ -11,7 +11,7 @@ include_context 'define shared FLE helpers' include_context 'with local kms_providers' - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } let(:client) do new_local_client( diff --git a/spec/integration/client_side_encryption/auto_encryption_command_monitoring_spec.rb b/spec/integration/client_side_encryption/auto_encryption_command_monitoring_spec.rb index 8713c9c5d0..cef8a166a3 100644 --- a/spec/integration/client_side_encryption/auto_encryption_command_monitoring_spec.rb +++ b/spec/integration/client_side_encryption/auto_encryption_command_monitoring_spec.rb @@ -15,7 +15,7 @@ include_context 'define shared FLE helpers' include_context 'with local kms_providers' - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } let(:db_name) { 'auto_encryption' } let(:encryption_client) do diff --git a/spec/integration/client_side_encryption/bson_size_limit_spec.rb b/spec/integration/client_side_encryption/bson_size_limit_spec.rb index 14e0740b59..556248f3c3 100644 --- a/spec/integration/client_side_encryption/bson_size_limit_spec.rb +++ b/spec/integration/client_side_encryption/bson_size_limit_spec.rb @@ -11,7 +11,7 @@ include_context 'define shared FLE helpers' - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } let(:client) do authorized_client.use('db') diff --git a/spec/integration/client_side_encryption/data_key_spec.rb b/spec/integration/client_side_encryption/data_key_spec.rb index 5254a9e749..7e89620cc0 100644 --- a/spec/integration/client_side_encryption/data_key_spec.rb +++ b/spec/integration/client_side_encryption/data_key_spec.rb @@ -11,7 +11,7 @@ include_context 'define shared FLE helpers' - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } let(:client) do new_local_client( diff --git a/spec/integration/command_monitoring_spec.rb b/spec/integration/command_monitoring_spec.rb index 0cb61b40c9..7f0ec3578b 100644 --- a/spec/integration/command_monitoring_spec.rb +++ b/spec/integration/command_monitoring_spec.rb @@ -5,7 +5,7 @@ describe 'Command monitoring' do - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } let(:client) do authorized_client.with(app_name: 'command monitoring spec').tap do |client| diff --git a/spec/integration/command_spec.rb b/spec/integration/command_spec.rb index 165d385fb0..9b3237df72 100644 --- a/spec/integration/command_spec.rb +++ b/spec/integration/command_spec.rb @@ -5,7 +5,7 @@ describe 'Command' do - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } describe 'payload' do let(:server) { authorized_client.cluster.next_primary } diff --git a/spec/integration/connection_spec.rb b/spec/integration/connection_spec.rb index a3c7de1df4..6cea7563fa 100644 --- a/spec/integration/connection_spec.rb +++ b/spec/integration/connection_spec.rb @@ -50,7 +50,7 @@ context 'with sdam event subscription' do - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } let(:client) do ClientRegistry.instance.global_client('authorized').with(app_name: 'connection_integration').tap do |client| client.subscribe(Mongo::Monitoring::SERVER_OPENING, subscriber) diff --git a/spec/integration/cursor_reaping_spec.rb b/spec/integration/cursor_reaping_spec.rb index 2ae347706d..e465434e91 100644 --- a/spec/integration/cursor_reaping_spec.rb +++ b/spec/integration/cursor_reaping_spec.rb @@ -21,7 +21,7 @@ end =end - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } let(:client) do authorized_client.tap do |client| diff --git a/spec/integration/get_more_spec.rb b/spec/integration/get_more_spec.rb index c7070f54f6..6f53a141f5 100644 --- a/spec/integration/get_more_spec.rb +++ b/spec/integration/get_more_spec.rb @@ -7,7 +7,7 @@ # https://jira.mongodb.org/browse/RUBY-1987 min_server_fcv '3.2' - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } let(:client) do authorized_client.tap do |client| diff --git a/spec/integration/heartbeat_events_spec.rb b/spec/integration/heartbeat_events_spec.rb index f2d16849a8..08da6baf43 100644 --- a/spec/integration/heartbeat_events_spec.rb +++ b/spec/integration/heartbeat_events_spec.rb @@ -11,7 +11,7 @@ class HeartbeatEventsSpecTestException < StandardError; end clean_slate_for_all - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } before do Mongo::Monitoring::Global.subscribe(Mongo::Monitoring::SERVER_HEARTBEAT, subscriber) diff --git a/spec/integration/map_reduce_spec.rb b/spec/integration/map_reduce_spec.rb index 38afed6408..634d9e9cae 100644 --- a/spec/integration/map_reduce_spec.rb +++ b/spec/integration/map_reduce_spec.rb @@ -7,7 +7,7 @@ let(:client) { authorized_client } let(:collection) { client['mr_integration'] } - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } let(:find_options) { {} } diff --git a/spec/integration/query_cache_spec.rb b/spec/integration/query_cache_spec.rb index b7c4137c36..ce6363bdef 100644 --- a/spec/integration/query_cache_spec.rb +++ b/spec/integration/query_cache_spec.rb @@ -28,7 +28,7 @@ SessionRegistry.instance.verify_sessions_ended! end - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } let(:client) do authorized_client.tap do |client| diff --git a/spec/integration/query_cache_transactions_spec.rb b/spec/integration/query_cache_transactions_spec.rb index 29d77763ba..aae9016644 100644 --- a/spec/integration/query_cache_transactions_spec.rb +++ b/spec/integration/query_cache_transactions_spec.rb @@ -23,7 +23,7 @@ # leak sessions independently of the query cache. This will be resolved by # RUBY-2391. - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } let(:client) do authorized_client.tap do |client| diff --git a/spec/integration/read_concern_spec.rb b/spec/integration/read_concern_spec.rb index ea152b3704..bf313dfd50 100644 --- a/spec/integration/read_concern_spec.rb +++ b/spec/integration/read_concern_spec.rb @@ -7,7 +7,7 @@ min_server_version '3.2' let(:subscriber) do - EventSubscriber.new + Mrss::EventSubscriber.new end let(:specified_read_concern) do diff --git a/spec/integration/read_preference_spec.rb b/spec/integration/read_preference_spec.rb index 68ae5b9107..ca46da81ea 100644 --- a/spec/integration/read_preference_spec.rb +++ b/spec/integration/read_preference_spec.rb @@ -16,7 +16,7 @@ authorized_client.with(client_options) end - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } before do client.subscribe(Mongo::Monitoring::COMMAND, subscriber) diff --git a/spec/integration/retryable_errors_spec.rb b/spec/integration/retryable_errors_spec.rb index 187b1ad3c1..1cbf979919 100644 --- a/spec/integration/retryable_errors_spec.rb +++ b/spec/integration/retryable_errors_spec.rb @@ -7,7 +7,7 @@ # Requirement for fail point min_server_fcv '4.0' - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } let(:client_options) do {} diff --git a/spec/integration/sdam_error_handling_spec.rb b/spec/integration/sdam_error_handling_spec.rb index e589937263..5c756d2653 100644 --- a/spec/integration/sdam_error_handling_spec.rb +++ b/spec/integration/sdam_error_handling_spec.rb @@ -18,7 +18,7 @@ # shard cluster where multiple servers are equally eligible require_no_multi_mongos - let(:diagnostic_subscriber) { VerboseEventSubscriber.new } + let(:diagnostic_subscriber) { Mrss::VerboseEventSubscriber.new } let(:client) do new_local_client(SpecConfig.instance.addresses, @@ -290,7 +290,7 @@ describe 'when there is an error on monitoring connection' do clean_slate_for_all - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } let(:set_subscribers) do client.subscribe(Mongo::Monitoring::SERVER_DESCRIPTION_CHANGED, subscriber) diff --git a/spec/integration/sdam_events_spec.rb b/spec/integration/sdam_events_spec.rb index 8edb49e535..a59f7c923b 100644 --- a/spec/integration/sdam_events_spec.rb +++ b/spec/integration/sdam_events_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' describe 'SDAM events' do - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } describe 'server closed event' do it 'is published when client is closed' do diff --git a/spec/integration/sdam_prose_spec.rb b/spec/integration/sdam_prose_spec.rb index 1487b4db53..8f85fd869c 100644 --- a/spec/integration/sdam_prose_spec.rb +++ b/spec/integration/sdam_prose_spec.rb @@ -11,7 +11,7 @@ min_server_fcv '4.4' require_topology :single - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } let(:client) do new_local_client(SpecConfig.instance.addresses, diff --git a/spec/integration/step_down_spec.rb b/spec/integration/step_down_spec.rb index 7abcb7e6d2..b726c06d9c 100644 --- a/spec/integration/step_down_spec.rb +++ b/spec/integration/step_down_spec.rb @@ -32,7 +32,7 @@ end end - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } let(:test_client) do authorized_client_without_any_retries.with(server_selection_timeout: 20).tap do |client| diff --git a/spec/integration/x509_auth_spec.rb b/spec/integration/x509_auth_spec.rb index f7b697a979..c6c164b668 100644 --- a/spec/integration/x509_auth_spec.rb +++ b/spec/integration/x509_auth_spec.rb @@ -38,7 +38,7 @@ "C=US,ST=New York,L=New York City,O=MongoDB,OU=x509,CN=localhost".freeze end - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } shared_examples 'authenticates successfully' do it 'authenticates successfully' do diff --git a/spec/lite_spec_helper.rb b/spec/lite_spec_helper.rb index b3ab77882f..9a408bfe77 100644 --- a/spec/lite_spec_helper.rb +++ b/spec/lite_spec_helper.rb @@ -77,7 +77,7 @@ module Mrss require 'mrss/lite_constraints' require 'support/matchers' -require 'support/event_subscriber' +require 'mrss/event_subscriber' require 'support/common_shortcuts' require 'support/client_registry' require 'support/client_registry_macros' diff --git a/spec/mongo/auth/user/view_spec.rb b/spec/mongo/auth/user/view_spec.rb index 135453a315..8a43e20c45 100644 --- a/spec/mongo/auth/user/view_spec.rb +++ b/spec/mongo/auth/user/view_spec.rb @@ -23,7 +23,7 @@ shared_context 'testing write concern' do let(:subscriber) do - EventSubscriber.new + Mrss::EventSubscriber.new end let(:client) do diff --git a/spec/mongo/bulk_write_spec.rb b/spec/mongo/bulk_write_spec.rb index edc31c054a..4a213cb990 100644 --- a/spec/mongo/bulk_write_spec.rb +++ b/spec/mongo/bulk_write_spec.rb @@ -2106,7 +2106,7 @@ require_no_multi_mongos - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } let(:client) do authorized_client_with_retry_writes.tap do |client| diff --git a/spec/mongo/client_construction_spec.rb b/spec/mongo/client_construction_spec.rb index e797788668..1d9237628b 100644 --- a/spec/mongo/client_construction_spec.rb +++ b/spec/mongo/client_construction_spec.rb @@ -6,7 +6,7 @@ describe Mongo::Client do clean_slate - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } describe '.new' do context 'with scan: false' do diff --git a/spec/mongo/client_spec.rb b/spec/mongo/client_spec.rb index 6b2290a2a6..ee8c829250 100644 --- a/spec/mongo/client_spec.rb +++ b/spec/mongo/client_spec.rb @@ -635,7 +635,7 @@ root_authorized_client.options.merge(heartbeat_frequency: 100, monitoring: true) end - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } let(:client) do ClientRegistry.instance.new_local_client( diff --git a/spec/mongo/cluster_spec.rb b/spec/mongo/cluster_spec.rb index c0b9c522bc..2c765e4f13 100644 --- a/spec/mongo/cluster_spec.rb +++ b/spec/mongo/cluster_spec.rb @@ -362,7 +362,7 @@ end let(:monitoring) { Mongo::Monitoring.new } - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } it 'publishes server closed event once' do monitoring.subscribe(Mongo::Monitoring::SERVER_CLOSED, subscriber) diff --git a/spec/mongo/collection/view/aggregation_spec.rb b/spec/mongo/collection/view/aggregation_spec.rb index f5810121d4..46c836fe16 100644 --- a/spec/mongo/collection/view/aggregation_spec.rb +++ b/spec/mongo/collection/view/aggregation_spec.rb @@ -235,7 +235,7 @@ { session: session } end - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } let(:client) do authorized_client.tap do |client| diff --git a/spec/mongo/collection/view/map_reduce_spec.rb b/spec/mongo/collection/view/map_reduce_spec.rb index 4ac3d77d68..d9b7fe427e 100644 --- a/spec/mongo/collection/view/map_reduce_spec.rb +++ b/spec/mongo/collection/view/map_reduce_spec.rb @@ -242,7 +242,7 @@ Mongo::Collection::View.new(client[TEST_COLL], selector, view_options) end - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } let(:client) do authorized_client.tap do |client| diff --git a/spec/mongo/collection_crud_spec.rb b/spec/mongo/collection_crud_spec.rb index d3841565cb..6659e400e5 100644 --- a/spec/mongo/collection_crud_spec.rb +++ b/spec/mongo/collection_crud_spec.rb @@ -5,7 +5,7 @@ describe Mongo::Collection do - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } let(:client) do authorized_client.tap do |client| diff --git a/spec/mongo/collection_ddl_spec.rb b/spec/mongo/collection_ddl_spec.rb index 9e4a8948e8..b3e31a2569 100644 --- a/spec/mongo/collection_ddl_spec.rb +++ b/spec/mongo/collection_ddl_spec.rb @@ -5,7 +5,7 @@ describe Mongo::Collection do - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } let(:client) do authorized_client.tap do |client| diff --git a/spec/mongo/collection_spec.rb b/spec/mongo/collection_spec.rb index bd297317d4..819b6bc234 100644 --- a/spec/mongo/collection_spec.rb +++ b/spec/mongo/collection_spec.rb @@ -5,7 +5,7 @@ describe Mongo::Collection do - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } let(:client) do authorized_client.tap do |client| diff --git a/spec/mongo/cursor_spec.rb b/spec/mongo/cursor_spec.rb index 0463d29a1d..2f3c6862de 100644 --- a/spec/mongo/cursor_spec.rb +++ b/spec/mongo/cursor_spec.rb @@ -438,7 +438,7 @@ context 'when an implicit session is used' do min_server_fcv '3.6' - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } let(:subscribed_client) do authorized_client.tap do |client| diff --git a/spec/mongo/database_spec.rb b/spec/mongo/database_spec.rb index 7938a34a07..e27c451ff7 100644 --- a/spec/mongo/database_spec.rb +++ b/spec/mongo/database_spec.rb @@ -218,7 +218,7 @@ described_class.new(client, SpecConfig.instance.test_db) end - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } let(:client) do authorized_client.tap do |client| @@ -391,7 +391,7 @@ described_class.new(client, SpecConfig.instance.test_db) end - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } let(:client) do authorized_client.tap do |client| @@ -583,7 +583,7 @@ described_class.new(client, SpecConfig.instance.test_db) end - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } let(:client) do authorized_client.tap do |client| @@ -678,7 +678,7 @@ client.start_session end - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } let(:client) do authorized_client.tap do |client| @@ -969,7 +969,7 @@ client.start_session end - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } let(:client) do root_authorized_client.tap do |client| diff --git a/spec/mongo/index/view_spec.rb b/spec/mongo/index/view_spec.rb index 1c1d4f6d0b..b20d9b35e0 100644 --- a/spec/mongo/index/view_spec.rb +++ b/spec/mongo/index/view_spec.rb @@ -266,7 +266,7 @@ context 'on server versions >= 4.4' do min_server_fcv '4.4' - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } let(:client) do authorized_client.tap do |client| @@ -932,7 +932,7 @@ context 'on server versions >= 4.4' do min_server_fcv '4.4' - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } let(:client) do authorized_client.tap do |client| diff --git a/spec/mongo/query_cache_spec.rb b/spec/mongo/query_cache_spec.rb index 0ef3fe3b92..ac01826d35 100644 --- a/spec/mongo/query_cache_spec.rb +++ b/spec/mongo/query_cache_spec.rb @@ -14,7 +14,7 @@ authorized_collection.delete_many end - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } let(:client) do authorized_client.tap do |client| diff --git a/spec/mongo/server/connection_pool_spec.rb b/spec/mongo/server/connection_pool_spec.rb index 1385aa4e20..8583f28a2e 100644 --- a/spec/mongo/server/connection_pool_spec.rb +++ b/spec/mongo/server/connection_pool_spec.rb @@ -602,7 +602,7 @@ it 'raises an error and emits ConnectionCheckOutFailedEvent' do pool - subscriber = EventSubscriber.new + subscriber = Mrss::EventSubscriber.new client.subscribe(Mongo::Monitoring::CONNECTION_POOL, subscriber) subscriber.clear_events! diff --git a/spec/mongo/session/session_pool_spec.rb b/spec/mongo/session/session_pool_spec.rb index e96c2aeeb7..6d196dff0f 100644 --- a/spec/mongo/session/session_pool_spec.rb +++ b/spec/mongo/session/session_pool_spec.rb @@ -192,7 +192,7 @@ pool.checkout end - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } let(:client) do authorized_client.tap do |client| diff --git a/spec/runners/change_streams/test.rb b/spec/runners/change_streams/test.rb index cfb19bb0f3..7d38a9ff50 100644 --- a/spec/runners/change_streams/test.rb +++ b/spec/runners/change_streams/test.rb @@ -89,7 +89,7 @@ def setup_test setup_fail_point(client) - @subscriber = EventSubscriber.new + @subscriber = Mrss::EventSubscriber.new client.subscribe(Mongo::Monitoring::COMMAND, @subscriber) @target = case @target_type diff --git a/spec/runners/cmap.rb b/spec/runners/cmap.rb index 30b13927e8..9085728411 100644 --- a/spec/runners/cmap.rb +++ b/spec/runners/cmap.rb @@ -33,7 +33,7 @@ class Spec # @return [ Mongo::ConnectionPool ] pool The connection pool to use for operations. attr_reader :pool - # @return [ EventSubscriber ] subscriber The subscriber receiving the CMAP events. + # @return [ Mrss::EventSubscriber ] subscriber The subscriber receiving the CMAP events. attr_reader :subscriber # Instantiate the new spec. diff --git a/spec/runners/crud.rb b/spec/runners/crud.rb index 7a2b9130e5..c0c1a7c651 100644 --- a/spec/runners/crud.rb +++ b/spec/runners/crud.rb @@ -96,7 +96,7 @@ def define_crud_spec_test_examples(spec, req = nil, &block) end let(:event_subscriber) do - EventSubscriber.new + Mrss::EventSubscriber.new end let(:verifier) { Mongo::CRUD::Verifier.new(test) } diff --git a/spec/runners/transactions/test.rb b/spec/runners/transactions/test.rb index c7714eb13a..49085697ce 100644 --- a/spec/runners/transactions/test.rb +++ b/spec/runners/transactions/test.rb @@ -141,11 +141,11 @@ def test_client end def command_subscriber - @command_subscriber ||= EventSubscriber.new + @command_subscriber ||= Mrss::EventSubscriber.new end def sdam_subscriber - @sdam_subscriber ||= EventSubscriber.new(name: 'sdam subscriber') + @sdam_subscriber ||= Mrss::EventSubscriber.new(name: 'sdam subscriber') end # Run the test. diff --git a/spec/runners/unified/event_subscriber.rb b/spec/runners/unified/event_subscriber.rb index 073b515a9a..42490b4a6e 100644 --- a/spec/runners/unified/event_subscriber.rb +++ b/spec/runners/unified/event_subscriber.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true # encoding: utf-8 -require 'support/event_subscriber' +require 'mrss/event_subscriber' module Unified - class EventSubscriber < ::EventSubscriber + class EventSubscriber < Mrss::EventSubscriber def ignore_commands(command_names) @ignore_commands = command_names end diff --git a/spec/shared b/spec/shared index e489f0dc70..96871ae135 160000 --- a/spec/shared +++ b/spec/shared @@ -1 +1 @@ -Subproject commit e489f0dc706982576d004e61805b0d7c1e3b338e +Subproject commit 96871ae1353e2229f9ebf839594e4eb76451c22b diff --git a/spec/spec_tests/cmap_spec.rb b/spec/spec_tests/cmap_spec.rb index bb0bdc043c..b164866558 100644 --- a/spec/spec_tests/cmap_spec.rb +++ b/spec/spec_tests/cmap_spec.rb @@ -40,7 +40,7 @@ context("#{spec.description} (#{file.sub(%r'.*/data/cmap/', '')})") do before do - subscriber = EventSubscriber.new + subscriber = Mrss::EventSubscriber.new monitoring = Mongo::Monitoring.new(monitoring: false) monitoring.subscribe(Mongo::Monitoring::CONNECTION_POOL, subscriber) diff --git a/spec/spec_tests/command_monitoring_spec.rb b/spec/spec_tests/command_monitoring_spec.rb index 2fa235c0f6..44fcbd832b 100644 --- a/spec/spec_tests/command_monitoring_spec.rb +++ b/spec/spec_tests/command_monitoring_spec.rb @@ -24,7 +24,7 @@ end let(:subscriber) do - EventSubscriber.new + Mrss::EventSubscriber.new end let(:monitoring) do @@ -54,7 +54,7 @@ def check_event(subscriber, index, expectation) subscriber.all_events.length.should > index - # TODO move this filtering into EventSubscriber + # TODO move this filtering into Mrss::EventSubscriber events = subscriber.all_events.reject do |event| ( event.is_a?(Mongo::Monitoring::Event::CommandStarted) || diff --git a/spec/spec_tests/sdam_monitoring_spec.rb b/spec/spec_tests/sdam_monitoring_spec.rb index 6c4d65f0cb..e6517effe8 100644 --- a/spec/spec_tests/sdam_monitoring_spec.rb +++ b/spec/spec_tests/sdam_monitoring_spec.rb @@ -16,7 +16,7 @@ context("#{spec.description} (#{file.sub(%r'.*/data/sdam_monitoring/', '')})") do before(:all) do - @subscriber = PhasedEventSubscriber.new + @subscriber = Mrss::PhasedEventSubscriber.new sdam_proc = lambda do |client| client.subscribe(Mongo::Monitoring::SERVER_OPENING, @subscriber) client.subscribe(Mongo::Monitoring::SERVER_CLOSED, @subscriber) diff --git a/spec/support/event_subscriber.rb b/spec/support/event_subscriber.rb deleted file mode 100644 index 5513b03135..0000000000 --- a/spec/support/event_subscriber.rb +++ /dev/null @@ -1,221 +0,0 @@ -# frozen_string_literal: true -# encoding: utf-8 - -# Test event subscriber. -# -# @since 2.5.0 -class EventSubscriber - - # The mappings of event names to types. - # - # @since 2.4.0 - MAPPINGS = { - 'topology_opening_event' => Mongo::Monitoring::Event::TopologyOpening, - 'topology_description_changed_event' => Mongo::Monitoring::Event::TopologyChanged, - 'topology_closed_event' => Mongo::Monitoring::Event::TopologyClosed, - 'server_opening_event' => Mongo::Monitoring::Event::ServerOpening, - 'server_description_changed_event' => Mongo::Monitoring::Event::ServerDescriptionChanged, - 'server_closed_event' => Mongo::Monitoring::Event::ServerClosed - }.freeze - - # All events. - attr_reader :all_events - - # The started events. - # - # @since 2.5.0 - attr_reader :started_events - - # The succeeded events. - # - # @since 2.5.0 - attr_reader :succeeded_events - - # The failed events. - # - # @since 2.5.0 - attr_reader :failed_events - - attr_reader :published_events - - # @param [ String ] name Optional name for the event subscriber. - def initialize(name: nil) - @mutex = Mutex.new - clear_events! - @name = name - end - - def to_s - %Q`#` - end - - alias :inspect :to_s - - # Event retrieval - - def select_started_events(cls) - started_events.select do |event| - event.is_a?(cls) - end - end - - def select_succeeded_events(cls) - succeeded_events.select do |event| - event.is_a?(cls) - end - end - - def select_completed_events(*classes) - (succeeded_events + failed_events).select do |event| - classes.any? { |c| c === event } - end - end - - def select_published_events(cls) - published_events.select do |event| - event.is_a?(cls) - end - end - - # Filters command started events for the specified command name. - def command_started_events(command_name) - started_events.select do |event| - event.command[command_name] - end - end - - def non_auth_command_started_events - started_events.reject do |event| - %w(authenticate getnonce saslSstart saslContinue).any? do |cmd| - event.command[cmd] - end - end - end - - # Locates command stated events for the specified command name, - # asserts that there is exactly one such event, and returns it. - def single_command_started_event(command_name, include_auth: false) - events = if include_auth - started_events - else - non_auth_command_started_events - end - events.select! do |event| - event.command[command_name] - end - if events.length != 1 - raise "Expected a single #{command_name} event but we have #{events.length}" - end - events.first - end - - # Get the first succeeded event published for the name, and then delete it. - # - # @param [ String ] name The event name. - # - # @return [ Event ] The matching event. - def first_event(name) - cls = MAPPINGS[name] - if cls.nil? - raise ArgumentError, "Bogus event name #{name}" - end - matching = succeeded_events.find do |event| - cls === event - end - succeeded_events.delete(matching) - matching - end - - # Event recording - - # Cache the started event. - # - # @param [ Event ] event The event. - # - # @since 2.5.0 - def started(event) - @mutex.synchronize do - started_events << event - all_events << event - end - end - - # Cache the succeeded event. - # - # @param [ Event ] event The event. - # - # @since 2.5.0 - def succeeded(event) - @mutex.synchronize do - succeeded_events << event - all_events << event - end - end - - # Cache the failed event. - # - # @param [ Event ] event The event. - # - # @since 2.5.0 - def failed(event) - @mutex.synchronize do - failed_events << event - all_events << event - end - end - - def published(event) - @mutex.synchronize do - published_events << event - all_events << event - end - end - - # Clear all cached events. - # - # @since 2.5.1 - def clear_events! - @all_events = [] - @started_events = [] - @succeeded_events = [] - @failed_events = [] - @published_events = [] - self - end -end - -# Only handles succeeded events correctly. -class PhasedEventSubscriber < EventSubscriber - def initialize - super - @phase_events = {} - end - - def phase_finished(phase_index) - @phase_events[phase_index] = succeeded_events - @succeeded_events = [] - end - - def phase_events(phase_index) - @phase_events[phase_index] - end - - def event_count - @phase_events.inject(0) do |sum, event| - sum + event.length - end - end -end - -class VerboseEventSubscriber < EventSubscriber - %w(started succeeded failed published).each do |meth| - define_method(meth) do |event| - puts event.summary - super(event) - end - end -end diff --git a/spec/support/shared/session.rb b/spec/support/shared/session.rb index ad016d27f8..d48d4f0070 100644 --- a/spec/support/shared/session.rb +++ b/spec/support/shared/session.rb @@ -185,7 +185,7 @@ shared_examples 'an operation supporting causally consistent reads' do - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } let(:client) do authorized_client.tap do |client| @@ -622,7 +622,7 @@ client.start_session end - let(:subscriber) { EventSubscriber.new } + let(:subscriber) { Mrss::EventSubscriber.new } let(:client) do authorized_client.tap do |client| diff --git a/spec/support/utils.rb b/spec/support/utils.rb index f47d12eb1f..84b8ff6466 100644 --- a/spec/support/utils.rb +++ b/spec/support/utils.rb @@ -556,7 +556,7 @@ def match_with_type?(expected, actual) # command event published, asserts the command event published has the # specified command name, and returns the published event. module_function def get_command_event(client, command_name, include_auth: false) - subscriber = EventSubscriber.new + subscriber = Mrss::EventSubscriber.new client.subscribe(Mongo::Monitoring::COMMAND, subscriber) begin yield client