diff --git a/src/cpp/pybmq_mocksession.cpp b/src/cpp/pybmq_mocksession.cpp index e842e25..c0c9bfc 100644 --- a/src/cpp/pybmq_mocksession.cpp +++ b/src/cpp/pybmq_mocksession.cpp @@ -276,10 +276,22 @@ MockSession::MockSession( static const char* const option_names[] = { "broker_uri", "process_name_override", + "connect_timeout", + "disconnect_timeout", "open_queue_timeout", "configure_queue_timeout", - "close_queue_timeout"}; - + "close_queue_timeout", + "num_processing_threads", + "blob_buffer_size", + "channel_high_watermark", + "event_queue_low_watermark", + "event_queue_high_watermark", + "stats_dump_interval"}; + + double timeout_connect_secs = options.connectTimeout().seconds() + + options.connectTimeout().nanoseconds() * 1e-9; + double timeout_disconnect_secs = options.disconnectTimeout().seconds() + + options.disconnectTimeout().nanoseconds() * 1e-9; double timeout_open_secs = options.openQueueTimeout().seconds() + options.openQueueTimeout().nanoseconds() * 1e-9; double timeout_configure_secs = @@ -287,18 +299,29 @@ MockSession::MockSession( + options.configureQueueTimeout().nanoseconds() * 1e-9; double timeout_close_secs = options.closeQueueTimeout().seconds() + options.closeQueueTimeout().nanoseconds() * 1e-9; + double stats_dump_interval_secs = + options.statsDumpInterval().seconds() + + options.statsDumpInterval().nanoseconds() * 1e-9; bslma::ManagedPtr py_options = RefUtils::toManagedPtr(_Py_DictBuilder( option_names, - "(s# N f f f)", + "(s# N f f f f f i i i i i f)", options.brokerUri().c_str(), options.brokerUri().length(), PyBytes_FromStringAndSize( options.processNameOverride().c_str(), options.processNameOverride().length()), + timeout_connect_secs, + timeout_disconnect_secs, timeout_open_secs, timeout_configure_secs, - timeout_close_secs)); + timeout_close_secs, + options.numProcessingThreads(), + options.blobBufferSize(), + options.channelHighWatermark(), + options.eventQueueLowWatermark(), + options.eventQueueHighWatermark(), + stats_dump_interval_secs)); if (!py_options) throw bsl::runtime_error("propagating Python error"); PyObject_SetAttrString(d_mock, "options", py_options.get()); } diff --git a/tests/unit/test_ext_session.py b/tests/unit/test_ext_session.py index 4d5257e..6373480 100644 --- a/tests/unit/test_ext_session.py +++ b/tests/unit/test_ext_session.py @@ -223,6 +223,36 @@ def test_session_timeout_passed_to_queue_defaults(): assert mock.options["close_queue_timeout"] == close_queue_timeout +def test_session_session_options_propagated(): + # GIVEN + mock = sdk_mock(start=0, stop=None) + num_processing_threads = 10 + blob_buffer_size = 5000 + channel_high_watermark = 20000000 + event_queue_low_watermark = 1000000 + event_queue_high_watermark = 10000000 + stats_dump_interval = 90.0 + + # WHEN + Session( + dummy_callback, + num_processing_threads=num_processing_threads, + blob_buffer_size=blob_buffer_size, + channel_high_watermark=channel_high_watermark, + event_queue_watermarks=(event_queue_low_watermark, event_queue_high_watermark), + stats_dump_interval=stats_dump_interval, + _mock=mock, + ) + + # THEN + assert mock.options["num_processing_threads"] == num_processing_threads + assert mock.options["blob_buffer_size"] == blob_buffer_size + assert mock.options["channel_high_watermark"] == channel_high_watermark + assert mock.options["event_queue_low_watermark"] == event_queue_low_watermark + assert mock.options["event_queue_high_watermark"] == event_queue_high_watermark + assert mock.options["stats_dump_interval"] == stats_dump_interval + + def test_ensure_stop_session_callback_calls_sdk_stop(): """Ensure that every started session is stopped by `ensure_stop_session`.