Version: CI now tags images YYYY.MM.DD-<shortsha> alongside :latest/:sha and passes GIT_SHA/BUILD_TAG build-args; the running app reports them via dashboard /api/health and admin /api/status (TrueNAS custom apps only show 'custom/1.0.0', so the app self-reports what it actually runs). Config parity: every scheduler-run script (nightly_tune, eod_replay, premarket_eval, regime, market_context, experiments cli) now loads config_overrides at startup like the live services do — a bare env would replay under DEFAULT exits (the documented 4.5x-baseline landmine). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
43 lines
1.4 KiB
Python
43 lines
1.4 KiB
Python
"""DB-backed config overrides: table CRUD + boot precedence."""
|
|
|
|
import os
|
|
|
|
import pytest
|
|
|
|
from runtime import env_overrides
|
|
from storage.event_store import EventStore
|
|
|
|
|
|
@pytest.fixture
|
|
def con():
|
|
s = EventStore(":memory:")
|
|
yield s.con
|
|
s.close()
|
|
|
|
|
|
def test_write_read_roundtrip_and_delete(con):
|
|
merged = env_overrides.write_db_overrides(
|
|
{"TRADING_MAX_ORDERS_PER_TICK": "3", "TRIGGER_RVOL_MIN": "1.5"}, con=con)
|
|
assert merged == {"TRADING_MAX_ORDERS_PER_TICK": "3", "TRIGGER_RVOL_MIN": "1.5"}
|
|
merged = env_overrides.write_db_overrides(
|
|
{"TRIGGER_RVOL_MIN": None, "TRADING_MAX_ORDERS_PER_TICK": "5"}, con=con)
|
|
assert merged == {"TRADING_MAX_ORDERS_PER_TICK": "5"}
|
|
|
|
|
|
def test_read_missing_table_is_empty(con):
|
|
assert env_overrides.read_db_overrides(con=con) == {}
|
|
|
|
|
|
def test_load_db_applies_onto_environ(con, monkeypatch):
|
|
monkeypatch.setenv("ENV_OVERRIDES_DB", "1") # force on (harness may disable)
|
|
env_overrides.write_db_overrides({"TRADING_TEST_KNOB_XYZ": "42"}, con=con)
|
|
monkeypatch.setattr(env_overrides, "_db_con", lambda: con)
|
|
monkeypatch.setenv("TRADING_TEST_KNOB_XYZ", "1") # compose value loses
|
|
n = env_overrides.load_db()
|
|
assert n == 1 and os.environ["TRADING_TEST_KNOB_XYZ"] == "42"
|
|
|
|
|
|
def test_load_db_kill_switch(monkeypatch):
|
|
monkeypatch.setenv("ENV_OVERRIDES_DB", "0")
|
|
assert env_overrides.load_db() == 0
|