Skip to content

Commit

Permalink
Adding replacement for input v1
Browse files Browse the repository at this point in the history
  • Loading branch information
mjmbischoff committed Sep 2, 2021
1 parent ad521cd commit cee8602
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions filebeat/input/kafka/input_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,32 @@
package kafka

import (
"github.com/elastic/beats/v7/libbeat/common"
"github.com/elastic/beats/v7/libbeat/tests/resources"
"github.com/stretchr/testify/require"
"testing"
)

func TestNewInputDone(t *testing.T) {
//config := common.MapStr{
// "hosts": "localhost:9092",
// "topics": "messages",
// "group_id": "filebeat",
//}
// TODO find v2 equivalent inputtest.AssertNotStartedInputCanBeDone(t, NewInput, &config)
config := common.MustNewConfigFrom(common.MapStr{
"hosts": "localhost:9092",
"topics": "messages",
"group_id": "filebeat",
})

AssertNotStartedInputCanBeDone(t, config)
}

// AssertNotStartedInputCanBeDone checks that the context of an input can be
// done before starting the input, and it doesn't leak goroutines. This is
// important to confirm that leaks don't happen with CheckConfig.
func AssertNotStartedInputCanBeDone(t *testing.T, configMap *common.Config) {
goroutines := resources.NewGoroutinesChecker()
defer goroutines.Check(t)

config, err := common.NewConfigFrom(configMap)
require.NoError(t, err)

_, err = Plugin().Manager.Create(config)
require.NoError(t, err)
}

0 comments on commit cee8602

Please sign in to comment.