feat: execute durable client commands through supervisor
This commit is contained in:
@@ -6,6 +6,9 @@ import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
rvboxv1 "github.com/rvbox/rvbox/gen/go/rvbox/v1"
|
||||
"github.com/rvbox/rvbox/internal/domain"
|
||||
)
|
||||
|
||||
func TestCheckSpoolPayloadsAndCounters_HP_CLIENT_09(t *testing.T) {
|
||||
@@ -46,3 +49,33 @@ func TestCheckSpoolRejectsCounterDrift_BH_CLIENT_03(t *testing.T) {
|
||||
t.Fatalf("counter-drift Check error = %v, want ErrQuotaCounterMismatch", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRecoverLaunchUncertaintyFencesRedispatchAfterRestart_HP_CLIENT_12(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
store := openTestStore(t, ctx, filepath.Join(t.TempDir(), "spool"), DefaultTombstoneLimit)
|
||||
issue := testUUID(t, "019c46f1-1d02-7000-8000-000000000043")
|
||||
command := testCommand(issue, []byte("uncertain launch"))
|
||||
command.Phase = uint32(rvboxv1.CommandLifecycle_COMMAND_ACCEPTED)
|
||||
now := time.Date(2026, time.September, 6, 12, 0, 0, 0, time.UTC)
|
||||
if _, err := store.AcceptCommand(ctx, command, now); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := store.SetLaunchPhase(ctx, issue, domain.LaunchPhaseAuthorized, "LOCAL_SYSTEM", 42); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
recovered, err := store.RecoverLaunchUncertainty(ctx, now.Add(time.Second))
|
||||
if err != nil || len(recovered) != 1 || recovered[0] != issue {
|
||||
t.Fatalf("recovered = %v, %v", recovered, err)
|
||||
}
|
||||
var phase, launchPhase uint32
|
||||
if err := store.db.QueryRow(`SELECT phase, launch_phase FROM commands WHERE issue_uuid = ?`, issue[:]).Scan(&phase, &launchPhase); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if phase != uint32(rvboxv1.CommandLifecycle_COMMAND_INTERRUPTED) || launchPhase != 0 {
|
||||
t.Fatalf("recovered phase/barrier = %d/%d", phase, launchPhase)
|
||||
}
|
||||
if second, err := store.RecoverLaunchUncertainty(ctx, now.Add(2*time.Second)); err != nil || len(second) != 0 {
|
||||
t.Fatalf("recovery repeated = %v, %v", second, err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user