From 1e10a943b2d6192db58ea67a00070d35b723e262 Mon Sep 17 00:00:00 2001 From: Rogee Date: Mon, 24 Aug 2026 14:21:30 +0800 Subject: [PATCH] test(HH-609): decouple rollback watchdog Co-authored-by: multica-agent --- internal/bootstrap/bootstrap_test.go | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/internal/bootstrap/bootstrap_test.go b/internal/bootstrap/bootstrap_test.go index 0f1990b..e5aab69 100644 --- a/internal/bootstrap/bootstrap_test.go +++ b/internal/bootstrap/bootstrap_test.go @@ -282,16 +282,25 @@ func TestRunStopsServicesWhenRollbackReloadFails(t *testing.T) { })) defer server.Close() - ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond) + runResult := make(chan error, 1) + ctx, cancel := context.WithCancel(context.Background()) defer cancel() - err := Run(ctx, RuntimeConfig{ - CoreBinary: binary, - SSClashBinary: binary, - ConfigSource: config, - RuntimeDir: filepath.Join(tempDir, "runtime"), - SubscriptionURL: server.URL, - UpdateInterval: 20 * time.Millisecond, - }) + go func() { + runResult <- Run(ctx, RuntimeConfig{ + CoreBinary: binary, + SSClashBinary: binary, + ConfigSource: config, + RuntimeDir: filepath.Join(tempDir, "runtime"), + SubscriptionURL: server.URL, + UpdateInterval: 20 * time.Millisecond, + }) + }() + var err error + select { + case err = <-runResult: + case <-time.After(5 * time.Second): + t.Fatal("Run() did not reach rollback failure") + } if !errors.Is(err, errMihomoStateUncertain) { t.Fatalf("Run() error = %v, want uncertain Mihomo state", err) }