Доработайте публикацию и сверку вложений по итогам ревью
This commit is contained in:
@@ -209,7 +209,8 @@ func (f *reconcileFixture) run(apply, deep bool) (attachment.Stats, []attachment
|
||||
f.t.Fatal(err)
|
||||
}
|
||||
var found []attachment.Finding
|
||||
stats, err := r.Run(context.Background(), apply, deep, func(v attachment.Finding) { found = append(found, v) })
|
||||
options := attachment.ReconcileOptions{Apply: apply, Deep: deep}
|
||||
stats, err := r.Run(context.Background(), options, func(v attachment.Finding) { found = append(found, v) })
|
||||
return stats, found, err
|
||||
}
|
||||
|
||||
@@ -221,6 +222,28 @@ func TestReconciler(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer db.Close()
|
||||
t.Run("healthy apply does not block publication", func(t *testing.T) {
|
||||
f := reconcileSetup(t, db)
|
||||
hash := f.file("healthy", "ready", 2*time.Hour, true, true)
|
||||
tx, err := db.Pool.Begin(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer tx.Rollback(ctx)
|
||||
if err := attachment.LockHash(ctx, tx, hash); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
r, err := attachment.NewReconciler(f.db, f.b, time.Hour)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
scanCtx, cancel := context.WithTimeout(ctx, 2*time.Second)
|
||||
defer cancel()
|
||||
stats, err := r.Run(scanCtx, attachment.ReconcileOptions{Apply: true, Deep: true}, nil)
|
||||
if err != nil || stats.Findings != 0 || stats.Repaired != 0 {
|
||||
t.Fatalf("healthy inspection waited for publication: %+v %v", stats, err)
|
||||
}
|
||||
})
|
||||
t.Run("constructor validates and defaults grace", func(t *testing.T) {
|
||||
f := reconcileSetup(t, db)
|
||||
for _, grace := range []time.Duration{-time.Second, time.Minute} {
|
||||
@@ -361,7 +384,7 @@ func TestReconciler(t *testing.T) {
|
||||
done := make(chan error, 1)
|
||||
go func() {
|
||||
r, _ := attachment.NewReconciler(f.db, f.b, 0)
|
||||
_, err := r.Run(ctx, true, false, nil)
|
||||
_, err := r.Run(ctx, attachment.ReconcileOptions{Apply: true}, nil)
|
||||
done <- err
|
||||
}()
|
||||
waitReconcileLock(t, ctx, f.db)
|
||||
@@ -395,7 +418,7 @@ func TestReconciler(t *testing.T) {
|
||||
done := make(chan error, 1)
|
||||
go func() {
|
||||
r, _ := attachment.NewReconciler(f.db, f.b, 0)
|
||||
_, err := r.Run(ctx, true, false, nil)
|
||||
_, err := r.Run(ctx, attachment.ReconcileOptions{Apply: true}, nil)
|
||||
done <- err
|
||||
}()
|
||||
waitReconcileLock(t, ctx, f.db)
|
||||
@@ -592,7 +615,7 @@ func TestReconcilerFailureBoundaries(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
stats, err := r.Run(ctx, false, true, nil)
|
||||
stats, err := r.Run(ctx, attachment.ReconcileOptions{Deep: true}, nil)
|
||||
if err != nil || stats.Findings != 1 || stats.Repaired != 0 || f.status(hash) != "ready" {
|
||||
t.Fatalf("read only dry run: %+v %v", stats, err)
|
||||
}
|
||||
@@ -681,11 +704,11 @@ func TestReconcilerS3(t *testing.T) {
|
||||
t.Fatalf("CLI mutated by default: %+v %v", cliStats, err)
|
||||
}
|
||||
var found []attachment.Finding
|
||||
stats, err := r.Run(ctx, false, true, func(v attachment.Finding) { found = append(found, v) })
|
||||
stats, err := r.Run(ctx, attachment.ReconcileOptions{Deep: true}, func(v attachment.Finding) { found = append(found, v) })
|
||||
if err != nil || stats.Repaired != 0 || stats.Findings != 2 || f.status(missing) != "ready" {
|
||||
t.Fatalf("S3 dry: %+v %v %+v", stats, err, found)
|
||||
}
|
||||
stats, err = r.Run(ctx, true, true, nil)
|
||||
stats, err = r.Run(ctx, attachment.ReconcileOptions{Apply: true, Deep: true}, nil)
|
||||
if err != nil || stats.Repaired != 1 || f.status(missing) != "failed" || f.status(hash) != "ready" {
|
||||
t.Fatalf("S3 apply: %+v %v", stats, err)
|
||||
}
|
||||
@@ -695,7 +718,7 @@ func TestReconcilerS3(t *testing.T) {
|
||||
if _, err = s3.Store.Stat(ctx, "staging/fresh"); err != nil {
|
||||
t.Fatal("fresh staging deleted", err)
|
||||
}
|
||||
stats, err = r.Run(ctx, true, true, nil)
|
||||
stats, err = r.Run(ctx, attachment.ReconcileOptions{Apply: true, Deep: true}, nil)
|
||||
if err != nil || stats.Repaired != 0 {
|
||||
t.Fatalf("S3 repeat: %+v %v", stats, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user