Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore][pkg/stanza] Move tokenization tests into tokenizetest package #25997

Merged
merged 3 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/stanza/operator/helper/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type EncodingConfig struct {
// Deprecated: [v0.84.0] Use decoder.Decoder instead
type Decoder = decoder.Decoder

// Deprecated: [v0.84.0] Use decoder.New instead
var NewDecoder = decoder.New

// Deprecated: [v0.84.0] Use decoder.LookupEncoding instead
Expand Down
54 changes: 27 additions & 27 deletions pkg/stanza/operator/input/syslog/syslog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator"
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/input/tcp"
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/input/udp"
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/internal"
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/syslog"
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/pipeline"
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/testutil"
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/tokenize/tokenizetest"
)

var (
Expand Down Expand Up @@ -182,76 +182,76 @@ func NewConfigWithUDP(syslogCfg *syslog.BaseConfig) *Config {
}

func TestOctetFramingSplitFunc(t *testing.T) {
testCases := []internal.TokenizerTestCase{
testCases := []tokenizetest.TestCase{
{
Name: "OneLogSimple",
Raw: []byte(`17 my log LOGEND 123`),
ExpectedTokenized: []string{
Name: "OneLogSimple",
Input: []byte(`17 my log LOGEND 123`),
ExpectedTokens: []string{
`17 my log LOGEND 123`,
},
},
{
Name: "TwoLogsSimple",
Raw: []byte(`17 my log LOGEND 12317 my log LOGEND 123`),
ExpectedTokenized: []string{
Name: "TwoLogsSimple",
Input: []byte(`17 my log LOGEND 12317 my log LOGEND 123`),
ExpectedTokens: []string{
`17 my log LOGEND 123`,
`17 my log LOGEND 123`,
},
},
{
Name: "NoMatches",
Raw: []byte(`no matches in it`),
ExpectedTokenized: []string{
Name: "NoMatches",
Input: []byte(`no matches in it`),
ExpectedTokens: []string{
`no matches in it`,
},
},
{
Name: "NonMatchesAfter",
Raw: []byte(`17 my log LOGEND 123my log LOGEND 12317 my log LOGEND 123`),
ExpectedTokenized: []string{
Name: "NonMatchesAfter",
Input: []byte(`17 my log LOGEND 123my log LOGEND 12317 my log LOGEND 123`),
ExpectedTokens: []string{
`17 my log LOGEND 123`,
`my log LOGEND 12317 my log LOGEND 123`,
},
},
{
Name: "HugeLog100",
Raw: func() []byte {
newRaw := internal.GeneratedByteSliceOfLength(100)
Input: func() []byte {
newRaw := tokenizetest.GenerateBytes(100)
newRaw = append([]byte(`100 `), newRaw...)
return newRaw
}(),
ExpectedTokenized: []string{
`100 ` + string(internal.GeneratedByteSliceOfLength(100)),
ExpectedTokens: []string{
`100 ` + string(tokenizetest.GenerateBytes(100)),
},
},
{
Name: "maxCapacity",
Raw: func() []byte {
newRaw := internal.GeneratedByteSliceOfLength(4091)
Input: func() []byte {
newRaw := tokenizetest.GenerateBytes(4091)
newRaw = append([]byte(`4091 `), newRaw...)
return newRaw
}(),
ExpectedTokenized: []string{
`4091 ` + string(internal.GeneratedByteSliceOfLength(4091)),
ExpectedTokens: []string{
`4091 ` + string(tokenizetest.GenerateBytes(4091)),
},
},
{
Name: "over capacity",
Raw: func() []byte {
newRaw := internal.GeneratedByteSliceOfLength(4092)
Input: func() []byte {
newRaw := tokenizetest.GenerateBytes(4092)
newRaw = append([]byte(`5000 `), newRaw...)
return newRaw
}(),
ExpectedTokenized: []string{
`5000 ` + string(internal.GeneratedByteSliceOfLength(4091)),
ExpectedTokens: []string{
`5000 ` + string(tokenizetest.GenerateBytes(4091)),
`j`,
},
},
}
for _, tc := range testCases {
splitFunc, err := OctetMultiLineBuilder(nil)
require.NoError(t, err)
t.Run(tc.Name, tc.RunFunc(splitFunc))
t.Run(tc.Name, tc.Run(splitFunc))
}
}

Expand Down
119 changes: 0 additions & 119 deletions pkg/stanza/operator/internal/test_common.go

This file was deleted.

Loading