Engine holds for a rename: the pipeline refuses publish and inline cascades with EngineHeld once those running have finished, the execution service stops claiming and its timers once claimed cascades have finished; both wait without a limit, report what is busy and can be aborted. REST answers 503 with Retry-After, a device frame busy. Redis adds no longer wait for each other, only a queue hold waits for them
This commit is contained in:
@@ -3,6 +3,7 @@ and 3 of docs/private/id_refac_rename.md). Memory always, Redis with
|
||||
FLUKSIO_TEST_REDIS_HOST (and optional PORT)."""
|
||||
|
||||
import os
|
||||
import threading
|
||||
import uuid
|
||||
|
||||
import pytest
|
||||
@@ -218,6 +219,36 @@ def test_held_work_is_released_in_order_behind_older_work(queue):
|
||||
]
|
||||
|
||||
|
||||
def test_a_hold_waits_for_an_add_already_writing_to_the_stream(
|
||||
redis_queue, monkeypatch
|
||||
):
|
||||
"""Adds do not wait for each other, but a hold waits for them, so no
|
||||
entry lands in a stream after the rebuild has read it."""
|
||||
writing, finish = threading.Event(), threading.Event()
|
||||
xadd = redis_queue._redis.xadd
|
||||
|
||||
def slow(*args, **kwargs):
|
||||
writing.set()
|
||||
finish.wait(5)
|
||||
return xadd(*args, **kwargs)
|
||||
|
||||
monkeypatch.setattr(redis_queue._redis, "xadd", slow)
|
||||
adding = threading.Thread(target=redis_queue.add, args=(item("heat.a"),))
|
||||
adding.start()
|
||||
assert writing.wait(5)
|
||||
holding = threading.Thread(target=redis_queue.hold)
|
||||
holding.start()
|
||||
holding.join(0.2)
|
||||
assert holding.is_alive()
|
||||
|
||||
finish.set()
|
||||
holding.join(5)
|
||||
adding.join(5)
|
||||
assert redis_queue.count(HEAT)["queue_items"] == 1
|
||||
assert redis_queue.held
|
||||
redis_queue.release()
|
||||
|
||||
|
||||
def test_a_guarded_timer_still_finds_its_guard(queue):
|
||||
state = MemoryState()
|
||||
state["__node__:heat.limit:generation"] = 3
|
||||
|
||||
Reference in New Issue
Block a user