fix: serialize deployment revision writes
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -67,6 +68,32 @@ def test_file_store_round_trips_deployment(tmp_path) -> None:
|
||||
assert loaded.binding_map()["context7"] == "context7.personal"
|
||||
|
||||
|
||||
def test_concurrent_deployment_saves_advance_revision_without_lost_updates(
|
||||
tmp_path,
|
||||
) -> None:
|
||||
store = FileWorkflowArtifactStore(tmp_path)
|
||||
store.save_deployment(
|
||||
WorkflowDeployment(
|
||||
id="concurrent.personal",
|
||||
artifact_id="summarize_docs",
|
||||
artifact_version=1,
|
||||
)
|
||||
)
|
||||
updates = [
|
||||
WorkflowDeployment(
|
||||
id="concurrent.personal",
|
||||
artifact_id="summarize_docs",
|
||||
artifact_version=version,
|
||||
)
|
||||
for version in range(2, 10)
|
||||
]
|
||||
|
||||
with ThreadPoolExecutor(max_workers=len(updates)) as executor:
|
||||
list(executor.map(store.save_deployment, updates))
|
||||
|
||||
assert store.get_deployment("concurrent.personal").revision == 9
|
||||
|
||||
|
||||
def test_file_store_loads_legacy_artifact_and_rewrites_canonical_shape(
|
||||
tmp_path,
|
||||
) -> None:
|
||||
|
||||
Reference in New Issue
Block a user