|
| 1 | +package input |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + |
| 6 | + "github.com/fluent/fluent-operator/v3/apis/fluentbit/v1alpha2/plugins" |
| 7 | + "github.com/fluent/fluent-operator/v3/apis/fluentbit/v1alpha2/plugins/params" |
| 8 | + "github.com/fluent/fluent-operator/v3/pkg/utils" |
| 9 | + . "github.com/onsi/gomega" |
| 10 | +) |
| 11 | + |
| 12 | +func TestSyslog_Name(t *testing.T) { |
| 13 | + g := NewGomegaWithT(t) |
| 14 | + syslog := Syslog{} |
| 15 | + g.Expect(syslog.Name()).To(Equal("syslog")) |
| 16 | +} |
| 17 | + |
| 18 | +func TestSyslog_Params(t *testing.T) { |
| 19 | + g := NewGomegaWithT(t) |
| 20 | + sl := plugins.NewSecretLoader(nil, "test namespace") |
| 21 | + |
| 22 | + syslog := Syslog{ |
| 23 | + Mode: "tcp", |
| 24 | + Listen: "0.0.0.0", |
| 25 | + Port: utils.ToPtr[int32](514), |
| 26 | + Path: "/tmp/syslog.sock", |
| 27 | + UnixPerm: utils.ToPtr[int32](644), |
| 28 | + Parser: "syslog-rfc5424", |
| 29 | + BufferChunkSize: "32KB", |
| 30 | + BufferMaxSize: "256KB", |
| 31 | + ReceiveBufferSize: "1MB", |
| 32 | + SourceAddressKey: "source_address", |
| 33 | + Tag: "syslog.tag", |
| 34 | + } |
| 35 | + |
| 36 | + expected := params.NewKVs() |
| 37 | + expected.Insert("Mode", "tcp") |
| 38 | + expected.Insert("Listen", "0.0.0.0") |
| 39 | + expected.Insert("Path", "/tmp/syslog.sock") |
| 40 | + expected.Insert("Parser", "syslog-rfc5424") |
| 41 | + expected.Insert("Buffer_Chunk_Size", "32KB") |
| 42 | + expected.Insert("Buffer_Max_Size", "256KB") |
| 43 | + expected.Insert("Receive_Buffer_Size", "1MB") |
| 44 | + expected.Insert("Source_Address_Key", "source_address") |
| 45 | + expected.Insert("Tag", "syslog.tag") |
| 46 | + expected.Insert("Port", "514") |
| 47 | + expected.Insert("Unix_Perm", "644") |
| 48 | + |
| 49 | + kvs, err := syslog.Params(sl) |
| 50 | + g.Expect(err).NotTo(HaveOccurred()) |
| 51 | + g.Expect(kvs).To(Equal(expected)) |
| 52 | +} |
0 commit comments