Yicong-Huang commented on code in PR #4685: URL: https://github.com/apache/texera/pull/4685#discussion_r3189063779
########## amber/src/main/python/core/runnables/test_data_processor.py: ########## @@ -0,0 +1,102 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +import sys + +import pytest + +from core.architecture.managers import Context +from core.models.internal_queue import InternalQueue +from core.runnables.data_processor import DataProcessor +from proto.org.apache.texera.amber.engine.architecture.rpc import ConsoleMessageType + + [email protected] +def context(): + return Context(worker_id="test-worker", input_queue=InternalQueue()) + + [email protected] +def data_processor(context, monkeypatch): + """ + DataProcessor with `_switch_context` swapped for a counter so the + `post_switch` checks can yield without blocking the test thread and the + test can assert exactly how many extra switches happened. + """ + dp = DataProcessor(context) + dp.switch_calls = 0 + + def fake_switch(): + dp.switch_calls += 1 + + monkeypatch.setattr(dp, "_switch_context", fake_switch) Review Comment: The underlying regression the test would have caught is fixed in 5ec1dc2a1a — `_report_exception` is back inside `_executor_session.except` so the ERROR ConsoleMessage is queued before the switch, and the test now pins that ordering directly: `TestExecutorSession.test_exception_inside_session_is_reported_before_the_switch` swaps in a `_switch_context` that drains `console_message_manager` *at the moment of the switch* and asserts the stack trace is already there. That catches the "pause without stack trace" regression without needing a full Thread + Condition handshake (which adds flakiness without exercising any code path the controller-facing assertion doesn't already cover). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
