forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[chore][pkg/stanza] Move some reader tests into reader package (open-…
…telemetry#29664) This localizes a few tests by moving them from `fileconsumer` to `reader` package.
- Loading branch information
1 parent
4c16e26
commit d6dda62
Showing
2 changed files
with
55 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package reader | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/decode" | ||
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/fileconsumer/internal/emittest" | ||
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/fileconsumer/internal/fingerprint" | ||
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/split" | ||
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/testutil" | ||
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/trim" | ||
) | ||
|
||
const ( | ||
defaultMaxLogSize = 1024 * 1024 | ||
defaultMaxConcurrentFiles = 1024 | ||
defaultEncoding = "utf-8" | ||
defaultPollInterval = 200 * time.Millisecond | ||
defaultFlushPeriod = 500 * time.Millisecond | ||
) | ||
|
||
func testFactory(t *testing.T, sCfg split.Config, maxLogSize int, flushPeriod time.Duration) (*Factory, *emittest.Sink) { | ||
enc, err := decode.LookupEncoding(defaultEncoding) | ||
require.NoError(t, err) | ||
|
||
splitFunc, err := sCfg.Func(enc, false, maxLogSize) | ||
require.NoError(t, err) | ||
|
||
sink := emittest.NewSink() | ||
return &Factory{ | ||
SugaredLogger: testutil.Logger(t), | ||
Config: &Config{ | ||
FingerprintSize: fingerprint.DefaultSize, | ||
MaxLogSize: maxLogSize, | ||
Emit: sink.Callback, | ||
FlushTimeout: flushPeriod, | ||
}, | ||
FromBeginning: true, | ||
Encoding: enc, | ||
SplitFunc: splitFunc, | ||
TrimFunc: trim.Whitespace, | ||
}, sink | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters