Add runtime SQLite query targets
This commit is contained in:
@@ -452,7 +452,7 @@ func TestResolveRuntimeProfilesSupportsDeclaredModesAndSafeMissingKeys(t *testin
|
||||
}
|
||||
}
|
||||
|
||||
func TestTailDeclaredFileLogSourceUsesCheckpointAndRedaction(t *testing.T) {
|
||||
func TestTailDeclaredFileLogSourceUsesCheckpointAndVerbatimOutput(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
assignment := lifecycleAssignment(protocol.RunCapabilityLogsRead)
|
||||
serverRoot := filepath.Join(root, assignment.ServerInstanceID, "logs")
|
||||
@@ -472,8 +472,8 @@ func TestTailDeclaredFileLogSourceUsesCheckpointAndRedaction(t *testing.T) {
|
||||
if result.State != "succeeded" || !strings.Contains(result.ResultRef, "live-log-checkpoint") {
|
||||
t.Fatalf("expected file tail success, got %+v", result)
|
||||
}
|
||||
if len(sink.lines) != 2 || strings.Contains(strings.Join(sink.lines, "\n"), "password=hidden") {
|
||||
t.Fatalf("expected redacted tailed lines, got %+v", sink.lines)
|
||||
if len(sink.lines) != 2 || strings.Join(sink.lines, "\n") != "latest-log:first line\nlatest-log:password=hidden" {
|
||||
t.Fatalf("expected verbatim tailed lines, got %+v", sink.lines)
|
||||
}
|
||||
checkpoint := store.GetLogCheckpoint("latest-log")
|
||||
if checkpoint.Offset == 0 || checkpoint.Sequence != 2 || strings.Contains(RedactedLogCheckpointSummary(checkpoint), "/Users/") {
|
||||
@@ -490,6 +490,36 @@ func TestTailDeclaredFileLogSourceUsesCheckpointAndRedaction(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestTailDeclaredFileLogSourceDoesNotLimitOrRewriteOutput(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
assignment := lifecycleAssignment(protocol.RunCapabilityLogsRead)
|
||||
serverRoot := filepath.Join(root, assignment.ServerInstanceID, "logs")
|
||||
if err := os.MkdirAll(serverRoot, 0o755); err != nil {
|
||||
t.Fatalf("create logs dir: %v", err)
|
||||
}
|
||||
longLine := "password=visible\r" + strings.Repeat("x", maxLifecycleOutputBytes+1)
|
||||
logPath := filepath.Join(serverRoot, "current.log")
|
||||
if err := os.WriteFile(logPath, []byte(longLine+"\n\nfinal"), 0o644); err != nil {
|
||||
t.Fatalf("write log file: %v", err)
|
||||
}
|
||||
store := NewMemoryLogCheckpointStore()
|
||||
sink := &recordingLogSink{}
|
||||
source := RuntimeLogSource{Key: "current-log", Kind: "file.tail", TargetKey: "logs/current.log", StreamKey: "current-log", CursorKind: "offset"}
|
||||
|
||||
result := TailDeclaredFileLogSource(context.Background(), root, assignment, source, sink, store)
|
||||
|
||||
if result.State != lifecycleResultStateSucceeded || len(sink.lines) != 3 {
|
||||
t.Fatalf("expected all unbounded log entries, result=%+v lines=%d", result, len(sink.lines))
|
||||
}
|
||||
if sink.lines[0] != "current-log:"+longLine || sink.lines[1] != "current-log:" || sink.lines[2] != "current-log:final" {
|
||||
t.Fatalf("expected byte-for-byte log payloads, got lengths=%d,%d,%d", len(sink.lines[0]), len(sink.lines[1]), len(sink.lines[2]))
|
||||
}
|
||||
checkpoint := store.GetLogCheckpoint(source.Key)
|
||||
if checkpoint.Offset != int64(len(longLine+"\n\nfinal")) || checkpoint.Sequence != 3 {
|
||||
t.Fatalf("expected complete checkpoint after unbounded tail, got %+v", checkpoint)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLifecycleExecutorExecutesDeclaredLogBackfillTail(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
assignment := lifecycleAssignment(protocol.RunCapabilityLogsBackfill)
|
||||
@@ -523,6 +553,22 @@ func (supervisor *recordingSupervisor) Run(_ context.Context, command ProcessCom
|
||||
return ProcessResult{ExitCode: 0, Stdout: "recorded\n"}, nil
|
||||
}
|
||||
|
||||
func TestOSProcessSupervisorRelaysRawCarriageReturn(t *testing.T) {
|
||||
var output []string
|
||||
result, err := (OSProcessSupervisor{}).Run(context.Background(), ProcessCommand{
|
||||
Args: []string{"sh", "-c", "printf 'raw\\r\\n'"},
|
||||
OutputLine: func(stream string, line string) {
|
||||
output = append(output, stream+":"+line)
|
||||
},
|
||||
})
|
||||
if err != nil || result.ExitCode != 0 {
|
||||
t.Fatalf("run process: result=%+v err=%v", result, err)
|
||||
}
|
||||
if len(output) != 1 || output[0] != "stdout:raw\r" {
|
||||
t.Fatalf("expected raw CR to be relayed, got %+v", output)
|
||||
}
|
||||
}
|
||||
|
||||
type recordingLogSink struct {
|
||||
mu sync.Mutex
|
||||
lines []string
|
||||
|
||||
Reference in New Issue
Block a user