keep discoverds fileds in separate sqlite
This commit is contained in:
@@ -163,6 +163,35 @@ class MonitorTests(unittest.TestCase):
|
||||
self.assertEqual(status["profile_suggestions"][0]["profile_advisor"]["status"], "heuristic")
|
||||
self.assertIn("timeout", status["profile_suggestions"][0]["profile_advisor"]["error"])
|
||||
|
||||
def test_profile_suggestions_use_cached_discovered_fields(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
history_path = str(Path(tmp) / "history.sqlite3")
|
||||
incidents = str(Path(tmp) / "incidents.json")
|
||||
first = Path(tmp) / "first.log"
|
||||
first.write_text(
|
||||
"\n".join(
|
||||
f"fgai_stream_id=app fgai_stream=App lcs_actor=user{index % 4} lcs_result=r{index % 3} action=ok"
|
||||
for index in range(1, 20)
|
||||
),
|
||||
encoding="utf-8",
|
||||
)
|
||||
build_status(str(first), history_path=history_path, incident_path=incidents)
|
||||
second = Path(tmp) / "second.log"
|
||||
second.write_text(
|
||||
"\n".join(
|
||||
f"fgai_stream_id=app fgai_stream=App action=ok"
|
||||
for _index in range(1, 5)
|
||||
),
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
status = build_status(str(second), history_path=history_path, incident_path=incidents)
|
||||
|
||||
suggestion = status["profile_suggestions"][0]
|
||||
self.assertIn("lcs_actor", suggestion["entity_fields"])
|
||||
self.assertIn("lcs_result", suggestion["categorical_fields"])
|
||||
self.assertGreater(status["baseline"]["discovery_cache_events"], 0)
|
||||
|
||||
def test_cached_status_with_error_keeps_last_good_dashboard_data(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
cache_path = str(Path(tmp) / "status-cache.sqlite3")
|
||||
|
||||
Reference in New Issue
Block a user