mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-11-30 17:42:32 +01:00
Keep alert eventlog test fixtures inside normal retention (#5193)
**Keep alert eventlog test fixtures inside normal retention** v6.10.0-beta.1 release run 45748685025 failed backend_tests on both attempts because TestAlertSnoozeIsDurableAndEnforcedByDeliveryPolicy anchored its eventlog fixture at 2026-08-27 12:00 UTC, which crossed the 90-day startup pruning cutoff on 2026-11-26. Switch that test and the remaining hardcoded 2026 eventlog fixtures in internal/alerts to relative UTC anchors while keeping live retention pruning unchanged. Contract-Neutral: Test-only fixture timestamps; no alert history, retention, or CI gate behavior changes. **Retry transient prior-stage API reads and classify failures safely** Attempt 2 of v6.10.0-beta.1 (job 139696369412) stopped in previous_private_stage.py with an opaque read error even though Attempt 1's log uniquely acknowledged child run 45748982422. Add bounded retries for transient HTTP 429/5xx, timeout, and network read errors while failing closed immediately on permanent errors with a sanitized stage and status summary. Contract-Neutral: Retry transient prior-stage read failures and classify safe read diagnostics without changing release prerequisites, dispatch payload, child identity, or fail-closed staging gates. --- Fleet candidate `20261126T161026Z-delivery-trust` from the `delivery-trust` lane. Reviewed tip `535dd228af1bf41f97b571ff3691b3627a4410ec` on `main`. [How Pulse handles triage](https://github.com/rcourtman/Pulse/blob/main/docs/AI_TRANSPARENCY.md)
This commit is contained in:
@@ -16,7 +16,8 @@ func TestCriticalEscalationRepeatsAtFinalLevelUntilAcknowledged(t *testing.T) {
|
||||
t.Fatalf("open in-memory event log: %v", err)
|
||||
}
|
||||
m.SetEventLog(store)
|
||||
now := time.Date(2026, time.August, 27, 18, 0, 0, 0, time.UTC)
|
||||
// Keep fixture timestamps inside the 90-day eventlog retention window.
|
||||
now := time.Now().UTC().Truncate(time.Second).Add(-2 * time.Hour)
|
||||
m.now = func() time.Time { return now }
|
||||
|
||||
cfg := m.GetConfig()
|
||||
@@ -97,7 +98,8 @@ func TestCriticalEscalationRepeatsAtFinalLevelUntilAcknowledged(t *testing.T) {
|
||||
|
||||
func TestEscalationRepeatSkipsWarningAlerts(t *testing.T) {
|
||||
m := newTestManager(t)
|
||||
now := time.Date(2026, time.August, 27, 18, 0, 0, 0, time.UTC)
|
||||
// Keep fixture timestamps inside the 90-day eventlog retention window.
|
||||
now := time.Now().UTC().Truncate(time.Second).Add(-2 * time.Hour)
|
||||
m.now = func() time.Time { return now }
|
||||
m.mu.Lock()
|
||||
m.config.Enabled = true
|
||||
|
||||
@@ -27,7 +27,7 @@ func testActiveEvent(t *testing.T, eventType, alertID string, startedAt, occurre
|
||||
|
||||
func TestLifecycleEventsTransactionallyProjectActiveState(t *testing.T) {
|
||||
store := newTestStore(t)
|
||||
startedAt := time.Date(2026, 8, 27, 8, 0, 0, 0, time.UTC)
|
||||
startedAt := time.Now().UTC().Truncate(time.Second).Add(-2 * time.Hour)
|
||||
|
||||
if err := store.AppendDurable(testActiveEvent(t, TypeFired, "alert-1", startedAt, startedAt, 91)); err != nil {
|
||||
t.Fatalf("append fired: %v", err)
|
||||
@@ -71,7 +71,7 @@ func TestLifecycleEventsTransactionallyProjectActiveState(t *testing.T) {
|
||||
|
||||
func TestDelayedResolutionCannotDeleteNewerOccurrence(t *testing.T) {
|
||||
store := newTestStore(t)
|
||||
oldStart := time.Date(2026, 8, 27, 8, 0, 0, 0, time.UTC)
|
||||
oldStart := time.Now().UTC().Truncate(time.Second).Add(-2 * time.Hour)
|
||||
newStart := oldStart.Add(time.Hour)
|
||||
|
||||
if err := store.AppendDurable(testActiveEvent(t, TypeFired, "reused-alert", oldStart, oldStart, 91)); err != nil {
|
||||
@@ -95,7 +95,7 @@ func TestDelayedResolutionCannotDeleteNewerOccurrence(t *testing.T) {
|
||||
|
||||
func TestStaleCheckpointCannotOverwriteLifecycleTransaction(t *testing.T) {
|
||||
store := newTestStore(t)
|
||||
startedAt := time.Date(2026, 8, 27, 8, 0, 0, 0, time.UTC)
|
||||
startedAt := time.Now().UTC().Truncate(time.Second).Add(-2 * time.Hour)
|
||||
activeEvent := testActiveEvent(t, TypeFired, "cas-alert", startedAt, startedAt, 91)
|
||||
initial := ActiveStateSnapshot{
|
||||
AlertID: activeEvent.AlertID,
|
||||
|
||||
@@ -383,15 +383,20 @@ func referenceWindowedHistory(t *testing.T, m *Manager, since time.Time, limit i
|
||||
return m.applyCurrentNodeDisplayNames(canonicalizeAlertHistoryForOutput(results))
|
||||
}
|
||||
|
||||
// recentHistoryParityBase anchors eventlog fixtures inside the 90-day
|
||||
// retention window so background startup pruning does not drop test rows.
|
||||
func recentHistoryParityBase() time.Time {
|
||||
return time.Now().UTC().Truncate(time.Second).Add(-48 * time.Hour)
|
||||
}
|
||||
|
||||
// writeRandomHistory appends a lifecycle history with acknowledgements on
|
||||
// both sides of window boundaries, out-of-order LastSeen values, uneven
|
||||
// fractional seconds (so RFC3339Nano text order and time order can differ),
|
||||
// same-instant events and a history clear. It returns every event time.
|
||||
func writeRandomHistory(t *testing.T, m *Manager, seed int64) []time.Time {
|
||||
func writeRandomHistory(t *testing.T, m *Manager, seed int64, base time.Time) []time.Time {
|
||||
t.Helper()
|
||||
rng := rand.New(rand.NewSource(seed))
|
||||
store := m.eventLogStore()
|
||||
base := time.Date(2026, 9, 1, 0, 0, 0, 0, time.UTC)
|
||||
kinds := []string{
|
||||
eventlog.TypeFired, eventlog.TypeRefired, eventlog.TypeAcknowledged,
|
||||
eventlog.TypeUnacknowledged, eventlog.TypeSnoozed, eventlog.TypeEscalated, eventlog.TypeResolved,
|
||||
@@ -439,12 +444,13 @@ func TestWindowedHistoryMatchesAWalkOfOnlyTheWindow(t *testing.T) {
|
||||
for seed := int64(1); seed <= 25; seed++ {
|
||||
t.Run(fmt.Sprintf("seed-%d", seed), func(t *testing.T) {
|
||||
m := newHistoryParityManager(t)
|
||||
times := writeRandomHistory(t, m, seed)
|
||||
base := recentHistoryParityBase()
|
||||
times := writeRandomHistory(t, m, seed, base)
|
||||
// Live overlay: one alert the log knows (with a fresh value) and
|
||||
// one it never saw fire.
|
||||
m.mu.Lock()
|
||||
m.activeAlerts["live-known"] = &Alert{ID: "alert-1", ResourceID: "vm-alert-1",
|
||||
StartTime: time.Date(2026, 9, 1, 1, 0, 0, 0, time.UTC), LastSeen: times[len(times)-1], Value: 999}
|
||||
StartTime: base.Add(time.Hour), LastSeen: times[len(times)-1], Value: 999}
|
||||
m.activeAlerts["live-new"] = &Alert{ID: "alert-new", ResourceID: "vm-new",
|
||||
StartTime: times[len(times)/2], LastSeen: times[len(times)-1], Value: 7}
|
||||
m.mu.Unlock()
|
||||
@@ -472,7 +478,7 @@ func TestWindowedHistoryMatchesAWalkOfOnlyTheWindow(t *testing.T) {
|
||||
|
||||
func TestWindowedHistoryReusesTheFullHistoryFold(t *testing.T) {
|
||||
m := newHistoryParityManager(t)
|
||||
times := writeRandomHistory(t, m, 7)
|
||||
times := writeRandomHistory(t, m, 7, recentHistoryParityBase())
|
||||
if _, ok := m.AlertHistoryFromEvents(time.Time{}, 0); !ok {
|
||||
t.Fatal("history unavailable")
|
||||
}
|
||||
@@ -497,10 +503,11 @@ func TestWindowedHistoryReusesTheFullHistoryFold(t *testing.T) {
|
||||
|
||||
func TestHistoryReadResultsDoNotAliasTheSharedFold(t *testing.T) {
|
||||
m := newHistoryParityManager(t)
|
||||
times := writeRandomHistory(t, m, 11)
|
||||
base := recentHistoryParityBase()
|
||||
times := writeRandomHistory(t, m, 11, base)
|
||||
m.mu.Lock()
|
||||
m.activeAlerts["live-known"] = &Alert{ID: "alert-2", ResourceID: "vm-alert-2",
|
||||
StartTime: time.Date(2026, 9, 1, 2, 0, 0, 0, time.UTC), LastSeen: times[len(times)-1]}
|
||||
StartTime: base.Add(2 * time.Hour), LastSeen: times[len(times)-1]}
|
||||
m.mu.Unlock()
|
||||
for _, since := range []time.Time{{}, times[30], times[100]} {
|
||||
first, _ := m.AlertHistoryFromEvents(since, 0)
|
||||
@@ -522,7 +529,7 @@ func TestHistoryReadResultsDoNotAliasTheSharedFold(t *testing.T) {
|
||||
func TestLimitedHistoryReadCopiesOnlyReturnedRows(t *testing.T) {
|
||||
m := newHistoryParityManager(t)
|
||||
store := m.eventLogStore()
|
||||
at := time.Date(2026, 9, 1, 0, 0, 0, 0, time.UTC)
|
||||
at := recentHistoryParityBase()
|
||||
metadata := map[string]interface{}{}
|
||||
for i := 0; i < 40; i++ {
|
||||
metadata[fmt.Sprintf("key-%d", i)] = fmt.Sprintf("value-%d-with-some-detail", i)
|
||||
@@ -590,7 +597,7 @@ func TestNewestHistoryEvidenceChoosesByObservationTime(t *testing.T) {
|
||||
func TestHistoryEntriesKeepOnlyTheNewestEvidence(t *testing.T) {
|
||||
m := newHistoryParityManager(t)
|
||||
store := m.eventLogStore()
|
||||
start := time.Date(2026, 9, 1, 0, 0, 0, 0, time.UTC)
|
||||
start := recentHistoryParityBase()
|
||||
ids := make([]string, 0, 64)
|
||||
for i := 0; i < 64; i++ {
|
||||
ids = append(ids, fmt.Sprintf("ev-%02d", i))
|
||||
@@ -646,7 +653,7 @@ func TestHistoryEntriesKeepOnlyTheNewestEvidence(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHistoryOverlayKeepsOnlyTheNewestEvidence(t *testing.T) {
|
||||
start := time.Date(2026, 9, 1, 0, 0, 0, 0, time.UTC)
|
||||
start := recentHistoryParityBase()
|
||||
m := newHistoryParityManager(t)
|
||||
m.mu.Lock()
|
||||
m.activeAlerts["live"] = &Alert{ID: "cpu-1", ResourceID: "vm-2", StartTime: start, LastSeen: start,
|
||||
|
||||
@@ -68,7 +68,7 @@ func shadowDivergenceEvents(t *testing.T, manager *Manager) []eventlog.Event {
|
||||
// shadow reducer tracks the live manager exactly through the hooked paths.
|
||||
func TestShadowFeedNoDivergenceThroughFullCycle(t *testing.T) {
|
||||
manager := newShadowFeedManager(t)
|
||||
epoch := time.Date(2026, 8, 26, 12, 0, 0, 0, time.UTC)
|
||||
epoch := time.Now().UTC().Truncate(time.Second).Add(-2 * time.Hour)
|
||||
resourceID := "shadow-pbs-1"
|
||||
|
||||
// Fire after three offline confirmations.
|
||||
@@ -148,7 +148,7 @@ func TestShadowFeedSeedsFromActiveAlerts(t *testing.T) {
|
||||
manager.config.Enabled = true
|
||||
manager.mu.Unlock()
|
||||
|
||||
epoch := time.Date(2026, 8, 26, 12, 0, 0, 0, time.UTC)
|
||||
epoch := time.Now().UTC().Truncate(time.Second).Add(-2 * time.Hour)
|
||||
resourceID := "shadow-seeded-1"
|
||||
|
||||
// Fire before the feed exists (simulating restored state).
|
||||
|
||||
@@ -16,7 +16,7 @@ func shadowGuestManager(t *testing.T, grace bool) (*Manager, *atomic.Int64) {
|
||||
t.Helper()
|
||||
m := newShadowFeedManager(t)
|
||||
configureUnifiedEvalManager(t, m, unifiedEvalBaseConfig())
|
||||
epoch := time.Date(2026, 10, 25, 12, 0, 0, 0, time.UTC)
|
||||
epoch := time.Now().UTC().Truncate(time.Second).Add(-2 * time.Hour)
|
||||
tick := &atomic.Int64{}
|
||||
m.mu.Lock()
|
||||
m.now = func() time.Time { return epoch.Add(time.Duration(tick.Load())) }
|
||||
|
||||
@@ -17,7 +17,8 @@ func TestAlertSnoozeIsDurableAndEnforcedByDeliveryPolicy(t *testing.T) {
|
||||
}
|
||||
m.SetEventLog(store)
|
||||
|
||||
now := time.Date(2026, 8, 27, 12, 0, 0, 0, time.UTC)
|
||||
// Keep fixture timestamps inside the 90-day eventlog retention window.
|
||||
now := time.Now().UTC().Truncate(time.Second).Add(-2 * time.Hour)
|
||||
m.now = func() time.Time { return now }
|
||||
cfg := m.GetConfig()
|
||||
cfg.Enabled = true
|
||||
@@ -112,7 +113,8 @@ func TestUnsnoozeRestoresAcknowledgedState(t *testing.T) {
|
||||
|
||||
func TestSnoozeExpiryResumesEscalationWithoutReplayingMissedLevels(t *testing.T) {
|
||||
m := newTestManager(t)
|
||||
now := time.Date(2026, 8, 27, 12, 0, 0, 0, time.UTC)
|
||||
// Keep fixture timestamps inside the 90-day eventlog retention window.
|
||||
now := time.Now().UTC().Truncate(time.Second).Add(-2 * time.Hour)
|
||||
m.now = func() time.Time { return now }
|
||||
cfg := m.GetConfig()
|
||||
cfg.Enabled = true
|
||||
|
||||
@@ -8,12 +8,26 @@ import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
|
||||
JOB_NAME = "stage_private_pro_runtime"
|
||||
DISPATCH_STEP = "Dispatch private Pro runtime staging"
|
||||
RUN_ID = r"[1-9][0-9]{0,18}"
|
||||
FINISHED_DISPATCH = {"success", "failure", "cancelled", "timed_out", "startup_failure"}
|
||||
MAX_READ_ATTEMPTS = 3
|
||||
RETRY_DELAYS = (1.0, 2.0)
|
||||
HTTP_STATUS = re.compile(r"\bHTTP\s+([1-5][0-9]{2})\b")
|
||||
TRANSIENT_HTTP_CODES = frozenset({429, 500, 502, 503, 504})
|
||||
TRANSIENT_NETWORK_MARKERS = (
|
||||
"connection reset",
|
||||
"unexpected eof",
|
||||
"eof",
|
||||
"tls handshake timeout",
|
||||
"i/o timeout",
|
||||
"temporary failure",
|
||||
"no such host",
|
||||
)
|
||||
# GitHub's raw job log prefixes stdout lines with a UTC timestamp. Match
|
||||
# only the fixed acknowledgement from the POST step, not a later watcher,
|
||||
# script echoes, links, or child logs. Every attempt runs the same immutable
|
||||
@@ -29,11 +43,42 @@ class EvidenceError(ValueError):
|
||||
pass
|
||||
|
||||
|
||||
def read_api(endpoint: str) -> str:
|
||||
try:
|
||||
response = subprocess.run(["gh", "api", endpoint], capture_output=True, timeout=30, check=True)
|
||||
except (OSError, subprocess.SubprocessError):
|
||||
raise EvidenceError("could not read the exact prior staging job evidence") from None
|
||||
def _classify_read_error(exc: Exception) -> tuple[str, bool]:
|
||||
if isinstance(exc, subprocess.TimeoutExpired):
|
||||
return "timeout", True
|
||||
if isinstance(exc, subprocess.CalledProcessError):
|
||||
raw_stderr = exc.stderr
|
||||
if isinstance(raw_stderr, bytes):
|
||||
stderr_text = raw_stderr.decode("utf-8", errors="replace")
|
||||
else:
|
||||
stderr_text = str(raw_stderr or "")
|
||||
match = HTTP_STATUS.search(stderr_text)
|
||||
if match:
|
||||
status = int(match.group(1))
|
||||
return f"exit {exc.returncode}, HTTP {status}", status in TRANSIENT_HTTP_CODES
|
||||
lowered = stderr_text.lower()
|
||||
if any(marker in lowered for marker in TRANSIENT_NETWORK_MARKERS):
|
||||
return f"exit {exc.returncode}, transient network error", True
|
||||
return f"exit {exc.returncode}", False
|
||||
return "os-error", False
|
||||
|
||||
|
||||
def read_api(endpoint: str, label: str = "GitHub API") -> str:
|
||||
last_cause = "unknown"
|
||||
for attempt in range(MAX_READ_ATTEMPTS):
|
||||
try:
|
||||
response = subprocess.run(["gh", "api", endpoint], capture_output=True, timeout=30, check=True)
|
||||
break
|
||||
except (OSError, subprocess.SubprocessError) as exc:
|
||||
last_cause, retryable = _classify_read_error(exc)
|
||||
if retryable and attempt + 1 < MAX_READ_ATTEMPTS:
|
||||
delay = RETRY_DELAYS[min(attempt, len(RETRY_DELAYS) - 1)]
|
||||
if delay > 0:
|
||||
time.sleep(delay)
|
||||
continue
|
||||
raise EvidenceError(
|
||||
f"could not read the exact prior staging job evidence ({label}: {last_cause})"
|
||||
) from None
|
||||
if len(response.stdout) > 2 * 1024 * 1024:
|
||||
raise EvidenceError("prior staging job evidence exceeded the read limit")
|
||||
return response.stdout.decode("utf-8")
|
||||
@@ -50,7 +95,9 @@ def previous_child(repository: str, run_id: str, attempt: str, source: str) -> s
|
||||
|
||||
root = f"repos/{repository}/actions"
|
||||
for earlier in range(int(attempt) - 1, 0, -1):
|
||||
metadata = json.loads(read_api(f"{root}/runs/{run_id}/attempts/{earlier}/jobs?per_page=100"))
|
||||
metadata = json.loads(
|
||||
read_api(f"{root}/runs/{run_id}/attempts/{earlier}/jobs?per_page=100", f"attempt {earlier} job list")
|
||||
)
|
||||
jobs = metadata["jobs"]
|
||||
if not isinstance(jobs, list) or metadata["total_count"] != len(jobs):
|
||||
raise EvidenceError(f"incomplete attempt {earlier} job evidence")
|
||||
@@ -82,7 +129,9 @@ def previous_child(repository: str, run_id: str, attempt: str, source: str) -> s
|
||||
if job["conclusion"] == "skipped" or conclusion not in FINISHED_DISPATCH:
|
||||
raise EvidenceError(f"attempt {earlier} has no definite dispatch step result")
|
||||
|
||||
children = ACK.findall(read_api(f"{root}/jobs/{job_id}/logs"))
|
||||
children = ACK.findall(
|
||||
read_api(f"{root}/jobs/{job_id}/logs", f"attempt {earlier} staging job {job_id} log")
|
||||
)
|
||||
if len(children) != 1:
|
||||
raise EvidenceError(f"attempt {earlier} has no unique child acknowledgement; dispatch may have been accepted")
|
||||
return children[0]
|
||||
|
||||
@@ -1959,6 +1959,99 @@ else:
|
||||
assert_posts(calls, [1])
|
||||
self.assertEqual([(i, n) for i, k, n in calls if k == "watch"], [(1, 300)])
|
||||
|
||||
def test_previous_private_stage_retries_transient_reads_and_sanitizes_errors(self) -> None:
|
||||
"""Transient GitHub API read failures retry boundedly while permanent errors stop
|
||||
immediately with a sanitized stage and status classification."""
|
||||
import importlib.util
|
||||
from unittest import mock
|
||||
|
||||
spec = importlib.util.spec_from_file_location(
|
||||
"previous_private_stage_under_test",
|
||||
REPO_ROOT / "scripts/release_control/previous_private_stage.py",
|
||||
)
|
||||
assert spec and spec.loader
|
||||
mod = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(mod)
|
||||
|
||||
jobs_payload = json.dumps({
|
||||
"total_count": 1,
|
||||
"jobs": [{
|
||||
"name": "stage_private_pro_runtime",
|
||||
"id": 101,
|
||||
"run_id": 200,
|
||||
"run_attempt": 1,
|
||||
"head_sha": "a" * 40,
|
||||
"status": "completed",
|
||||
"conclusion": "failure",
|
||||
"steps": [{
|
||||
"name": "Dispatch private Pro runtime staging",
|
||||
"status": "completed",
|
||||
"conclusion": "success",
|
||||
}],
|
||||
}],
|
||||
}).encode("utf-8")
|
||||
log_payload = (
|
||||
b"2026-11-26T03:27:01.1208655Z "
|
||||
b"Acknowledged private Pro build dispatch run 45748982422 in rcourtman/pulse-enterprise.\n"
|
||||
)
|
||||
|
||||
# Transient HTTP 502 on the log read retries and recovers the exact child ID.
|
||||
calls: list[list[str]] = []
|
||||
|
||||
def flaky_log(cmd, **kwargs):
|
||||
calls.append(cmd)
|
||||
endpoint = cmd[2]
|
||||
if endpoint.endswith("/jobs?per_page=100"):
|
||||
return subprocess.CompletedProcess(cmd, 0, stdout=jobs_payload, stderr=b"")
|
||||
if len([c for c in calls if c[2].endswith("/logs")]) == 1:
|
||||
raise subprocess.CalledProcessError(
|
||||
1, cmd, stderr=b"gh: Bad Gateway (HTTP 502)\n"
|
||||
)
|
||||
return subprocess.CompletedProcess(cmd, 0, stdout=log_payload, stderr=b"")
|
||||
|
||||
with mock.patch.object(mod.subprocess, "run", side_effect=flaky_log), \
|
||||
mock.patch.object(mod, "RETRY_DELAYS", (0.0, 0.0)):
|
||||
child = mod.previous_child("rcourtman/Pulse", "200", "2", "a" * 40)
|
||||
self.assertEqual(child, "45748982422")
|
||||
self.assertEqual(len([c for c in calls if c[2].endswith("/logs")]), 2)
|
||||
|
||||
# Persistent transient HTTP 503 exhausts bounded retries and fails closed.
|
||||
calls.clear()
|
||||
|
||||
def persistent_503(cmd, **kwargs):
|
||||
calls.append(cmd)
|
||||
if cmd[2].endswith("/jobs?per_page=100"):
|
||||
return subprocess.CompletedProcess(cmd, 0, stdout=jobs_payload, stderr=b"")
|
||||
raise subprocess.CalledProcessError(
|
||||
1, cmd, stderr=b"gh: Service Unavailable (HTTP 503)\n"
|
||||
)
|
||||
|
||||
with mock.patch.object(mod.subprocess, "run", side_effect=persistent_503), \
|
||||
mock.patch.object(mod, "RETRY_DELAYS", (0.0, 0.0)):
|
||||
with self.assertRaises(mod.EvidenceError) as ctx:
|
||||
mod.previous_child("rcourtman/Pulse", "200", "2", "a" * 40)
|
||||
self.assertEqual(len([c for c in calls if c[2].endswith("/logs")]), mod.MAX_READ_ATTEMPTS)
|
||||
self.assertIn("attempt 1 staging job 101 log: exit 1, HTTP 503", str(ctx.exception))
|
||||
|
||||
# Non-transient HTTP 403 stops on the first attempt without leaking raw stderr.
|
||||
calls.clear()
|
||||
|
||||
def forbidden_log(cmd, **kwargs):
|
||||
calls.append(cmd)
|
||||
if cmd[2].endswith("/jobs?per_page=100"):
|
||||
return subprocess.CompletedProcess(cmd, 0, stdout=jobs_payload, stderr=b"")
|
||||
raise subprocess.CalledProcessError(
|
||||
1, cmd, stderr=b"gh: Resource not accessible by integration (HTTP 403) secret-token-marker\n"
|
||||
)
|
||||
|
||||
with mock.patch.object(mod.subprocess, "run", side_effect=forbidden_log), \
|
||||
mock.patch.object(mod, "RETRY_DELAYS", (0.0, 0.0)):
|
||||
with self.assertRaises(mod.EvidenceError) as ctx:
|
||||
mod.previous_child("rcourtman/Pulse", "200", "2", "a" * 40)
|
||||
self.assertEqual(len([c for c in calls if c[2].endswith("/logs")]), 1)
|
||||
self.assertIn("attempt 1 staging job 101 log: exit 1, HTTP 403", str(ctx.exception))
|
||||
self.assertNotIn("secret-token-marker", str(ctx.exception))
|
||||
|
||||
def test_private_pro_promotion_redispatches_only_a_moved_main_source_refusal(self) -> None:
|
||||
"""Run the real dispatch loop against doubles: only a pre-credential refusal caused by a
|
||||
pulse-pro main that moved after dispatch is re-dispatched, and only the terminal failure
|
||||
|
||||
Reference in New Issue
Block a user