Relay current process output without spool
This commit is contained in:
@@ -404,6 +404,33 @@ func TestWorkerSpoolHooksUseRegisteredSession(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLiveLogSinkQueuesCurrentBatchWithoutDurableSpool(t *testing.T) {
|
||||
client := &recordingLiveLogClient{received: make(chan protocol.LogBatchIngestRequest, 1)}
|
||||
sink := NewLiveLogSink(client)
|
||||
sink.SetSession("run-test", "session-token")
|
||||
t.Cleanup(sink.Close)
|
||||
assignment := protocol.RunJobAssignment{
|
||||
JobID: "execution-job",
|
||||
RunEndpointID: "run-test",
|
||||
ServerInstanceID: "server-worker",
|
||||
Capability: protocol.RunCapabilityProcessStart,
|
||||
LogSessionID: "generation-current",
|
||||
SessionStartedAt: workerTestTime(),
|
||||
ExecutionInput: protocol.RunJobExecutionInput{LogSources: []protocol.RuntimeLogSourcePlan{{Kind: "process.stdout", StreamKey: "game.console.stdout"}}},
|
||||
}
|
||||
if err := sink.Append(context.Background(), assignment, "stdout", "current output"); err != nil {
|
||||
t.Fatalf("append live log: %v", err)
|
||||
}
|
||||
select {
|
||||
case batch := <-client.received:
|
||||
if batch.LogStreamID != "run.run-test.server-worker.generation-current.game.console.stdout" || batch.FirstSeq != 1 || batch.LastSeq != 1 || batch.Checksum == "" || len(batch.Entries) != 1 || batch.Entries[0].Line != "current output" {
|
||||
t.Fatalf("unexpected live batch: %+v", batch)
|
||||
}
|
||||
case <-time.After(time.Second):
|
||||
t.Fatal("live log was not dispatched")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSpoolLogSinkUsesRunScopedStreamForAutonomousLifecycle(t *testing.T) {
|
||||
logSpool, err := spool.NewLogSpool(t.TempDir())
|
||||
if err != nil {
|
||||
@@ -898,6 +925,15 @@ type recordingDurableLogClient struct {
|
||||
err error
|
||||
}
|
||||
|
||||
type recordingLiveLogClient struct {
|
||||
received chan protocol.LogBatchIngestRequest
|
||||
}
|
||||
|
||||
func (client *recordingLiveLogClient) RelayLiveLogBatch(_ context.Context, batch protocol.LogBatchIngestRequest) (protocol.LogBatchIngestResponse, error) {
|
||||
client.received <- batch
|
||||
return protocol.LogBatchIngestResponse{Accepted: true, LogStreamID: batch.LogStreamID, AcceptedFrom: batch.FirstSeq, AcceptedTo: batch.LastSeq}, nil
|
||||
}
|
||||
|
||||
func (client *recordingDurableLogClient) IngestLogBatch(_ context.Context, batch protocol.LogBatchIngestRequest) (protocol.LogBatchIngestResponse, error) {
|
||||
client.batch = batch
|
||||
if client.err != nil {
|
||||
|
||||
Reference in New Issue
Block a user