From 214d4e43d26c4fbd8f05c44aa758022c495b41ca Mon Sep 17 00:00:00 2001 From: cabbage Date: Sun, 6 Sep 2026 09:19:51 +0000 Subject: [PATCH] test: cover durable command event acknowledgement --- .../clientagent/clientagent_integration_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/integration/clientagent/clientagent_integration_test.go b/test/integration/clientagent/clientagent_integration_test.go index 52f8413..eb2e0e6 100644 --- a/test/integration/clientagent/clientagent_integration_test.go +++ b/test/integration/clientagent/clientagent_integration_test.go @@ -109,4 +109,20 @@ 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) } + 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) + } + encoded, err = transport.Read(readContext) + if err != nil { + t.Fatal(err) + } + envelope, err = agentproto.DecodeEnvelope(encoded, agentproto.DefaultLimits(), rvboxv1.Platform_PLATFORM_WINDOWS) + if err != nil || envelope.GetEventAck() == nil || envelope.GetEventAck().GetIssueUuid() != issue.String() || envelope.GetEventAck().GetThroughEventSeq() != 1 { + t.Fatalf("event acknowledgement = %#v, %v", envelope, err) + } + var persistedEvents int + 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) + } }