diff --git a/pkg/stanza/fileconsumer/benchmark_test.go b/pkg/stanza/fileconsumer/benchmark_test.go index 42315e78bbb9..a373129aa4c7 100644 --- a/pkg/stanza/fileconsumer/benchmark_test.go +++ b/pkg/stanza/fileconsumer/benchmark_test.go @@ -159,7 +159,7 @@ func BenchmarkFileInput(b *testing.B) { } b.ResetTimer() - err = op.Start(testutil.NewMockPersister("test")) + err = op.Start(testutil.NewUnscopedMockPersister()) defer func() { require.NoError(b, op.Stop()) }() diff --git a/pkg/stanza/fileconsumer/file_test.go b/pkg/stanza/fileconsumer/file_test.go index d0dfaca5dee1..069ab0fbb043 100644 --- a/pkg/stanza/fileconsumer/file_test.go +++ b/pkg/stanza/fileconsumer/file_test.go @@ -44,7 +44,7 @@ func TestDefaultBehaviors(t *testing.T) { tempName := filepath.Base(temp.Name()) writeString(t, temp, " testlog1 \n") - require.NoError(t, operator.Start(testutil.NewMockPersister("test"))) + require.NoError(t, operator.Start(testutil.NewUnscopedMockPersister())) defer func() { require.NoError(t, operator.Stop()) }() @@ -82,7 +82,7 @@ See this issue for details: https://github.com/census-instrumentation/opencensus operator, _ := buildTestManager(t, cfg) _ = openTemp(t, tempDir) - err := operator.Start(testutil.NewMockPersister("test")) + err := operator.Start(testutil.NewUnscopedMockPersister()) require.NoError(t, err) defer func() { require.NoError(t, operator.Stop()) @@ -107,7 +107,7 @@ func TestAddFileFields(t *testing.T) { temp := openTemp(t, tempDir) writeString(t, temp, "testlog\n") - require.NoError(t, operator.Start(testutil.NewMockPersister("test"))) + require.NoError(t, operator.Start(testutil.NewUnscopedMockPersister())) defer func() { require.NoError(t, operator.Stop()) }() @@ -159,7 +159,7 @@ func TestAddFileResolvedFields(t *testing.T) { resolved, err := filepath.Abs(realPath) require.NoError(t, err) - require.NoError(t, operator.Start(testutil.NewMockPersister("test"))) + require.NoError(t, operator.Start(testutil.NewUnscopedMockPersister())) defer func() { require.NoError(t, operator.Stop()) }() @@ -229,7 +229,7 @@ func TestAddFileResolvedFieldsWithChangeOfSymlinkTarget(t *testing.T) { // Populate data writeString(t, file1, "testlog\n") - require.NoError(t, operator.Start(testutil.NewMockPersister("test"))) + require.NoError(t, operator.Start(testutil.NewUnscopedMockPersister())) defer func() { require.NoError(t, operator.Stop()) }() @@ -318,7 +318,7 @@ func TestReadExistingLogs(t *testing.T) { temp := openTemp(t, tempDir) writeString(t, temp, "testlog1\ntestlog2\n") - require.NoError(t, operator.Start(testutil.NewMockPersister("test"))) + require.NoError(t, operator.Start(testutil.NewUnscopedMockPersister())) defer func() { require.NoError(t, operator.Stop()) }() @@ -387,7 +387,7 @@ func TestReadUsingNopEncoding(t *testing.T) { bytesWritten, err := temp.Write(tc.input) require.Greater(t, bytesWritten, 0) require.NoError(t, err) - require.NoError(t, operator.Start(testutil.NewMockPersister("test"))) + require.NoError(t, operator.Start(testutil.NewUnscopedMockPersister())) defer func() { require.NoError(t, operator.Stop()) }() @@ -471,7 +471,7 @@ func TestNopEncodingDifferentLogSizes(t *testing.T) { bytesWritten, err := temp.Write(tc.input) require.Greater(t, bytesWritten, 0) require.NoError(t, err) - require.NoError(t, operator.Start(testutil.NewMockPersister("test"))) + require.NoError(t, operator.Start(testutil.NewUnscopedMockPersister())) defer func() { require.NoError(t, operator.Stop()) }() @@ -490,7 +490,7 @@ func TestReadNewLogs(t *testing.T) { cfg := NewConfig().includeDir(tempDir) cfg.StartAt = "beginning" operator, emitCalls := buildTestManager(t, cfg) - operator.persister = testutil.NewMockPersister("test") + operator.persister = testutil.NewUnscopedMockPersister() // Poll once so we know this isn't a new file operator.poll(context.Background()) @@ -518,7 +518,7 @@ func TestReadExistingAndNewLogs(t *testing.T) { cfg := NewConfig().includeDir(tempDir) cfg.StartAt = "beginning" operator, emitCalls := buildTestManager(t, cfg) - operator.persister = testutil.NewMockPersister("test") + operator.persister = testutil.NewUnscopedMockPersister() // Start with a file with an entry in it, and expect that entry // to come through when we poll for the first time @@ -542,7 +542,7 @@ func TestStartAtEnd(t *testing.T) { tempDir := t.TempDir() cfg := NewConfig().includeDir(tempDir) operator, emitCalls := buildTestManager(t, cfg) - operator.persister = testutil.NewMockPersister("test") + operator.persister = testutil.NewUnscopedMockPersister() temp := openTemp(t, tempDir) writeString(t, temp, "testlog1\n") @@ -570,7 +570,7 @@ func TestStartAtEndNewFile(t *testing.T) { cfg := NewConfig().includeDir(tempDir) cfg.StartAt = "beginning" operator, emitCalls := buildTestManager(t, cfg) - operator.persister = testutil.NewMockPersister("test") + operator.persister = testutil.NewUnscopedMockPersister() operator.poll(context.Background()) temp := openTemp(t, tempDir) @@ -595,7 +595,7 @@ func TestNoNewline(t *testing.T) { temp := openTemp(t, tempDir) writeString(t, temp, "testlog1\ntestlog2") - require.NoError(t, operator.Start(testutil.NewMockPersister("test"))) + require.NoError(t, operator.Start(testutil.NewUnscopedMockPersister())) defer func() { require.NoError(t, operator.Stop()) }() @@ -616,7 +616,7 @@ func TestEmptyLine(t *testing.T) { temp := openTemp(t, tempDir) writeString(t, temp, "testlog1\n\ntestlog2\n") - require.NoError(t, operator.Start(testutil.NewMockPersister("test"))) + require.NoError(t, operator.Start(testutil.NewUnscopedMockPersister())) defer func() { require.NoError(t, operator.Stop()) }() @@ -639,7 +639,7 @@ func TestMultipleEmpty(t *testing.T) { temp := openTemp(t, tempDir) writeString(t, temp, "\n\ntestlog1\n\n\ntestlog2\n") - require.NoError(t, operator.Start(testutil.NewMockPersister("test"))) + require.NoError(t, operator.Start(testutil.NewUnscopedMockPersister())) defer func() { require.NoError(t, operator.Stop()) }() @@ -666,7 +666,7 @@ func TestLeadingEmpty(t *testing.T) { temp := openTemp(t, tempDir) writeString(t, temp, "\ntestlog1\ntestlog2\n") - require.NoError(t, operator.Start(testutil.NewMockPersister("test"))) + require.NoError(t, operator.Start(testutil.NewUnscopedMockPersister())) defer func() { require.NoError(t, operator.Stop()) }() @@ -686,7 +686,7 @@ func TestSplitWrite(t *testing.T) { cfg := NewConfig().includeDir(tempDir) cfg.StartAt = "beginning" operator, emitCalls := buildTestManager(t, cfg) - operator.persister = testutil.NewMockPersister("test") + operator.persister = testutil.NewUnscopedMockPersister() temp := openTemp(t, tempDir) writeString(t, temp, "testlog1") @@ -706,7 +706,7 @@ func TestIgnoreEmptyFiles(t *testing.T) { cfg := NewConfig().includeDir(tempDir) cfg.StartAt = "beginning" operator, emitCalls := buildTestManager(t, cfg) - operator.persister = testutil.NewMockPersister("test") + operator.persister = testutil.NewUnscopedMockPersister() temp := openTemp(t, tempDir) temp2 := openTemp(t, tempDir) @@ -734,7 +734,7 @@ func TestDecodeBufferIsResized(t *testing.T) { cfg.StartAt = "beginning" operator, emitCalls := buildTestManager(t, cfg) - require.NoError(t, operator.Start(testutil.NewMockPersister("test"))) + require.NoError(t, operator.Start(testutil.NewUnscopedMockPersister())) defer func() { require.NoError(t, operator.Stop()) }() @@ -760,7 +760,7 @@ func TestMultiFileSimple(t *testing.T) { writeString(t, temp1, "testlog1\n") writeString(t, temp2, "testlog2\n") - require.NoError(t, operator.Start(testutil.NewMockPersister("test"))) + require.NoError(t, operator.Start(testutil.NewUnscopedMockPersister())) defer func() { require.NoError(t, operator.Stop()) }() @@ -792,7 +792,7 @@ func TestMultiFileSort(t *testing.T) { writeString(t, temp1, "testlog1\n") writeString(t, temp2, "testlog2\n") - require.NoError(t, operator.Start(testutil.NewMockPersister("test"))) + require.NoError(t, operator.Start(testutil.NewUnscopedMockPersister())) defer func() { require.NoError(t, operator.Stop()) }() @@ -826,7 +826,7 @@ func TestMultiFileSortTimestamp(t *testing.T) { writeString(t, temp1, "testlog1\n") writeString(t, temp2, "testlog2\n") - require.NoError(t, operator.Start(testutil.NewMockPersister("test"))) + require.NoError(t, operator.Start(testutil.NewUnscopedMockPersister())) defer func() { require.NoError(t, operator.Stop()) }() @@ -867,7 +867,7 @@ func TestMultiFileParallel_PreloadedFiles(t *testing.T) { }(temp, i) } - require.NoError(t, operator.Start(testutil.NewMockPersister("test"))) + require.NoError(t, operator.Start(testutil.NewUnscopedMockPersister())) defer func() { require.NoError(t, operator.Stop()) }() @@ -896,7 +896,7 @@ func TestMultiFileParallel_LiveFiles(t *testing.T) { } } - require.NoError(t, operator.Start(testutil.NewMockPersister("test"))) + require.NoError(t, operator.Start(testutil.NewUnscopedMockPersister())) defer func() { require.NoError(t, operator.Stop()) }() @@ -941,7 +941,7 @@ func TestRestartOffsets(t *testing.T) { cfg := NewConfig().includeDir(tempDir) cfg.StartAt = tc.startAt - persister := testutil.NewMockPersister("test") + persister := testutil.NewUnscopedMockPersister() logFile := openTemp(t, tempDir) @@ -989,7 +989,7 @@ func TestManyLogsDelivered(t *testing.T) { } // Start the operator - require.NoError(t, operator.Start(testutil.NewMockPersister("test"))) + require.NoError(t, operator.Start(testutil.NewUnscopedMockPersister())) defer func() { require.NoError(t, operator.Stop()) }() @@ -1027,7 +1027,7 @@ func TestFileBatching(t *testing.T) { cfg.MaxBatches = maxBatches emitCalls := make(chan *emitParams, files*linesPerFile) operator, _ := buildTestManager(t, cfg, withEmitChan(emitCalls)) - operator.persister = testutil.NewMockPersister("test") + operator.persister = testutil.NewUnscopedMockPersister() core, observedLogs := observer.New(zap.DebugLevel) operator.SugaredLogger = zap.New(core).Sugar() @@ -1111,7 +1111,7 @@ func TestFileBatchingRespectsStartAtEnd(t *testing.T) { cfg.MaxConcurrentFiles = maxConcurrentFiles operator, emitChan := buildTestManager(t, cfg) - operator.persister = testutil.NewMockPersister("test") + operator.persister = testutil.NewUnscopedMockPersister() temps := make([]*os.File, 0, initFiles+moreFiles) for i := 0; i < initFiles; i++ { @@ -1388,7 +1388,7 @@ func TestEncodings(t *testing.T) { _, err := temp.Write(tc.contents) require.NoError(t, err) - require.NoError(t, operator.Start(testutil.NewMockPersister("test"))) + require.NoError(t, operator.Start(testutil.NewUnscopedMockPersister())) defer func() { require.NoError(t, operator.Stop()) }() @@ -1433,7 +1433,7 @@ func TestDeleteAfterRead(t *testing.T) { cfg.DeleteAfterRead = true emitCalls := make(chan *emitParams, totalLines) operator, _ := buildTestManager(t, cfg, withEmitChan(emitCalls)) - operator.persister = testutil.NewMockPersister("test") + operator.persister = testutil.NewUnscopedMockPersister() operator.poll(context.Background()) actualTokens = append(actualTokens, waitForNTokens(t, emitCalls, totalLines)...) @@ -1464,7 +1464,7 @@ func TestMaxBatching(t *testing.T) { cfg.MaxBatches = maxBatches emitCalls := make(chan *emitParams, files*linesPerFile) operator, _ := buildTestManager(t, cfg, withEmitChan(emitCalls)) - operator.persister = testutil.NewMockPersister("test") + operator.persister = testutil.NewUnscopedMockPersister() core, observedLogs := observer.New(zap.DebugLevel) operator.SugaredLogger = zap.New(core).Sugar() @@ -1551,7 +1551,7 @@ func TestReadExistingLogsWithHeader(t *testing.T) { temp := openTemp(t, tempDir) writeString(t, temp, "#headerField: headerValue\ntestlog\n") - require.NoError(t, operator.Start(testutil.NewMockPersister("test"))) + require.NoError(t, operator.Start(testutil.NewUnscopedMockPersister())) defer func() { require.NoError(t, operator.Stop()) }() @@ -1580,7 +1580,7 @@ func TestDeleteAfterRead_SkipPartials(t *testing.T) { cfg.DeleteAfterRead = true emitCalls := make(chan *emitParams, longFileLines+1) operator, _ := buildTestManager(t, cfg, withEmitChan(emitCalls)) - operator.persister = testutil.NewMockPersister("test") + operator.persister = testutil.NewUnscopedMockPersister() shortFile := openTemp(t, tempDir) _, err := shortFile.WriteString(string(shortFileLine) + "\n") @@ -1725,7 +1725,7 @@ func TestStalePartialFingerprintDiscarded(t *testing.T) { cfg.FingerprintSize = 18 cfg.StartAt = "beginning" operator, emitCalls := buildTestManager(t, cfg) - operator.persister = testutil.NewMockPersister("test") + operator.persister = testutil.NewUnscopedMockPersister() // Both of they will be include file1 := openTempWithPattern(t, tempDir, "*.log1") diff --git a/pkg/stanza/fileconsumer/rotation_test.go b/pkg/stanza/fileconsumer/rotation_test.go index ff8408003124..f627312a0ad3 100644 --- a/pkg/stanza/fileconsumer/rotation_test.go +++ b/pkg/stanza/fileconsumer/rotation_test.go @@ -48,7 +48,7 @@ func TestMultiFileRotate(t *testing.T) { } } - require.NoError(t, operator.Start(testutil.NewMockPersister("test"))) + require.NoError(t, operator.Start(testutil.NewUnscopedMockPersister())) defer func() { require.NoError(t, operator.Stop()) }() @@ -109,7 +109,7 @@ func TestMultiFileRotateSlow(t *testing.T) { } } - require.NoError(t, operator.Start(testutil.NewMockPersister("test"))) + require.NoError(t, operator.Start(testutil.NewUnscopedMockPersister())) defer func() { require.NoError(t, operator.Stop()) }() @@ -163,7 +163,7 @@ func TestMultiCopyTruncateSlow(t *testing.T) { } } - require.NoError(t, operator.Start(testutil.NewMockPersister("test"))) + require.NoError(t, operator.Start(testutil.NewUnscopedMockPersister())) defer func() { require.NoError(t, operator.Stop()) }() @@ -263,7 +263,7 @@ func (rt rotationTest) run(tc rotationTest, copyTruncate, sequential bool) func( expected = append(expected, []byte(fmt.Sprintf("%s %3d", baseStr, i))) } - require.NoError(t, operator.Start(testutil.NewMockPersister("test"))) + require.NoError(t, operator.Start(testutil.NewUnscopedMockPersister())) defer func() { require.NoError(t, operator.Stop()) }() @@ -358,7 +358,7 @@ func TestMoveFile(t *testing.T) { cfg := NewConfig().includeDir(tempDir) cfg.StartAt = "beginning" operator, emitCalls := buildTestManager(t, cfg) - operator.persister = testutil.NewMockPersister("test") + operator.persister = testutil.NewUnscopedMockPersister() temp1 := openTemp(t, tempDir) writeString(t, temp1, "testlog1\n") @@ -390,7 +390,7 @@ func TestTrackMovedAwayFiles(t *testing.T) { cfg := NewConfig().includeDir(tempDir) cfg.StartAt = "beginning" operator, emitCalls := buildTestManager(t, cfg) - operator.persister = testutil.NewMockPersister("test") + operator.persister = testutil.NewUnscopedMockPersister() temp1 := openTemp(t, tempDir) writeString(t, temp1, "testlog1\n") @@ -439,7 +439,7 @@ func TestTrackRotatedFilesLogOrder(t *testing.T) { orginalName := originalFile.Name() writeString(t, originalFile, "testlog1\n") - require.NoError(t, operator.Start(testutil.NewMockPersister("test"))) + require.NoError(t, operator.Start(testutil.NewUnscopedMockPersister())) defer func() { require.NoError(t, operator.Stop()) }() @@ -474,7 +474,7 @@ func TestRotatedOutOfPatternMoveCreate(t *testing.T) { cfg.Include = append(cfg.Include, fmt.Sprintf("%s/*.log1", tempDir)) cfg.StartAt = "beginning" operator, emitCalls := buildTestManager(t, cfg) - operator.persister = testutil.NewMockPersister("test") + operator.persister = testutil.NewUnscopedMockPersister() originalFile := openTempWithPattern(t, tempDir, "*.log1") originalFileName := originalFile.Name() @@ -511,7 +511,7 @@ func TestRotatedOutOfPatternCopyTruncate(t *testing.T) { cfg.Include = append(cfg.Include, fmt.Sprintf("%s/*.log1", tempDir)) cfg.StartAt = "beginning" operator, emitCalls := buildTestManager(t, cfg) - operator.persister = testutil.NewMockPersister("test") + operator.persister = testutil.NewUnscopedMockPersister() originalFile := openTempWithPattern(t, tempDir, "*.log1") writeString(t, originalFile, "testlog1\n") @@ -551,7 +551,7 @@ func TestTruncateThenWrite(t *testing.T) { cfg := NewConfig().includeDir(tempDir) cfg.StartAt = "beginning" operator, emitCalls := buildTestManager(t, cfg) - operator.persister = testutil.NewMockPersister("test") + operator.persister = testutil.NewUnscopedMockPersister() temp1 := openTemp(t, tempDir) writeString(t, temp1, "testlog1\ntestlog2\n") @@ -588,7 +588,7 @@ func TestCopyTruncateWriteBoth(t *testing.T) { cfg := NewConfig().includeDir(tempDir) cfg.StartAt = "beginning" operator, emitCalls := buildTestManager(t, cfg) - operator.persister = testutil.NewMockPersister("test") + operator.persister = testutil.NewUnscopedMockPersister() temp1 := openTemp(t, tempDir) writeString(t, temp1, "testlog1\ntestlog2\n") @@ -631,7 +631,7 @@ func TestFileMovedWhileOff_BigFiles(t *testing.T) { cfg := NewConfig().includeDir(tempDir) cfg.StartAt = "beginning" operator, emitCalls := buildTestManager(t, cfg) - persister := testutil.NewMockPersister("test") + persister := testutil.NewUnscopedMockPersister() log1 := tokenWithLength(1000) log2 := tokenWithLength(1000) diff --git a/pkg/stanza/operator/helper/operator_test.go b/pkg/stanza/operator/helper/operator_test.go index 95c4d5677236..68472e784696 100644 --- a/pkg/stanza/operator/helper/operator_test.go +++ b/pkg/stanza/operator/helper/operator_test.go @@ -101,7 +101,7 @@ func TestBasicOperatorStart(t *testing.T) { OperatorID: "test-id", OperatorType: "test-type", } - err := operator.Start(testutil.NewMockPersister("test")) + err := operator.Start(testutil.NewUnscopedMockPersister()) require.NoError(t, err) } diff --git a/pkg/stanza/operator/input/file/file_test.go b/pkg/stanza/operator/input/file/file_test.go index 5e8ce7a97932..b3adb53b7177 100644 --- a/pkg/stanza/operator/input/file/file_test.go +++ b/pkg/stanza/operator/input/file/file_test.go @@ -53,7 +53,7 @@ func TestAddFileResolvedFields(t *testing.T) { resolved, err := filepath.Abs(realPath) require.NoError(t, err) - require.NoError(t, operator.Start(testutil.NewMockPersister("test"))) + require.NoError(t, operator.Start(testutil.NewUnscopedMockPersister())) defer func() { require.NoError(t, operator.Stop()) }() @@ -75,7 +75,7 @@ func TestReadExistingLogs(t *testing.T) { temp := openTemp(t, tempDir) writeString(t, temp, "testlog1\ntestlog2\n") - require.NoError(t, operator.Start(testutil.NewMockPersister("test"))) + require.NoError(t, operator.Start(testutil.NewUnscopedMockPersister())) defer func() { require.NoError(t, operator.Stop()) }() @@ -140,7 +140,7 @@ func TestReadUsingNopEncoding(t *testing.T) { bytesWritten, err := temp.Write(tc.input) require.Greater(t, bytesWritten, 0) require.NoError(t, err) - require.NoError(t, operator.Start(testutil.NewMockPersister("test"))) + require.NoError(t, operator.Start(testutil.NewUnscopedMockPersister())) defer func() { require.NoError(t, operator.Stop()) }() @@ -156,7 +156,7 @@ func TestReadNewLogs(t *testing.T) { t.Parallel() operator, logReceived, tempDir := newTestFileOperator(t, nil) - require.NoError(t, operator.Start(testutil.NewMockPersister("test"))) + require.NoError(t, operator.Start(testutil.NewUnscopedMockPersister())) defer func() { require.NoError(t, operator.Stop()) }() @@ -181,7 +181,7 @@ func TestReadExistingAndNewLogs(t *testing.T) { temp := openTemp(t, tempDir) writeString(t, temp, "testlog1\n") - require.NoError(t, operator.Start(testutil.NewMockPersister("test"))) + require.NoError(t, operator.Start(testutil.NewUnscopedMockPersister())) defer func() { require.NoError(t, operator.Stop()) }() @@ -208,7 +208,7 @@ func TestStartAtEnd(t *testing.T) { temp := openTemp(t, tempDir) writeString(t, temp, "testlog1\n") - require.NoError(t, operator.Start(testutil.NewMockPersister("test"))) + require.NoError(t, operator.Start(testutil.NewUnscopedMockPersister())) defer func() { require.NoError(t, operator.Stop()) }() @@ -230,7 +230,7 @@ func TestSkipEmpty(t *testing.T) { temp := openTemp(t, tempDir) writeString(t, temp, "testlog1\n\ntestlog2\n") - require.NoError(t, operator.Start(testutil.NewMockPersister("test"))) + require.NoError(t, operator.Start(testutil.NewUnscopedMockPersister())) defer func() { require.NoError(t, operator.Stop()) }() diff --git a/pkg/stanza/operator/input/generate/generate_test.go b/pkg/stanza/operator/input/generate/generate_test.go index 198b9dae39b9..140bd3097bcc 100644 --- a/pkg/stanza/operator/input/generate/generate_test.go +++ b/pkg/stanza/operator/input/generate/generate_test.go @@ -28,7 +28,7 @@ func TestInputGenerate(t *testing.T) { err = op.SetOutputs([]operator.Operator{fake}) require.NoError(t, err) - require.NoError(t, op.Start(testutil.NewMockPersister("test"))) + require.NoError(t, op.Start(testutil.NewUnscopedMockPersister())) defer func() { require.NoError(t, op.Stop()) }() diff --git a/pkg/stanza/operator/input/journald/journald_test.go b/pkg/stanza/operator/input/journald/journald_test.go index 178f0571041a..1382fb87da28 100644 --- a/pkg/stanza/operator/input/journald/journald_test.go +++ b/pkg/stanza/operator/input/journald/journald_test.go @@ -72,7 +72,7 @@ func TestInputJournald(t *testing.T) { return &fakeJournaldCmd{} } - err = op.Start(testutil.NewMockPersister("test")) + err = op.Start(testutil.NewUnscopedMockPersister()) assert.EqualError(t, err, "journalctl command exited") defer func() { require.NoError(t, op.Stop()) @@ -246,7 +246,7 @@ func TestInputJournaldError(t *testing.T) { } } - err = op.Start(testutil.NewMockPersister("test")) + err = op.Start(testutil.NewUnscopedMockPersister()) assert.EqualError(t, err, "journalctl command failed (): stderr output\n") defer func() { require.NoError(t, op.Stop()) diff --git a/pkg/stanza/operator/input/stdin/stdin_test.go b/pkg/stanza/operator/input/stdin/stdin_test.go index 5166b0900882..ef6dfb50c201 100644 --- a/pkg/stanza/operator/input/stdin/stdin_test.go +++ b/pkg/stanza/operator/input/stdin/stdin_test.go @@ -29,7 +29,7 @@ func TestStdin(t *testing.T) { stdin := op.(*Input) stdin.stdin = r - require.NoError(t, stdin.Start(testutil.NewMockPersister("test"))) + require.NoError(t, stdin.Start(testutil.NewUnscopedMockPersister())) defer func() { require.NoError(t, stdin.Stop()) }() diff --git a/pkg/stanza/operator/input/syslog/syslog_test.go b/pkg/stanza/operator/input/syslog/syslog_test.go index b2f604a8b0df..7a32417e733a 100644 --- a/pkg/stanza/operator/input/syslog/syslog_test.go +++ b/pkg/stanza/operator/input/syslog/syslog_test.go @@ -95,7 +95,7 @@ func InputTest(t *testing.T, cfg *Config, tc syslog.Case) { p, err := pipeline.NewDirectedPipeline(ops) require.NoError(t, err) - err = p.Start(testutil.NewMockPersister("test")) + err = p.Start(testutil.NewUnscopedMockPersister()) require.NoError(t, err) var conn net.Conn diff --git a/pkg/stanza/operator/input/tcp/tcp_test.go b/pkg/stanza/operator/input/tcp/tcp_test.go index d3464641ff27..dbfdc97e4d27 100644 --- a/pkg/stanza/operator/input/tcp/tcp_test.go +++ b/pkg/stanza/operator/input/tcp/tcp_test.go @@ -90,7 +90,7 @@ func tcpInputTest(input []byte, expected []string) func(t *testing.T) { entryChan <- args.Get(1).(*entry.Entry) }).Return(nil) - err = tcpInput.Start(testutil.NewMockPersister("test")) + err = tcpInput.Start(testutil.NewUnscopedMockPersister()) require.NoError(t, err) defer func() { require.NoError(t, tcpInput.Stop(), "expected to stop tcp input operator without error") @@ -139,7 +139,7 @@ func tcpInputAttributesTest(input []byte, expected []string) func(t *testing.T) entryChan <- args.Get(1).(*entry.Entry) }).Return(nil) - err = tcpInput.Start(testutil.NewMockPersister("test")) + err = tcpInput.Start(testutil.NewUnscopedMockPersister()) require.NoError(t, err) defer func() { require.NoError(t, tcpInput.Stop(), "expected to stop tcp input operator without error") @@ -225,7 +225,7 @@ func tlsInputTest(input []byte, expected []string) func(t *testing.T) { entryChan <- args.Get(1).(*entry.Entry) }).Return(nil) - err = tcpInput.Start(testutil.NewMockPersister("test")) + err = tcpInput.Start(testutil.NewUnscopedMockPersister()) require.NoError(t, err) defer func() { require.NoError(t, tcpInput.Stop(), "expected to stop tcp input operator without error") @@ -397,7 +397,7 @@ func TestFailToBind(t *testing.T) { mockOutput.On("Process", mock.Anything, mock.Anything).Run(func(args mock.Arguments) { entryChan <- args.Get(1).(*entry.Entry) }).Return(nil) - err = tcpInput.Start(testutil.NewMockPersister("test")) + err = tcpInput.Start(testutil.NewUnscopedMockPersister()) return tcpInput, err } @@ -422,7 +422,7 @@ func BenchmarkTCPInput(b *testing.B) { tcpInput := op.(*Input) tcpInput.InputOperator.OutputOperators = []operator.Operator{fakeOutput} - err = tcpInput.Start(testutil.NewMockPersister("test")) + err = tcpInput.Start(testutil.NewUnscopedMockPersister()) require.NoError(b, err) done := make(chan struct{}) diff --git a/pkg/stanza/operator/input/udp/udp_test.go b/pkg/stanza/operator/input/udp/udp_test.go index 7a5b69b2b976..aba8eeb28e59 100644 --- a/pkg/stanza/operator/input/udp/udp_test.go +++ b/pkg/stanza/operator/input/udp/udp_test.go @@ -34,7 +34,7 @@ func udpInputTest(input []byte, expected []string, cfg *Config) func(t *testing. entryChan <- args.Get(1).(*entry.Entry) }).Return(nil) - err = udpInput.Start(testutil.NewMockPersister("test")) + err = udpInput.Start(testutil.NewUnscopedMockPersister()) require.NoError(t, err) defer func() { require.NoError(t, udpInput.Stop(), "expected to stop udp input operator without error") @@ -85,7 +85,7 @@ func udpInputAttributesTest(input []byte, expected []string) func(t *testing.T) entryChan <- args.Get(1).(*entry.Entry) }).Return(nil) - err = udpInput.Start(testutil.NewMockPersister("test")) + err = udpInput.Start(testutil.NewUnscopedMockPersister()) require.NoError(t, err) defer func() { require.NoError(t, udpInput.Stop(), "expected to stop udp input operator without error") @@ -190,7 +190,7 @@ func TestFailToBind(t *testing.T) { entryChan <- args.Get(1).(*entry.Entry) }).Return(nil) - err = udpInput.Start(testutil.NewMockPersister("test")) + err = udpInput.Start(testutil.NewUnscopedMockPersister()) return udpInput, err } @@ -215,7 +215,7 @@ func BenchmarkUDPInput(b *testing.B) { udpInput := op.(*Input) udpInput.InputOperator.OutputOperators = []operator.Operator{fakeOutput} - err = udpInput.Start(testutil.NewMockPersister("test")) + err = udpInput.Start(testutil.NewUnscopedMockPersister()) require.NoError(b, err) done := make(chan struct{}) diff --git a/pkg/stanza/operator/transformer/recombine/recombine_test.go b/pkg/stanza/operator/transformer/recombine/recombine_test.go index 0445d92c414d..3bb5fff876aa 100644 --- a/pkg/stanza/operator/transformer/recombine/recombine_test.go +++ b/pkg/stanza/operator/transformer/recombine/recombine_test.go @@ -477,7 +477,7 @@ func TestTransformer(t *testing.T) { t.Run(tc.name, func(t *testing.T) { op, err := tc.config.Build(testutil.Logger(t)) require.NoError(t, err) - require.NoError(t, op.Start(testutil.NewMockPersister("test"))) + require.NoError(t, op.Start(testutil.NewUnscopedMockPersister())) recombine := op.(*Transformer) fake := testutil.NewFakeOutput(t)