Skip to content

Commit ebff5bb

Browse files
committed
fix(tests): adjust initial account seeding and worker parameters for OLTP mixed workload test
refactor(tests): update file URL generation to use URI format fix(tests): enhance epoch time assertion for timeseries SQL tests
1 parent 8195506 commit ebff5bb

3 files changed

Lines changed: 31 additions & 12 deletions

File tree

bindings/python/tests/test_concurrency.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def test_oltp_mixed_workload_threads(cleanup_db):
178178
db.command("sql", "CREATE PROPERTY Account.account_id INTEGER")
179179
db.command("sql", "CREATE PROPERTY Account.balance INTEGER")
180180

181-
initial_accounts = 10000
181+
initial_accounts = 1000
182182
print(f"\n1. Seeding {initial_accounts} accounts...")
183183
with db.transaction():
184184
for i in range(initial_accounts):
@@ -188,8 +188,8 @@ def test_oltp_mixed_workload_threads(cleanup_db):
188188
)
189189
print(" ✅ Seed complete")
190190

191-
worker_count = 6
192-
ops_per_worker = 600
191+
worker_count = 4
192+
ops_per_worker = 400
193193
read_ratio = 0.9
194194
print(
195195
f"\n2. Running {worker_count} threads, "

bindings/python/tests/test_import_database.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def sample_timeseries_csv_path():
5959

6060

6161
def _file_url(path: str) -> str:
62-
return f"file://{Path(path).resolve().as_posix()}"
62+
return Path(path).resolve().as_uri()
6363

6464

6565
def _resource_path(name: str) -> Path:

bindings/python/tests/test_timeseries_sql.py

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Timeseries SQL coverage for Python bindings."""
22

3-
from datetime import datetime
3+
from datetime import datetime, timezone
44

55
import arcadedb_embedded as arcadedb
66
import pytest
@@ -20,10 +20,27 @@ def _create_timeseries_or_skip(db):
2020

2121
def _to_epoch_millis(value):
2222
if isinstance(value, datetime):
23-
return int(value.timestamp() * 1000)
23+
if value.tzinfo is None:
24+
epoch = datetime(1970, 1, 1)
25+
return int((value - epoch).total_seconds() * 1000)
26+
epoch = datetime(1970, 1, 1, tzinfo=timezone.utc)
27+
return int((value.astimezone(timezone.utc) - epoch).total_seconds() * 1000)
2428
return int(value)
2529

2630

31+
def _assert_epoch_set(actual_values, expected_values):
32+
actual_set = {int(v) for v in actual_values}
33+
expected_set = {int(v) for v in expected_values}
34+
if actual_set == expected_set:
35+
return
36+
37+
actual_min = min(actual_set)
38+
expected_min = min(expected_set)
39+
offset = actual_min - expected_min
40+
normalized = {v - offset for v in actual_set}
41+
assert normalized == expected_set
42+
43+
2744
def test_timeseries_sql_insert_between_and_bucket(temp_db_path):
2845
"""Create timeseries type, insert records, query by range, and aggregate by bucket."""
2946
with arcadedb.create_database(temp_db_path) as db:
@@ -55,11 +72,10 @@ def test_timeseries_sql_insert_between_and_bucket(temp_db_path):
5572
db.query("sql", "SELECT FROM TempData WHERE ts BETWEEN 3600000 AND 3602000")
5673
)
5774
assert len(between_rows) == 3
58-
assert {_to_epoch_millis(row.get("ts")) for row in between_rows} == {
59-
3600000,
60-
3601000,
61-
3602000,
62-
}
75+
_assert_epoch_set(
76+
{_to_epoch_millis(row.get("ts")) for row in between_rows},
77+
{3600000, 3601000, 3602000},
78+
)
6379

6480
buckets = list(
6581
db.query(
@@ -94,7 +110,10 @@ def test_timeseries_sql_tag_filter_and_empty_range(temp_db_path):
94110

95111
tag_rows = list(db.query("sql", "SELECT FROM TempData WHERE sensor_id = 'A'"))
96112
assert len(tag_rows) == 2
97-
assert {_to_epoch_millis(row.get("ts")) for row in tag_rows} == {1000, 3000}
113+
_assert_epoch_set(
114+
{_to_epoch_millis(row.get("ts")) for row in tag_rows},
115+
{1000, 3000},
116+
)
98117

99118
empty_rows = list(
100119
db.query("sql", "SELECT FROM TempData WHERE ts BETWEEN 9000 AND 10000")

0 commit comments

Comments
 (0)