Skip to content

Commit

Permalink
Merge pull request #179 from lsst-ts/tickets/DM-47223
Browse files Browse the repository at this point in the history
tickets/DM-47223:  Prepare _wait_hard_point_test_ok method in MTCS for parallelization
  • Loading branch information
cvillalon authored Nov 19, 2024
2 parents cdd00ec + 66357a2 commit 4319525
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
1 change: 1 addition & 0 deletions doc/news/DM-47223.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update ``_wait_hard_point_test_ok`` method in ``MTCS`` to be compatible with concurrent executions.
19 changes: 16 additions & 3 deletions python/lsst/ts/observatory/control/maintel/mtcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1311,11 +1311,14 @@ async def _wait_hard_point_test_ok(self, hp: int) -> None:

self.log.info("Checking if the hard point breakaway test has passed.")

while True:
timer_task = asyncio.create_task(
asyncio.sleep(self.timeout_hardpoint_test_status)
)
while not timer_task.done():
hp_test_state = MTM1M3.HardpointTest(
(
await self.rem.mtm1m3.evt_hardpointTestStatus.next(
flush=False, timeout=self.timeout_hardpoint_test_status
await self.rem.mtm1m3.evt_hardpointTestStatus.aget(
timeout=self.timeout_hardpoint_test_status
)
).testState[hp - 1]
)
Expand All @@ -1328,6 +1331,16 @@ async def _wait_hard_point_test_ok(self, hp: int) -> None:
else:
self.log.info(f"Hard point {hp} test state: {hp_test_state!r}.")

try:
await self.rem.mtm1m3.evt_heartbeat.next(
flush=True, timeout=self.timeout_hardpoint_test_status
)
except asyncio.TimeoutError:
raise RuntimeError(
f"No heartbeat received from M1M3 in the last {self.timeout_hardpoint_test_status}s"
" while waiting for hard point data information. Check CSC liveliness."
)

async def _wait_bump_test_ok(
self, actuator_id: int, primary: bool, secondary: bool
) -> None:
Expand Down
1 change: 1 addition & 0 deletions python/lsst/ts/observatory/control/mock/mtcs_async_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ async def setup_mtm1m3(self) -> None:
"evt_detailedState.next.side_effect": self.mtm1m3_evt_detailed_state,
"evt_detailedState.aget.side_effect": self.mtm1m3_evt_detailed_state,
"evt_hardpointTestStatus.next.side_effect": self.mtm1m3_evt_hp_test_status,
"evt_hardpointTestStatus.aget.side_effect": self.mtm1m3_evt_hp_test_status,
"evt_forceActuatorBumpTestStatus.next.side_effect": self.mtm1m3_evt_bump_test_status,
"evt_forceActuatorBumpTestStatus.aget.side_effect": self.mtm1m3_evt_bump_test_status,
"cmd_raiseM1M3.set_start.side_effect": self.mtm1m3_cmd_raise_m1m3,
Expand Down
19 changes: 15 additions & 4 deletions tests/maintel/test_mtcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1484,8 +1484,7 @@ async def test_run_m1m3_hard_point_test(self) -> None:
timeout=self.mtcs.long_timeout,
)
self.mtcs.rem.mtm1m3.evt_hardpointTestStatus.flush.assert_called()
self.mtcs.rem.mtm1m3.evt_hardpointTestStatus.next.assert_awaited_with(
flush=False,
self.mtcs.rem.mtm1m3.evt_hardpointTestStatus.aget.assert_awaited_with(
timeout=self.mtcs.timeout_hardpoint_test_status,
)

Expand All @@ -1500,11 +1499,23 @@ async def test_run_m1m3_hard_point_test_failed(self) -> None:
timeout=self.mtcs.long_timeout,
)
self.mtcs.rem.mtm1m3.evt_hardpointTestStatus.flush.assert_called()
self.mtcs.rem.mtm1m3.evt_hardpointTestStatus.next.assert_awaited_with(
flush=False,
self.mtcs.rem.mtm1m3.evt_hardpointTestStatus.aget.assert_awaited_with(
timeout=self.mtcs.timeout_hardpoint_test_status,
)

async def test_run_m1m3_hard_point_test_timeout(self) -> None:
message = (
f"No heartbeat received from M1M3 in the last {self.mtcs.timeout_hardpoint_test_status}s"
" while waiting for hard point data information. Check CSC liveliness."
)
with unittest.mock.patch.object(
self.mtcs.rem.mtm1m3.evt_heartbeat,
"next",
side_effect=asyncio.TimeoutError,
):
with pytest.raises(RuntimeError, match=message):
await self.mtcs.run_m1m3_hard_point_test(hp=1)

async def test_stop_m1m3_hard_point_test(self) -> None:
await self.mtcs.stop_m1m3_hard_point_test(hp=1)

Expand Down

0 comments on commit 4319525

Please sign in to comment.