Accept sessioned autonomous run logs
This commit is contained in:
@@ -150,7 +150,7 @@ func (svc *CoreService) ensureRunLogStreamForBatch(batch domain.LogBatchIngest,
|
|||||||
expectedStreamID = runSessionLogStreamID(batch.RunEndpointID, batch.ServerInstanceID, batch.LogSessionID, batch.StreamKey)
|
expectedStreamID = runSessionLogStreamID(batch.RunEndpointID, batch.ServerInstanceID, batch.LogSessionID, batch.StreamKey)
|
||||||
}
|
}
|
||||||
if batch.LogStreamID != expectedStreamID {
|
if batch.LogStreamID != expectedStreamID {
|
||||||
if batch.LogSessionID != "" || !legacyAutonomousLogStream(batch) {
|
if !legacyAutonomousLogStream(batch) {
|
||||||
return repo.ErrNotFound
|
return repo.ErrNotFound
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -441,14 +441,25 @@ func TestCoreServiceAcceptsLegacyAutonomousJobLogStreamWithoutPlatformJob(t *tes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCoreServiceRejectsSessionMetadataOnLegacyAutonomousStreamID(t *testing.T) {
|
func TestCoreServiceAcceptsSessionMetadataOnLegacyAutonomousStreamID(t *testing.T) {
|
||||||
svc, sessionToken := newRegisteredLogIngestService(t)
|
svc, sessionToken := newRegisteredLogIngestService(t)
|
||||||
batch := validLogBatch(t, sessionToken, 1, 1)
|
batch := validLogBatch(t, sessionToken, 1, 1)
|
||||||
batch.LogStreamID = jobLogStreamID("autonomous-bootstrap-start", "stdout")
|
batch.LogStreamID = jobLogStreamID("autonomous-bootstrap-start", "stdout")
|
||||||
batch.LogSessionID = "session-a"
|
batch.LogSessionID = "session-a"
|
||||||
batch.SessionStartedAt = time.Date(2026, 7, 3, 12, 30, 0, 0, time.UTC)
|
batch.SessionStartedAt = time.Date(2026, 7, 3, 12, 30, 0, 0, time.UTC)
|
||||||
if _, err := svc.IngestLogBatch(batch); err == nil {
|
ack, err := svc.IngestLogBatch(batch)
|
||||||
t.Fatal("expected session-scoped batch with legacy autonomous stream ID to be rejected")
|
if err != nil {
|
||||||
|
t.Fatalf("ingest session-scoped legacy autonomous stream: %v", err)
|
||||||
|
}
|
||||||
|
if !ack.Accepted || ack.LogStreamID != batch.LogStreamID || ack.LatestSeq != batch.LastSeq {
|
||||||
|
t.Fatalf("unexpected legacy autonomous session ack: %+v", ack)
|
||||||
|
}
|
||||||
|
stream, err := svc.GetLogStream(batch.LogStreamID)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("get session-scoped legacy autonomous stream: %v", err)
|
||||||
|
}
|
||||||
|
if stream.LogSessionID != batch.LogSessionID || !stream.SessionStartedAt.Equal(batch.SessionStartedAt) {
|
||||||
|
t.Fatalf("session metadata was not persisted: %+v", stream)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user