Skip to content

Commit 41fde1e

Browse files
committed
wip
1 parent 94734b9 commit 41fde1e

3 files changed

Lines changed: 409 additions & 53 deletions

File tree

feature_integration_tests/test_cases/tests/basic/test_orchestartion_with_persistency.py

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,211 @@ def test_kvs_write_results(self, temp_dir: Path, run_count: int):
5757
kvs_file = temp_dir / "kvs_1_0.json"
5858
data = json.loads(kvs_file.read_text())
5959
assert data["v"]["run_cycle_number"]["v"] == run_count
60+
61+
62+
class TestConcurrentKVS(FitScenario):
63+
"""
64+
Tests orchestration with persistency scenario using multiple KVS files.
65+
"""
66+
67+
@pytest.fixture(scope="class")
68+
def scenario_name(self) -> str:
69+
return "basic.concurrent_kvs"
70+
71+
@pytest.fixture(scope="class", params=[1, 5])
72+
def run_count(self, request) -> int:
73+
return request.param
74+
75+
@pytest.fixture(scope="class")
76+
def temp_dir(
77+
self,
78+
tmp_path_factory: pytest.TempPathFactory,
79+
run_count: int, # run_count is required to ensure proper order of fixture calls
80+
) -> Generator[Path, None, None]:
81+
yield from temp_dir_common(tmp_path_factory, self.__class__.__name__)
82+
83+
@pytest.fixture(scope="class")
84+
def test_config(self, run_count: int, temp_dir: Path) -> dict[str, Any]:
85+
return {
86+
"runtime": {"task_queue_size": 2, "workers": 4},
87+
"test": {"run_count": run_count, "kvs_path": str(temp_dir)},
88+
}
89+
90+
def test_kvs_logged_execution(self, run_count: int, logs_info_level: LogContainer):
91+
"""Verify that all runs have been logged."""
92+
logs = logs_info_level.get_logs(field="run_cycle_number")
93+
for log_group in logs.group_by("kvs_instance_id").values():
94+
logged_cycles = [log.run_cycle_number for log in log_group]
95+
expected_cycles = list(range(1, run_count + 1))
96+
assert logged_cycles == expected_cycles
97+
98+
def test_kvs_write_results(self, temp_dir: Path, run_count: int):
99+
"""Verify that each KVS file contains correct final run count."""
100+
# Verify KVS Instance(1)
101+
kvs1_file = temp_dir / "kvs_1_0.json"
102+
data1 = json.loads(kvs1_file.read_text())
103+
assert data1["v"]["run_cycle_number"]["v"] == run_count
104+
105+
# Verify KVS Instance(2)
106+
kvs2_file = temp_dir / "kvs_2_0.json"
107+
data2 = json.loads(kvs2_file.read_text())
108+
assert data2["v"]["run_cycle_number"]["v"] == run_count
109+
110+
# Verify KVS Instance(3)
111+
kvs3_file = temp_dir / "kvs_3_0.json"
112+
data3 = json.loads(kvs3_file.read_text())
113+
assert data3["v"]["run_cycle_number"]["v"] == run_count
114+
115+
116+
class TestMultipleKVS(FitScenario):
117+
"""
118+
Tests orchestration with persistency scenario using multiple KVS files.
119+
"""
120+
121+
@pytest.fixture(scope="class")
122+
def scenario_name(self) -> str:
123+
return "basic.multiple_kvs"
124+
125+
@pytest.fixture(scope="class")
126+
def run_count(self) -> int:
127+
return 1
128+
129+
@pytest.fixture(scope="class")
130+
def temp_dir(
131+
self,
132+
tmp_path_factory: pytest.TempPathFactory,
133+
run_count: int, # run_count is required to ensure proper order of fixture calls
134+
) -> Generator[Path, None, None]:
135+
yield from temp_dir_common(tmp_path_factory, self.__class__.__name__)
136+
137+
@pytest.fixture(scope="class")
138+
def test_config(self, run_count: int, temp_dir: Path) -> dict[str, Any]:
139+
return {
140+
"runtime": {"task_queue_size": 256, "workers": 4},
141+
"test": {"run_count": run_count, "kvs_path": str(temp_dir)},
142+
}
143+
144+
def test_kvs_cycle_write_results(self, temp_dir: Path, run_count: int):
145+
"""Verify that each KVS file contains correct final run count."""
146+
# Verify KVS Instance(1)
147+
kvs1_file = temp_dir / "kvs_1_0.json"
148+
data1 = json.loads(kvs1_file.read_text())
149+
assert data1["v"]["run_cycle_number"]["v"] == run_count
150+
151+
def test_kvs_write_i32_max(self, temp_dir: Path):
152+
"""Verify that each KVS file contains correct final run count."""
153+
# Verify KVS Instance(2)
154+
kvs2_file = temp_dir / "kvs_2_0.json"
155+
data2 = json.loads(kvs2_file.read_text())
156+
assert data2["v"]["key_i32_max"]["v"] == 2147483647
157+
assert data2["v"]["key_i32_max"]["t"] == "i32"
158+
159+
def test_kvs_write_i32_min(self, temp_dir: Path):
160+
"""Verify that each KVS file contains correct final run count."""
161+
# Verify KVS Instance(2)
162+
kvs2_file = temp_dir / "kvs_2_0.json"
163+
data2 = json.loads(kvs2_file.read_text())
164+
assert data2["v"]["key_i32_min"]["v"] == -2147483648
165+
assert data2["v"]["key_i32_min"]["t"] == "i32"
166+
167+
def test_kvs_write_u32_max(self, temp_dir: Path):
168+
"""Verify that each KVS file contains correct final run count."""
169+
# Verify KVS Instance(2)
170+
kvs2_file = temp_dir / "kvs_2_0.json"
171+
data2 = json.loads(kvs2_file.read_text())
172+
assert data2["v"]["key_u32_max"]["v"] == 4294967295
173+
assert data2["v"]["key_u32_max"]["t"] == "u32"
174+
175+
def test_kvs_write_u32_min(self, temp_dir: Path):
176+
"""Verify that each KVS file contains correct final run count."""
177+
# Verify KVS Instance(2)
178+
kvs2_file = temp_dir / "kvs_2_0.json"
179+
data2 = json.loads(kvs2_file.read_text())
180+
assert data2["v"]["key_u32_min"]["v"] == 0
181+
assert data2["v"]["key_u32_min"]["t"] == "u32"
182+
183+
def test_kvs_write_i64_max(self, temp_dir: Path):
184+
"""Verify that each KVS file contains correct final run count."""
185+
# Verify KVS Instance(2)
186+
kvs2_file = temp_dir / "kvs_2_0.json"
187+
data2 = json.loads(kvs2_file.read_text())
188+
assert data2["v"]["key_i64_max"]["v"] == 9223372036854775807
189+
assert data2["v"]["key_i64_max"]["t"] == "i64"
190+
191+
def test_kvs_write_i64_min(self, temp_dir: Path):
192+
"""Verify that each KVS file contains correct final run count."""
193+
# Verify KVS Instance(2)
194+
kvs2_file = temp_dir / "kvs_2_0.json"
195+
data2 = json.loads(kvs2_file.read_text())
196+
assert data2["v"]["key_i64_min"]["v"] == -9223372036854775808
197+
assert data2["v"]["key_i64_min"]["t"] == "i64"
198+
199+
def test_kvs_write_u64_max(self, temp_dir: Path):
200+
"""Verify that each KVS file contains correct final run count."""
201+
# Verify KVS Instance(2)
202+
kvs2_file = temp_dir / "kvs_2_0.json"
203+
data2 = json.loads(kvs2_file.read_text())
204+
assert data2["v"]["key_u64_max"]["v"] == 18446744073709551615
205+
assert data2["v"]["key_u64_max"]["t"] == "u64"
206+
207+
def test_kvs_write_u64_min(self, temp_dir: Path):
208+
"""Verify that each KVS file contains correct final run count."""
209+
# Verify KVS Instance(2)
210+
kvs2_file = temp_dir / "kvs_2_0.json"
211+
data2 = json.loads(kvs2_file.read_text())
212+
assert data2["v"]["key_u64_min"]["v"] == 0
213+
assert data2["v"]["key_u64_min"]["t"] == "u64"
214+
215+
def test_kvs_write_f64(self, temp_dir: Path):
216+
"""Verify that each KVS file contains correct final run count."""
217+
# Verify KVS Instance(2)
218+
kvs2_file = temp_dir / "kvs_2_0.json"
219+
data2 = json.loads(kvs2_file.read_text())
220+
assert data2["v"]["key_f64"]["v"] == 1.2345
221+
assert data2["v"]["key_f64"]["t"] == "f64"
222+
223+
def test_kvs_write_bool(self, temp_dir: Path):
224+
"""Verify that each KVS file contains correct final run count."""
225+
# Verify KVS Instance(2)
226+
kvs2_file = temp_dir / "kvs_2_0.json"
227+
data2 = json.loads(kvs2_file.read_text())
228+
assert data2["v"]["key_bool"]["v"] == True # noqa: E712
229+
assert data2["v"]["key_bool"]["t"] == "bool"
230+
231+
def test_kvs_write_string(self, temp_dir: Path):
232+
"""Verify that each KVS file contains correct final run count."""
233+
# Verify KVS Instance(2)
234+
kvs2_file = temp_dir / "kvs_2_0.json"
235+
data2 = json.loads(kvs2_file.read_text())
236+
assert data2["v"]["key_String"]["v"] == "TestString"
237+
assert data2["v"]["key_String"]["t"] == "str"
238+
239+
def test_kvs_write_null(self, temp_dir: Path):
240+
"""Verify that each KVS file contains correct final run count."""
241+
# Verify KVS Instance(2)
242+
kvs2_file = temp_dir / "kvs_2_0.json"
243+
data2 = json.loads(kvs2_file.read_text())
244+
assert data2["v"]["key_Null"]["v"] is None
245+
assert data2["v"]["key_Null"]["t"] == "null"
246+
247+
def test_kvs_write_array(self, temp_dir: Path):
248+
"""Verify that each KVS file contains correct final run count."""
249+
# Verify KVS Instance(2)
250+
kvs2_file = temp_dir / "kvs_2_0.json"
251+
data2 = json.loads(kvs2_file.read_text())
252+
assert data2["v"]["key_Array"]["v"] == [
253+
{"t": "i32", "v": 1},
254+
{"t": "i32", "v": 2},
255+
{"t": "i32", "v": 3},
256+
]
257+
assert data2["v"]["key_Array"]["t"] == "arr"
258+
259+
def test_kvs_write_map(self, temp_dir: Path):
260+
"""Verify that each KVS file contains correct final run count."""
261+
# Verify KVS Instance(2)
262+
kvs2_file = temp_dir / "kvs_2_0.json"
263+
data2 = json.loads(kvs2_file.read_text())
264+
assert data2["v"]["key_Map"]["v"] == {
265+
"inner_key": {"t": "i32", "v": 1},
266+
}
267+
assert data2["v"]["key_Map"]["t"] == "obj"

feature_integration_tests/test_scenarios/rust/src/scenarios/basic/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ mod orchestration_with_persistency;
1616
pub fn basic_scenario_group() -> Box<dyn ScenarioGroup> {
1717
Box::new(ScenarioGroupImpl::new(
1818
"basic",
19-
vec![Box::new(
20-
orchestration_with_persistency::OrchestrationWithPersistency,
21-
)],
19+
vec![
20+
Box::new(orchestration_with_persistency::OrchestrationWithPersistency),
21+
Box::new(orchestration_with_persistency::ConcurrentKvsOrchestrationWithPersistency),
22+
Box::new(orchestration_with_persistency::MultipleKvsOrchestrationWithPersistency),
23+
],
2224
vec![],
2325
))
2426
}

0 commit comments

Comments
 (0)