aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver-test
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2026-03-20 00:10:22 +0100
committerStefan Boberg <[email protected]>2026-03-20 00:10:22 +0100
commitacbec2de68598fd64179387158d4c808220241cf (patch)
tree6e88c2aadd4b428887fec5bca96ed7fa0bf4d97d /src/zenserver-test
parentFix HordeClient to use HttpClientAccessToken constructor (diff)
downloadzen-sb/compute-auth.tar.xz
zen-sb/compute-auth.zip
Consolidate action map locks and fix immediate query visibilitysb/compute-auth
Replace three separate RwLocks (m_PendingLock, m_RunningLock, m_ResultsLock) with a single m_ActionMapLock guarding all three action maps. This eliminates lock-ordering requirements and prevents actions from being temporarily absent from all maps during state transitions. Additionally, insert actions into m_PendingActions immediately during EnqueueResolvedAction so they are visible to GetActionResult and FindActionResult right away, without waiting for the scheduler thread to process the update. Previously, eager clients could get a spurious 404 if they queried before the scheduler's HandleActionUpdates ran. Also adds debug logging for worker manifest, process launch and exit on Windows, and ANSI color helper macros for log formatting.
Diffstat (limited to 'src/zenserver-test')
-rw-r--r--src/zenserver-test/compute-tests.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/zenserver-test/compute-tests.cpp b/src/zenserver-test/compute-tests.cpp
index d088c2bee..e522ed203 100644
--- a/src/zenserver-test/compute-tests.cpp
+++ b/src/zenserver-test/compute-tests.cpp
@@ -2542,6 +2542,41 @@ TEST_CASE("function.retract_http")
fmt::format("Second retract failed: status={}, body={}", int(RetractResp2.StatusCode), RetractResp2.ToText()));
}
+TEST_CASE("function.session.immediate_query_after_enqueue")
+{
+ // Verify that actions are immediately visible to GetActionResult and
+ // FindActionResult right after enqueue, without waiting for the
+ // scheduler thread to process the update.
+
+ InMemoryChunkResolver Resolver;
+ ScopedTemporaryDirectory SessionBaseDir;
+ zen::compute::ComputeServiceSession Session(Resolver);
+ Session.Ready();
+
+ CbPackage WorkerPackage = BuildWorkerPackage(TestEnv, Resolver);
+ Session.RegisterWorker(WorkerPackage);
+
+ CbObject ActionObj = BuildRot13ActionForSession("immediate-query"sv, Resolver);
+
+ auto EnqueueRes = Session.EnqueueAction(ActionObj, 0);
+ REQUIRE_MESSAGE(EnqueueRes, "Failed to enqueue action");
+
+ // Query by LSN immediately — must not return NotFound
+ CbPackage Result;
+ HttpResponseCode Code = Session.GetActionResult(EnqueueRes.Lsn, Result);
+ CHECK_MESSAGE(Code == HttpResponseCode::Accepted,
+ fmt::format("GetActionResult returned {} immediately after enqueue, expected Accepted", int(Code)));
+
+ // Query by ActionId immediately — must not return NotFound
+ const IoHash ActionId = ActionObj.GetHash();
+ CbPackage FindResult;
+ HttpResponseCode FindCode = Session.FindActionResult(ActionId, FindResult);
+ CHECK_MESSAGE(FindCode == HttpResponseCode::Accepted,
+ fmt::format("FindActionResult returned {} immediately after enqueue, expected Accepted", int(FindCode)));
+
+ Session.Shutdown();
+}
+
TEST_SUITE_END();
} // namespace zen::tests::compute