feat: apply lifecycle events atomically
This commit is contained in:
@@ -109,6 +109,13 @@ func TestWebSocketDispatchAfterReconciliation_HP_DISPATCH_03(t *testing.T) {
|
||||
if dispatch == nil || dispatch.GetIssueUuid() != issue.String() || dispatch.GetCommandRevision() != 1 || dispatch.GetTargetSessionGeneration() != accepted.Generation || !proto.Equal(dispatch.GetSpec(), spec) || string(dispatch.GetImmutableRequestSha256()) != string(requestHash[:]) {
|
||||
t.Fatalf("dispatch = %#v", dispatch)
|
||||
}
|
||||
acceptedEnvelope, err := proto.Marshal(&rvboxv1.AgentEnvelope{SessionId: accepted.ID, SessionGeneration: accepted.Generation, Payload: &rvboxv1.AgentEnvelope_CommandAccepted{CommandAccepted: &rvboxv1.CommandAccepted{IssueUuid: issue.String(), CommandRevision: 1, Accepted: true}}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := transport.Write(ctx, acceptedEnvelope); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
event := &rvboxv1.CommandEvent{IssueUuid: issue.String(), EventSeq: 1, ObservedAt: timestamppb.Now(), Payload: &rvboxv1.CommandEvent_Lifecycle{Lifecycle: &rvboxv1.LifecycleChange{Lifecycle: rvboxv1.CommandLifecycle_COMMAND_RUNNING, CommandRevision: 1}}}
|
||||
if err := agent.SendCommandEvent(ctx, transport, accepted, event, agentproto.DefaultLimits()); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -125,4 +132,8 @@ func TestWebSocketDispatchAfterReconciliation_HP_DISPATCH_03(t *testing.T) {
|
||||
if err := persistence.DB().QueryRow(`SELECT count(*) FROM command_events WHERE issue_uuid = ?`, issue[:]).Scan(&persistedEvents); err != nil || persistedEvents != 1 {
|
||||
t.Fatalf("persisted events = %d, %v", persistedEvents, err)
|
||||
}
|
||||
var lifecycle uint32
|
||||
if err := persistence.DB().QueryRow(`SELECT lifecycle FROM commands WHERE issue_uuid = ?`, issue[:]).Scan(&lifecycle); err != nil || lifecycle != uint32(rvboxv1.CommandLifecycle_COMMAND_RUNNING) {
|
||||
t.Fatalf("command lifecycle = %d, %v", lifecycle, err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user