diff --git a/e2e/scenarios.md b/e2e/scenarios.md index f5bb353..85a3d23 100644 --- a/e2e/scenarios.md +++ b/e2e/scenarios.md @@ -111,6 +111,7 @@ No notifications → no SMTP, no Postgres row. - Query-time filter (SIENTIAPDE-2011) → union of active groups' `levels`, intersection of their `ignore_models_id`; a model ignored by only one of several active groups is not excluded from the fetch. - Empty Mongo → no Redis timestamp write. - Batch size cap (SIENTIAPDE-2013) → with 5 pending notifications and a batch size of 2, each run returns exactly the next-oldest 2 (sorted ascending by timestamp), and the Redis cursor advances only to what was actually returned, so three successive runs drain the backlog in order instead of skipping anything. +- Batch size 0 means unlimited (SIENTIAPDE-2013) → the configured default (`0`) does not cap the query; 12 pending notifications all come back in one run, verified against a real MongoDB instance rather than assumed from pymongo's documented convention. ### ProcessNotifications — `e2e/test_subworkflow_process_notifications.py` diff --git a/e2e/test_subworkflow_load_notification_package.py b/e2e/test_subworkflow_load_notification_package.py index b860524..0eb2bf8 100644 --- a/e2e/test_subworkflow_load_notification_package.py +++ b/e2e/test_subworkflow_load_notification_package.py @@ -291,3 +291,51 @@ async def test_load_package_batch_size_caps_and_returns_oldest_first( make_workflow_id('load-pkg-batch-3'), ) assert [n['notification_id'] for n in third_run['notification_package']] == ['n5'] + + +@pytest.mark.e2e +@pytest.mark.asyncio +async def test_load_package_batch_size_zero_means_unlimited( + temporal_env: WorkflowEnvironment, + orchestrator_worker, + stub_workers, + mongo_uri: str, + test_activities, +): + """ + SIENTIAPDE-2013: notification_queue_batch_size=0 (the config default) must + NOT cap the query. This exercises pymongo's own documented convention -- + `Collection.find(..., limit=0)` is equivalent to no limit at all -- against + a real MongoDB instance rather than trusting the convention on faith. + + 12 notifications is deliberately more than any other test in this file + seeds, so a regression that silently caps at some smaller default (e.g. if + `limit=0` were ever misread as "return nothing", or pymongo's own behavior + changed) would fail loudly here instead of passing by coincidence. + """ + test_activities.notification_queue_batch_size = 0 + + seed_receiver_groups(mongo_uri, E2E_DATABASE, [default_receiver_group()]) + seed_notifications( + mongo_uri, + E2E_DATABASE, + [ + default_notification( + notification_id=f'n{i}', + timestamp=datetime(2024, 6, 1, 12, i, 0, tzinfo=UTC), + ) + for i in range(1, 13) + ], + ) + + input_data = load_scenario_input('subworkflow_load_notification_package.json') + _build_metadata(input_data) + + result = await start_and_await_workflow( + temporal_env.client, + LoadNotificationPackage.run, + input_data, + make_workflow_id('load-pkg-batch-unlimited'), + ) + + assert len(result['notification_package']) == 12