From e7099ee0cd62c4bfdbc4c40be15384ad77b346a0 Mon Sep 17 00:00:00 2001 From: Daniel Jaglowski Date: Mon, 1 Feb 2021 16:41:18 -0500 Subject: [PATCH] Add basic CI for unit testing (#7) * Add basic CI for unit testing --- .github/workflows/build-and-test.yml | 94 ++++++++++++++++++++++++ .golangci.yml | 3 + agent/builder.go | 6 +- database/database_test.go | 1 - operator/buffer/disk.go | 4 +- operator/buffer/disk_test.go | 12 +-- operator/buffer/memory_test.go | 10 +-- operator/buffer/util_test.go | 9 +-- operator/build_context_test.go | 1 - operator/builtin/input/file/file_test.go | 50 +++---------- operator/flusher/flusher_test.go | 2 - operator/helper/parser_test.go | 1 - operator/helper/persister_test.go | 1 + operator/helper/severity_test.go | 11 +-- operator/helper/time.go | 2 +- operator/helper/time_test.go | 28 +++---- pipeline/directed_test.go | 6 +- plugin/config.go | 4 +- plugin/parameter.go | 1 - plugin/plugin_test.go | 5 -- 20 files changed, 150 insertions(+), 101 deletions(-) create mode 100644 .github/workflows/build-and-test.yml diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 000000000000..ed2c64885de1 --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,94 @@ +name: Go + +on: + push: + branches: [ main ] + tags: + - 'v[0-9]+.[0-9]+.[0-9]+*' + pull_request: + +jobs: + + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v2 + - name: Setup Go + uses: actions/setup-go@v2 + with: + go-version: 1.15 + - name: Cache Go Modules + uses: actions/cache@v2 + env: + cache-name: cache-go-modules + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-${{ hashFiles('**/go.mod') }} + - name: Install tools + if: steps.tool-cache.outputs.cache-hit != 'true' + run: make install-tools + - name: Add Permissions to Tool Binaries + run: chmod -R +x ~/go/bin + - name: Vet + run: make vet + - name: Lint + run: make lint + + test-linux: + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v2 + - name: Setup Go + uses: actions/setup-go@v2 + with: + go-version: 1.15 + - name: Cache Go Modules + uses: actions/cache@v2 + env: + cache-name: cache-go-modules + with: + path: ~/go/bin + key: ${{ runner.os }}-${{ hashFiles('**/go.mod') }} + - name: Run Unit Tests + run: make test + + test-macos: + runs-on: macos-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v2 + - name: Setup Go + uses: actions/setup-go@v2 + with: + go-version: 1.15 + - name: Cache Go Modules + uses: actions/cache@v2 + env: + cache-name: cache-go-modules + with: + path: ~/go/bin + key: ${{ runner.os }}-${{ hashFiles('**/go.mod') }} + - name: Run Unit Tests + run: make test + + test-windows: + runs-on: windows-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v2 + - name: Set up Go + uses: actions/setup-go@v2.1.3 + with: + go-version: 1.15 + - name: Cache Go Modules + uses: actions/cache@v2 + env: + cache-name: cache-go-modules + with: + path: /Users/runneradmin/go/pkg/mod + key: ${{ runner.os }}-${{ hashFiles('**/go.mod') }} + - name: Run Unit Tests + run: make test + diff --git a/.golangci.yml b/.golangci.yml index 3cb7ab5712f7..49d84028b140 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -13,3 +13,6 @@ linters: - unparam - whitespace - ineffassign +linters-settings: + goconst: + min-occurrences: 5 \ No newline at end of file diff --git a/agent/builder.go b/agent/builder.go index 7dd3861b391c..fc70c384ccd4 100644 --- a/agent/builder.go +++ b/agent/builder.go @@ -87,9 +87,11 @@ func (b *LogAgentBuilder) Build() (*LogAgent, error) { if b.config != nil && len(b.configFiles) > 0 { return nil, errors.NewError("agent can be built WithConfig or WithConfigFiles, but not both", "") - } else if b.config == nil && len(b.configFiles) == 0 { + } + if b.config == nil && len(b.configFiles) == 0 { return nil, errors.NewError("agent cannot be built without WithConfig or WithConfigFiles", "") - } else if len(b.configFiles) > 0 { + } + if len(b.configFiles) > 0 { b.config, err = NewConfigFromGlobs(b.configFiles) if err != nil { return nil, errors.Wrap(err, "read configs from globs") diff --git a/database/database_test.go b/database/database_test.go index 718984beee6c..fa089c8f556e 100644 --- a/database/database_test.go +++ b/database/database_test.go @@ -84,7 +84,6 @@ func TestOpenDatabase(t *testing.T) { require.Error(t, err) require.Nil(t, db) }) - } func TestStubDatabase(t *testing.T) { diff --git a/operator/buffer/disk.go b/operator/buffer/disk.go index dc0d283ad8a0..964609585064 100644 --- a/operator/buffer/disk.go +++ b/operator/buffer/disk.go @@ -122,10 +122,10 @@ type DiskBuffer struct { // NewDiskBuffer creates a new DiskBuffer func NewDiskBuffer(maxDiskSize int64) *DiskBuffer { return &DiskBuffer{ - maxBytes: int64(maxDiskSize), + maxBytes: maxDiskSize, entryAdded: make(chan int64, 1), copyBuffer: make([]byte, 1<<16), - diskSizeSemaphore: semaphore.NewWeighted(int64(maxDiskSize)), + diskSizeSemaphore: semaphore.NewWeighted(maxDiskSize), } } diff --git a/operator/buffer/disk_test.go b/operator/buffer/disk_test.go index 34e76adf55e1..ea08b687aa67 100644 --- a/operator/buffer/disk_test.go +++ b/operator/buffer/disk_test.go @@ -74,7 +74,7 @@ func TestDiskBuffer(t *testing.T) { readyDone := make(chan struct{}) go func() { readyDone <- struct{}{} - readWaitN(t, b, 20, 0) + readWaitN(t, b, 20) readyDone <- struct{}{} }() <-readyDone @@ -90,7 +90,7 @@ func TestDiskBuffer(t *testing.T) { readyDone := make(chan struct{}) go func() { readyDone <- struct{}{} - readWaitN(t, b, 15, 0) + readWaitN(t, b, 15) readyDone <- struct{}{} }() <-readyDone @@ -209,7 +209,7 @@ func TestDiskBuffer(t *testing.T) { c, n, err := b.Read(dst) require.NoError(t, err) require.Equal(t, 1, n) - c.MarkAllAsFlushed() + require.NoError(t, c.MarkAllAsFlushed()) require.NoError(t, b.Compact()) // Now there should be space for another entry @@ -243,7 +243,7 @@ func TestDiskBuffer(t *testing.T) { readCount := (writes - reads) / 2 c := readN(t, b, readCount, reads) if j%2 == 0 { - c.MarkAllAsFlushed() + require.NoError(t, c.MarkAllAsFlushed()) } reads += readCount default: @@ -298,7 +298,7 @@ func BenchmarkDiskBuffer(b *testing.B) { cancel() panicOnErr(err) i += n - c.MarkAllAsFlushed() + require.NoError(b, c.MarkAllAsFlushed()) } }() @@ -336,7 +336,7 @@ func BenchmarkDiskBuffer(b *testing.B) { cancel() panicOnErr(err) i += n - c.MarkAllAsFlushed() + require.NoError(b, c.MarkAllAsFlushed()) } }() diff --git a/operator/buffer/memory_test.go b/operator/buffer/memory_test.go index f40724875937..e92ddc077ca6 100644 --- a/operator/buffer/memory_test.go +++ b/operator/buffer/memory_test.go @@ -87,7 +87,7 @@ func TestMemoryBuffer(t *testing.T) { readyDone := make(chan struct{}) go func() { readyDone <- struct{}{} - readWaitN(t, b, 20, 0) + readWaitN(t, b, 20) readyDone <- struct{}{} }() <-readyDone @@ -103,7 +103,7 @@ func TestMemoryBuffer(t *testing.T) { readyDone := make(chan struct{}) go func() { readyDone <- struct{}{} - readWaitN(t, b, 15, 0) + readWaitN(t, b, 15) readyDone <- struct{}{} }() <-readyDone @@ -190,7 +190,7 @@ func TestMemoryBuffer(t *testing.T) { c, n, err := b.Read(dst) require.NoError(t, err) require.Equal(t, 1, n) - c.MarkAllAsFlushed() + require.NoError(t, c.MarkAllAsFlushed()) // Now there should be space for another entry err = b.Add(context.Background(), entry.New()) @@ -220,7 +220,7 @@ func TestMemoryBuffer(t *testing.T) { readCount := (writes - reads) / 2 c := readN(t, b, readCount, reads) if j%2 == 0 { - c.MarkAllAsFlushed() + require.NoError(t, c.MarkAllAsFlushed()) } reads += readCount } @@ -278,7 +278,7 @@ func BenchmarkMemoryBuffer(b *testing.B) { i += n go func() { time.Sleep(50 * time.Millisecond) - c.MarkAllAsFlushed() + require.NoError(b, c.MarkAllAsFlushed()) }() } }() diff --git a/operator/buffer/util_test.go b/operator/buffer/util_test.go index 6b0847a60fdc..f4e8dc06ea2f 100644 --- a/operator/buffer/util_test.go +++ b/operator/buffer/util_test.go @@ -49,22 +49,21 @@ func readN(t testing.TB, buffer Buffer, n, start int) Clearer { return f } -func readWaitN(t testing.TB, buffer Buffer, n, start int) Clearer { +func readWaitN(t testing.TB, buffer Buffer, n int) { entries := make([]*entry.Entry, n) ctx, cancel := context.WithTimeout(context.Background(), time.Minute) defer cancel() - f, readCount, err := buffer.ReadWait(ctx, entries) + _, readCount, err := buffer.ReadWait(ctx, entries) require.NoError(t, err) require.Equal(t, n, readCount) for i := 0; i < n; i++ { - require.Equal(t, intEntry(start+i), entries[i]) + require.Equal(t, intEntry(i), entries[i]) } - return f } func flushN(t testing.TB, buffer Buffer, n, start int) { f := readN(t, buffer, n, start) - f.MarkAllAsFlushed() + require.NoError(t, f.MarkAllAsFlushed()) } func panicOnErr(err error) { diff --git a/operator/build_context_test.go b/operator/build_context_test.go index 7547c412c76a..0449c6eda3ef 100644 --- a/operator/build_context_test.go +++ b/operator/build_context_test.go @@ -53,6 +53,5 @@ func TestBuildContext(t *testing.T) { bc2 := bc.WithDefaultOutputIDs([]string{"id1", "id2"}) require.Equal(t, []string{"id1", "id2"}, bc2.DefaultOutputIDs) require.Equal(t, []string{"orig"}, bc.DefaultOutputIDs) - }) } diff --git a/operator/builtin/input/file/file_test.go b/operator/builtin/input/file/file_test.go index a1f4e3459a98..9822399f4dcf 100644 --- a/operator/builtin/input/file/file_test.go +++ b/operator/builtin/input/file/file_test.go @@ -784,7 +784,7 @@ func (rt rotationTest) run(tc rotationTest, copyTruncate, sequential bool) func( select { case e := <-logReceived: received = append(received, e.Record.(string)) - case <-time.After(100 * time.Millisecond): + case <-time.After(200 * time.Millisecond): break LOOP } } @@ -805,71 +805,39 @@ func TestRotation(t *testing.T) { cases := []rotationTest{ { - name: "Fast/NoRotation", + name: "NoRotation", totalLines: 10, maxLinesPerFile: 10, maxBackupFiles: 1, writeInterval: time.Millisecond, - pollInterval: 20 * time.Millisecond, + pollInterval: 10 * time.Millisecond, }, { - name: "Fast/NoDeletion", + name: "NoDeletion", totalLines: 20, maxLinesPerFile: 10, maxBackupFiles: 1, writeInterval: time.Millisecond, - pollInterval: 20 * time.Millisecond, + pollInterval: 10 * time.Millisecond, }, { - name: "Fast/Deletion", + name: "Deletion", totalLines: 30, maxLinesPerFile: 10, maxBackupFiles: 1, writeInterval: time.Millisecond, - pollInterval: 20 * time.Millisecond, + pollInterval: 10 * time.Millisecond, ephemeralLines: true, }, { - name: "Fast/Deletion/ExceedFingerprint", + name: "Deletion/ExceedFingerprint", totalLines: 300, maxLinesPerFile: 100, maxBackupFiles: 1, writeInterval: time.Millisecond, - pollInterval: 20 * time.Millisecond, + pollInterval: 10 * time.Millisecond, ephemeralLines: true, }, - { - name: "Slow/NoRotation", - totalLines: 10, - maxLinesPerFile: 10, - maxBackupFiles: 1, - writeInterval: 3 * time.Millisecond, - pollInterval: 20 * time.Millisecond, - }, - { - name: "Slow/NoDeletion", - totalLines: 20, - maxLinesPerFile: 10, - maxBackupFiles: 1, - writeInterval: 3 * time.Millisecond, - pollInterval: 20 * time.Millisecond, - }, - { - name: "Slow/Deletion", - totalLines: 30, - maxLinesPerFile: 10, - maxBackupFiles: 1, - writeInterval: 3 * time.Millisecond, - pollInterval: 20 * time.Millisecond, - }, - { - name: "Slow/Deletion/ExceedFingerprint", - totalLines: 100, - maxLinesPerFile: 25, // ~20 is just enough to exceed 1000 bytes fingerprint at 50 chars per line - maxBackupFiles: 2, - writeInterval: 3 * time.Millisecond, - pollInterval: 20 * time.Millisecond, - }, } for _, tc := range cases { diff --git a/operator/flusher/flusher_test.go b/operator/flusher/flusher_test.go index 0661c958689b..a4ff71abfe7a 100644 --- a/operator/flusher/flusher_test.go +++ b/operator/flusher/flusher_test.go @@ -26,7 +26,6 @@ import ( ) func TestFlusher(t *testing.T) { - // Override setting for test maxElapsedTime = 5 * time.Second @@ -56,7 +55,6 @@ func TestFlusher(t *testing.T) { } func TestMaxElapsedTime(t *testing.T) { - // Override setting for test maxElapsedTime = 100 * time.Millisecond diff --git a/operator/helper/parser_test.go b/operator/helper/parser_test.go index 6f3a14c5ca43..d8cff872d00e 100644 --- a/operator/helper/parser_test.go +++ b/operator/helper/parser_test.go @@ -218,7 +218,6 @@ func TestParserInvalidTimeValidSeverityParse(t *testing.T) { } func TestParserValidTimeInvalidSeverityParse(t *testing.T) { - // Hawaiian Standard Time hst, err := time.LoadLocation("HST") require.NoError(t, err) diff --git a/operator/helper/persister_test.go b/operator/helper/persister_test.go index 66170b428262..ffceedb75d1a 100644 --- a/operator/helper/persister_test.go +++ b/operator/helper/persister_test.go @@ -34,6 +34,7 @@ func TestPersisterCache(t *testing.T) { func TestPersisterLoad(t *testing.T) { tempDir := testutil.NewTempDir(t) db, err := database.OpenDatabase(filepath.Join(tempDir, "test.db")) + require.NoError(t, err) persister := NewScopedDBPersister(db, "test") persister.Set("key", []byte("value")) diff --git a/operator/helper/severity_test.go b/operator/helper/severity_test.go index 748802fb3a52..62601557fde2 100644 --- a/operator/helper/severity_test.go +++ b/operator/helper/severity_test.go @@ -90,7 +90,6 @@ func otlpSevCases() []severityTestCase { } func TestSeverityParser(t *testing.T) { - testCases := []severityTestCase{ { name: "unknown", @@ -356,14 +355,13 @@ func TestSeverityParser(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - t.Run("root", tc.run(t, rootField)) - t.Run("non-root", tc.run(t, someField)) + t.Run("root", tc.run(rootField)) + t.Run("non-root", tc.run(someField)) }) } } -func (tc severityTestCase) run(t *testing.T, parseFrom entry.Field) func(*testing.T) { - +func (tc severityTestCase) run(parseFrom entry.Field) func(*testing.T) { return func(t *testing.T) { t.Parallel() @@ -383,7 +381,7 @@ func (tc severityTestCase) run(t *testing.T, parseFrom entry.Field) func(*testin require.NoError(t, err, "unexpected error when configuring operator") ent := entry.New() - ent.Set(parseFrom, tc.sample) + require.NoError(t, ent.Set(parseFrom, tc.sample)) err = severityParser.Parse(ent) if tc.parseErr { require.Error(t, err, "expected error when parsing sample") @@ -392,6 +390,5 @@ func (tc severityTestCase) run(t *testing.T, parseFrom entry.Field) func(*testin require.NoError(t, err) require.Equal(t, tc.expected, ent.Severity) - } } diff --git a/operator/helper/time.go b/operator/helper/time.go index a7359daf9198..77779d075c25 100644 --- a/operator/helper/time.go +++ b/operator/helper/time.go @@ -187,7 +187,7 @@ func (t *TimeParser) parseGotime(value interface{}) (time.Time, error) { result, err := time.ParseInLocation(t.Layout, str, t.location) - // Depending on the timezone database, we may get a psuedo-matching timezone + // Depending on the timezone database, we may get a pseudo-matching timezone // This is apparent when the zone is not "UTC", but the offset is still 0 zone, offset := result.Zone() if offset != 0 || zone == "UTC" { diff --git a/operator/helper/time_test.go b/operator/helper/time_test.go index c232d7d32531..6318f69d9946 100644 --- a/operator/helper/time_test.go +++ b/operator/helper/time_test.go @@ -76,7 +76,6 @@ func TestIsZero(t *testing.T) { } func TestTimeParser(t *testing.T) { - // Mountain Standard Time mst, err := time.LoadLocation("MST") require.NoError(t, err) @@ -319,22 +318,21 @@ func TestTimeParser(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { gotimeRootCfg := parseTimeTestConfig(GotimeKey, tc.gotimeLayout, tc.location, rootField) - t.Run("gotime-root", runTimeParseTest(t, gotimeRootCfg, makeTestEntry(rootField, tc.sample), false, false, tc.expected)) + t.Run("gotime-root", runTimeParseTest(gotimeRootCfg, makeTestEntry(rootField, tc.sample), false, false, tc.expected)) gotimeNonRootCfg := parseTimeTestConfig(GotimeKey, tc.gotimeLayout, tc.location, someField) - t.Run("gotime-non-root", runTimeParseTest(t, gotimeNonRootCfg, makeTestEntry(someField, tc.sample), false, false, tc.expected)) + t.Run("gotime-non-root", runTimeParseTest(gotimeNonRootCfg, makeTestEntry(someField, tc.sample), false, false, tc.expected)) strptimeRootCfg := parseTimeTestConfig(StrptimeKey, tc.strptimeLayout, tc.location, rootField) - t.Run("strptime-root", runTimeParseTest(t, strptimeRootCfg, makeTestEntry(rootField, tc.sample), false, false, tc.expected)) + t.Run("strptime-root", runTimeParseTest(strptimeRootCfg, makeTestEntry(rootField, tc.sample), false, false, tc.expected)) strptimeNonRootCfg := parseTimeTestConfig(StrptimeKey, tc.strptimeLayout, tc.location, someField) - t.Run("strptime-non-root", runTimeParseTest(t, strptimeNonRootCfg, makeTestEntry(someField, tc.sample), false, false, tc.expected)) + t.Run("strptime-non-root", runTimeParseTest(strptimeNonRootCfg, makeTestEntry(someField, tc.sample), false, false, tc.expected)) }) } } func TestTimeEpochs(t *testing.T) { - testCases := []struct { name string sample interface{} @@ -487,16 +485,15 @@ func TestTimeEpochs(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { rootCfg := parseTimeTestConfig(EpochKey, tc.layout, "", rootField) - t.Run("epoch-root", runLossyTimeParseTest(t, rootCfg, makeTestEntry(rootField, tc.sample), false, false, tc.expected, tc.maxLoss)) + t.Run("epoch-root", runLossyTimeParseTest(rootCfg, makeTestEntry(rootField, tc.sample), false, false, tc.expected, tc.maxLoss)) nonRootCfg := parseTimeTestConfig(EpochKey, tc.layout, "", someField) - t.Run("epoch-non-root", runLossyTimeParseTest(t, nonRootCfg, makeTestEntry(someField, tc.sample), false, false, tc.expected, tc.maxLoss)) + t.Run("epoch-non-root", runLossyTimeParseTest(nonRootCfg, makeTestEntry(someField, tc.sample), false, false, tc.expected, tc.maxLoss)) }) } } func TestTimeErrors(t *testing.T) { - testCases := []struct { name string sample interface{} @@ -563,20 +560,19 @@ func TestTimeErrors(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { rootCfg := parseTimeTestConfig(tc.layoutType, tc.layout, tc.location, rootField) - t.Run("err-root", runTimeParseTest(t, rootCfg, makeTestEntry(rootField, tc.sample), tc.buildErr, tc.parseErr, time.Now())) + t.Run("err-root", runTimeParseTest(rootCfg, makeTestEntry(rootField, tc.sample), tc.buildErr, tc.parseErr, time.Now())) nonRootCfg := parseTimeTestConfig(tc.layoutType, tc.layout, tc.location, someField) - t.Run("err-non-root", runTimeParseTest(t, nonRootCfg, makeTestEntry(someField, tc.sample), tc.buildErr, tc.parseErr, time.Now())) + t.Run("err-non-root", runTimeParseTest(nonRootCfg, makeTestEntry(someField, tc.sample), tc.buildErr, tc.parseErr, time.Now())) }) } } -func runTimeParseTest(t *testing.T, timeParser *TimeParser, ent *entry.Entry, buildErr bool, parseErr bool, expected time.Time) func(*testing.T) { - return runLossyTimeParseTest(t, timeParser, ent, buildErr, parseErr, expected, time.Duration(0)) +func runTimeParseTest(timeParser *TimeParser, ent *entry.Entry, buildErr bool, parseErr bool, expected time.Time) func(*testing.T) { + return runLossyTimeParseTest(timeParser, ent, buildErr, parseErr, expected, time.Duration(0)) } -func runLossyTimeParseTest(t *testing.T, timeParser *TimeParser, ent *entry.Entry, buildErr bool, parseErr bool, expected time.Time, maxLoss time.Duration) func(*testing.T) { - +func runLossyTimeParseTest(timeParser *TimeParser, ent *entry.Entry, buildErr bool, parseErr bool, expected time.Time, maxLoss time.Duration) func(*testing.T) { return func(t *testing.T) { buildContext := testutil.NewBuildContext(t) @@ -614,6 +610,6 @@ func parseTimeTestConfig(layoutType, layout, location string, parseFrom entry.Fi func makeTestEntry(field entry.Field, value interface{}) *entry.Entry { e := entry.New() - e.Set(field, value) + _ = e.Set(field, value) return e } diff --git a/pipeline/directed_test.go b/pipeline/directed_test.go index 55cea6a4834b..60adb37907e5 100644 --- a/pipeline/directed_test.go +++ b/pipeline/directed_test.go @@ -92,7 +92,7 @@ func TestPipeline(t *testing.T) { err = pipeline.Start() require.NoError(t, err) - pipeline.Stop() + require.NoError(t, pipeline.Stop()) }) t.Run("MultipleStop", func(t *testing.T) { @@ -102,8 +102,8 @@ func TestPipeline(t *testing.T) { err = pipeline.Start() require.NoError(t, err) - pipeline.Stop() - pipeline.Stop() + require.NoError(t, pipeline.Stop()) + require.NoError(t, pipeline.Stop()) }) t.Run("DuplicateNodeIDs", func(t *testing.T) { diff --git a/plugin/config.go b/plugin/config.go index c56eeeb4979a..a52dbe484851 100644 --- a/plugin/config.go +++ b/plugin/config.go @@ -33,10 +33,10 @@ var _ operator.Builder = (*Config)(nil) type Config struct { helper.WriterConfig Plugin *Plugin `json:"-" yaml:"-"` - Parameters map[string]interface{} `json:",squash" yaml:",squash"` + Parameters map[string]interface{} `json:",inline" yaml:",squash"` } -// BuildMulti implements operator.MultiBuilder +// Build implements operator.MultiBuilder func (c *Config) Build(bc operator.BuildContext) ([]operator.Operator, error) { if bc.PluginDepth > 10 { return nil, errors.NewError("reached max plugin depth", "ensure that there are no recursive dependencies in plugins") diff --git a/plugin/parameter.go b/plugin/parameter.go index 4f9aae152ad8..b5f989346024 100644 --- a/plugin/parameter.go +++ b/plugin/parameter.go @@ -119,7 +119,6 @@ func (p Parameter) validateEnumValue(value interface{}) error { } func (p Parameter) validateDefinition() error { - if err := p.validateType(); err != nil { return err } diff --git a/plugin/plugin_test.go b/plugin/plugin_test.go index 0d7ae5708e9a..743cb8d29c30 100644 --- a/plugin/plugin_test.go +++ b/plugin/plugin_test.go @@ -65,7 +65,6 @@ func TestRegisterPlugins(t *testing.T) { } func TestPluginRender(t *testing.T) { - t.Run("ErrorExecFailure", func(t *testing.T) { plugin, err := NewPlugin("panicker", []byte(`pipeline:\n {{ .panicker }}`)) require.NoError(t, err) @@ -80,10 +79,6 @@ func TestPluginRender(t *testing.T) { }) } -func clearRegistry() { - operator.DefaultRegistry = operator.NewRegistry() -} - func TestPluginMetadata(t *testing.T) { testCases := []struct { name string