fix(hands,jobs): суточная сводка уходит и в чистые сутки, норма всплеска замирает на молодости беды
This commit is contained in:
1 parent
d89e24ae09
commit
06b4119ad3
2 files changed
+202
-36
No files matched your search
@@ -4,6 +4,9 @@ from beaver_agent.hands.komodo import Komodo
|
||||
from beaver_agent.hands.komodo_logs import (
|
||||
KEEP,
|
||||
SELF_MARK,
|
||||
SURGE_CEILING,
|
||||
SURGE_FACTOR,
|
||||
SURGE_MIN,
|
||||
Seen,
|
||||
StackScan,
|
||||
Sweep,
|
||||
@@ -531,7 +534,7 @@ def test_a_continuing_trouble_comes_back_in_the_daily_summary(tmp_path):
|
||||
assert night.summary and len(night.ongoing) == 1
|
||||
assert night.new == () and not night.worth_telling
|
||||
text = daily(night, UTC)
|
||||
assert "длящееся, сводка за 2026-09-21" in text
|
||||
assert "сводка за 2026-09-20" in text # числа - про закрывшиеся сутки
|
||||
assert "gitea/svc ошибка, с 20.09 09:00, за сутки 5, первые сутки" in text
|
||||
assert "ERROR" not in text # образцов строк в сводке нет намеренно
|
||||
told(state, night)
|
||||
@@ -657,3 +660,71 @@ def test_the_summary_folds_the_variants_of_one_service_into_one_row(tmp_path):
|
||||
text = daily(night, UTC)
|
||||
assert "Идёт до сих пор: 1 рядов (3 разных строк)" in text
|
||||
assert "gitea/svc ошибка, строк 3 видов, с 20.09 09:00, за сутки 12" in text
|
||||
|
||||
|
||||
def test_the_daily_summary_arrives_even_when_all_is_quiet(tmp_path):
|
||||
# Мёртвый джоб и чистый флот должны выглядеть по-разному.
|
||||
state = seen(tmp_path)
|
||||
for hour in (10, 13, 16, 19, 22):
|
||||
digest(state, swept([read_stack("gitea", log())], at=at(20, hour)))
|
||||
night = digest(state, swept([read_stack("gitea", log())], at=at(21, 1, 40)))
|
||||
assert night.summary and night.ongoing == ()
|
||||
assert not night.worth_telling # обычного инжекта нет, суточный - есть
|
||||
text = daily(night, UTC)
|
||||
assert text.splitlines() == [
|
||||
"Логи флота: сводка за 2026-09-20.",
|
||||
"Проходов за сутки 5 из 8 ожидавшихся; в последнем прочитано 1 стеков "
|
||||
"из 1 в области (dell-home, personal-main).",
|
||||
"Длящегося нет: всё, о чём я говорил, стихло или не повторялось.",
|
||||
]
|
||||
|
||||
|
||||
def test_the_daily_summary_counts_the_refusals(tmp_path):
|
||||
state = seen(tmp_path)
|
||||
digest(state, swept([StackScan(stack="gitea", error="timeout")], at=at(20, 10)))
|
||||
digest(state, Sweep(at=at(20, 13), unreachable="OSError: нет связи"))
|
||||
night = digest(state, swept([read_stack("gitea", log())], at=at(21, 1, 40)))
|
||||
assert (
|
||||
"Отказов доступа за те сутки: чтений стеков 1, проходов без ответа Komodo 1"
|
||||
in daily(night, UTC)
|
||||
)
|
||||
|
||||
|
||||
def test_a_slowly_growing_trouble_still_breaks_through(tmp_path):
|
||||
# Варёная лягушка: норма замерла на молодости беды и за ростом не тянется.
|
||||
state = seen(tmp_path)
|
||||
told(state, digest(state, swept([burst("gitea", stamps(20, 8, 1))], at=at(20, 9))))
|
||||
counts = [1, 1, 2, 3, 4, 6, 9, 13]
|
||||
hour = 10
|
||||
seen_times = stamps(20, 8, 1)
|
||||
surged = []
|
||||
for n in counts:
|
||||
seen_times = seen_times + stamps(20, hour - 1, n, start=10)
|
||||
report = digest(state, swept([burst("gitea", seen_times)], at=at(20, hour)))
|
||||
if report.surge:
|
||||
surged.append((hour, report.surge[0].gain, report.surge[0].norm))
|
||||
told(state, report)
|
||||
hour += 1
|
||||
(entry,) = state.entries.values()
|
||||
assert entry.norm == 1.0 # заморожена по первым трём активным проходам
|
||||
assert surged and surged[0][1] >= SURGE_MIN
|
||||
assert surged[0][2] == 1.0
|
||||
|
||||
|
||||
def test_the_ceiling_fires_without_any_relative_norm(tmp_path):
|
||||
# Беда, чья собственная норма уже огромна: относительный порог её не возьмёт.
|
||||
state = seen(tmp_path)
|
||||
times = stamps(20, 8, 40)
|
||||
told(state, digest(state, swept([burst("gitea", times)], at=at(20, 9))))
|
||||
for hour in (12, 15):
|
||||
times = times + stamps(20, hour - 1, 40, start=10)
|
||||
digest(state, swept([burst("gitea", times)], at=at(20, hour)))
|
||||
(entry,) = state.entries.values()
|
||||
assert entry.norm == 40.0
|
||||
huge = stamps(20, 17, 55, start=0)
|
||||
spike = digest(state, swept([burst("gitea", times + huge)], at=at(20, 18)))
|
||||
(item,) = spike.surge
|
||||
assert item.gain == 55 # 55 < 4 × 40, взял потолок, а не кратность
|
||||
assert item.gain < SURGE_FACTOR * item.norm
|
||||
assert item.gain >= SURGE_CEILING
|
||||
assert "Всплеск знакомого (1)" in brief(spike)
|
||||
Reference in new issue
Block a user