refactor: simplify architecture and harden lifecycle

Remove obsolete implementations, centralize background task ownership and terminal-state recovery, consolidate frontend routing and log streaming, and enforce project-wide verification in CI.
This commit is contained in:
Awuqing
2026-08-26 11:32:00 +08:00
parent 95b27af600
commit c06bbec383
189 changed files with 8983 additions and 4264 deletions
+29
View File
@@ -18,8 +18,35 @@ import (
"time"
"backupx/server/internal/storage"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"go.uber.org/zap/zaptest/observer"
)
func TestReportRecordFailureUsesFinalizationContextAndLogsUpdateError(t *testing.T) {
requestCount := 0
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
requestCount++
http.Error(w, "master unavailable", http.StatusServiceUnavailable)
}))
defer server.Close()
core, observed := observer.New(zapcore.ErrorLevel)
executor := NewExecutor(NewMasterClient(server.URL, "token", false), t.TempDir())
executor.SetLogger(zap.New(core))
ctx, cancel := context.WithCancel(context.Background())
cancel()
executor.reportRecordFailure(ctx, 42, "backup failed")
if requestCount != 1 {
t.Fatalf("terminal update requests = %d, want 1 despite canceled command context", requestCount)
}
if observed.Len() != 1 || observed.All()[0].Message != "report backup failure to master failed" {
t.Fatalf("observed logs = %#v", observed.All())
}
}
func TestBuildBackupTaskSpecParsesJSONSourcePaths(t *testing.T) {
spec := &TaskSpec{
TaskID: 7,
@@ -323,6 +350,8 @@ func (f *agentTestStorageFactory) Type() storage.ProviderType {
return "agent_test_storage"
}
func (f *agentTestStorageFactory) SensitiveFields() []string { return nil }
func (f *agentTestStorageFactory) New(_ context.Context, config map[string]any) (storage.StorageProvider, error) {
name, _ := config["name"].(string)
provider := f.providers[name]