forked from thecubed/gogstash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinputsocket_test.go
50 lines (43 loc) · 1023 Bytes
/
inputsocket_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package inputsocket
import (
"context"
"os"
"strings"
"testing"
"time"
"github.com/Sirupsen/logrus"
"github.com/stretchr/testify/require"
"github.com/tsaikd/gogstash/config"
)
var (
logger = config.Logger
)
func init() {
logger.Level = logrus.DebugLevel
config.RegistInputHandler(ModuleName, InitHandler)
}
func Test_input_socket_module(t *testing.T) {
require := require.New(t)
require.NotNil(require)
ctx := context.Background()
conf, err := config.LoadFromYAML([]byte(strings.TrimSpace(`
debugch: true
input:
- type: socket
socket: unix
address: "/tmp/gogstash-test-unix.sock"
- type: socket
socket: unixpacket
address: "/tmp/gogstash-test-unixpacket.sock"
- type: socket
socket: tcp
address: ":9999"
`)))
require.NoError(err)
require.NoError(conf.Start(ctx))
waitsec := 10
logger.Infof("Wait for %d seconds", waitsec)
time.Sleep(time.Duration(waitsec) * time.Second)
os.Remove("/tmp/gogstash-test-unix.sock")
os.Remove("/tmp/gogstash-test-unixpacket.sock")
}