feat: deliver durable live signal intents
This commit is contained in:
@@ -338,6 +338,12 @@ layer = "integration"
|
||||
status = "implemented"
|
||||
tests = ["test/integration/clientagent/clientagent_integration_test.go:TestControlStdinIntentReplaysAndAcknowledges_HP_DISPATCH_08"]
|
||||
|
||||
[[requirements]]
|
||||
id = "HP-SIGNAL-01"
|
||||
layer = "integration"
|
||||
status = "implemented"
|
||||
tests = ["test/integration/clientagent/clientagent_integration_test.go:TestControlStdinIntentReplaysAndAcknowledges_HP_DISPATCH_08"]
|
||||
|
||||
[[requirements]]
|
||||
id = "HP-EVENT-01"
|
||||
layer = "unit"
|
||||
|
||||
@@ -300,6 +300,30 @@ func TestControlStdinIntentReplaysAndAcknowledges_HP_DISPATCH_08(t *testing.T) {
|
||||
if err := persistence.DB().QueryRow(`SELECT acknowledged FROM stdin_writes WHERE issue_uuid = ? AND write_seq = 2`, parsedIssue[:]).Scan(&closeAcknowledged); err != nil || closeAcknowledged != 1 {
|
||||
t.Fatalf("stdin close acknowledgement = %d, %v", closeAcknowledged, err)
|
||||
}
|
||||
signalRequestID := fixedIssueID(0x7d)
|
||||
signalResponse, err := controlService.SignalCommand(ctx, &rvboxv1.ControlSignalCommandRequest{ClientId: hello.GetClientId(), IssueUuid: issue, RequestId: signalRequestID, Signal: rvboxv1.SignalKind_SIGNAL_TERM})
|
||||
if err != nil || signalResponse.GetCommandRevision() != 1 {
|
||||
t.Fatalf("active signal request = %#v, %v", signalResponse, err)
|
||||
}
|
||||
encoded, err = transport.Read(readContext)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
signalEnvelope, err := agentproto.DecodeEnvelope(encoded, agentproto.DefaultLimits(), rvboxv1.Platform_PLATFORM_WINDOWS)
|
||||
if err != nil || signalEnvelope.GetSignalCommand() == nil || signalEnvelope.GetSignalCommand().GetIssueUuid() != issue || signalEnvelope.GetSignalCommand().GetCommandRevision() != 1 || signalEnvelope.GetSignalCommand().GetSignal() != rvboxv1.SignalKind_SIGNAL_TERM {
|
||||
t.Fatalf("signal delivery = %#v, %v", signalEnvelope, err)
|
||||
}
|
||||
signalAck := &rvboxv1.CommandEvent{IssueUuid: issue, EventSeq: 3, ObservedAt: timestamppb.Now(), Payload: &rvboxv1.CommandEvent_SignalResult{SignalResult: &rvboxv1.SignalResult{Signal: rvboxv1.SignalKind_SIGNAL_TERM, Accepted: true, GracefulDeliveryAttempted: true, CommandRevision: 1, Detail: "delivered"}}}
|
||||
if err := agent.SendCommandEvent(ctx, transport, accepted, signalAck, agentproto.DefaultLimits()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := transport.Read(readContext); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var signalAcknowledged int
|
||||
if err := persistence.DB().QueryRow(`SELECT acknowledged FROM signal_intents WHERE issue_uuid = ? AND command_revision = 1 AND signal = ?`, parsedIssue[:], rvboxv1.SignalKind_SIGNAL_TERM).Scan(&signalAcknowledged); err != nil || signalAcknowledged != 1 {
|
||||
t.Fatalf("signal acknowledgement = %d, %v", signalAcknowledged, err)
|
||||
}
|
||||
}
|
||||
|
||||
func fixedIssueID(last byte) string {
|
||||
|
||||
@@ -67,13 +67,13 @@ func TestRealSQLiteInitializationAndRestart_HP_STORE_01(t *testing.T) {
|
||||
if err := rows.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
want := []string{"audit_events", "clients", "command_events", "command_payloads", "command_tombstones", "commands", "control_mutations", "output_segments", "output_truncations", "schema_migrations", "sessions", "stdin_writes", "storage_counters", "storage_incidents", "takeover_authorizations"}
|
||||
want := []string{"audit_events", "clients", "command_events", "command_payloads", "command_tombstones", "commands", "control_mutations", "output_segments", "output_truncations", "schema_migrations", "sessions", "signal_intents", "stdin_writes", "storage_counters", "storage_incidents", "takeover_authorizations"}
|
||||
sort.Strings(want)
|
||||
if strings.Join(names, ",") != strings.Join(want, ",") {
|
||||
t.Fatalf("tables = %v, want %v", names, want)
|
||||
}
|
||||
var migrationCount int
|
||||
if err := opened.DB().QueryRow(`SELECT count(*) FROM schema_migrations`).Scan(&migrationCount); err != nil || migrationCount != 1 {
|
||||
if err := opened.DB().QueryRow(`SELECT count(*) FROM schema_migrations`).Scan(&migrationCount); err != nil || migrationCount != 2 {
|
||||
t.Fatalf("migration count = %d, err = %v", migrationCount, err)
|
||||
}
|
||||
if err := opened.Close(); err != nil {
|
||||
@@ -81,7 +81,7 @@ func TestRealSQLiteInitializationAndRestart_HP_STORE_01(t *testing.T) {
|
||||
}
|
||||
|
||||
reopened := openStore(t, dataDir)
|
||||
if err := reopened.DB().QueryRow(`SELECT count(*) FROM schema_migrations`).Scan(&migrationCount); err != nil || migrationCount != 1 {
|
||||
if err := reopened.DB().QueryRow(`SELECT count(*) FROM schema_migrations`).Scan(&migrationCount); err != nil || migrationCount != 2 {
|
||||
t.Fatalf("reopened migration count = %d, err = %v", migrationCount, err)
|
||||
}
|
||||
if err := reopened.Close(); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user