Skip to content

Commit be41f22

Browse files
mob-galtrynmarcofranssen
authored andcommitted
Adds syslog_types_test.go and addresses lowercase for workers
Signed-off-by: Nick Galtry <nick.galtry@mobilise.cloud>
1 parent a4537ef commit be41f22

File tree

2 files changed

+62
-2
lines changed

2 files changed

+62
-2
lines changed

apis/fluentbit/v1alpha2/plugins/output/syslog_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ type Syslog struct {
4646
// Limit the maximum number of Chunks in the filesystem for the current output logical destination.
4747
TotalLimitSize string `json:"totalLimitSize,omitempty"`
4848
// Enables dedicated thread(s) for this output. Default value is set since version 1.8.13. For previous versions is 0.
49-
Workers *int32 `json:"workers,omitempty"`
49+
workers *int32 `json:"workers,omitempty"`
5050
}
5151

5252
func (*Syslog) Name() string {
@@ -71,7 +71,7 @@ func (s *Syslog) Params(sl plugins.SecretLoader) (*params.KVs, error) {
7171
plugins.InsertKVString(kvs, "syslog_sd_key", s.SyslogSDKey)
7272
plugins.InsertKVString(kvs, "storage.total_limit_size", s.TotalLimitSize)
7373
plugins.InsertKVField(kvs, "syslog_maxsize", s.SyslogMaxSize)
74-
plugins.InsertKVField(kvs, "Workers", s.Workers)
74+
plugins.InsertKVField(kvs, "workers", s.workers)
7575

7676
if s.TLS != nil {
7777
tls, err := s.TLS.Params(sl)
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package output
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 TestOutput_Syslog_Params(t *testing.T) {
13+
g := NewGomegaWithT(t)
14+
15+
sl := plugins.NewSecretLoader(nil, "test-namespace")
16+
17+
// Initialize Syslog struct based on your provided types
18+
syslog := Syslog{
19+
Host: "127.0.0.1",
20+
Port: utils.ToPtr[int32](514),
21+
Mode: "tcp",
22+
SyslogFormat: "rfc5424",
23+
SyslogMaxSize: utils.ToPtr[int32](2048),
24+
SyslogSeverityKey: "severity",
25+
SyslogFacilityKey: "facility",
26+
SyslogHostnameKey: "hostname",
27+
SyslogAppnameKey: "appname",
28+
SyslogProcessIDKey: "pid",
29+
SyslogMessageIDKey: "msgid",
30+
SyslogSDKey: "structured_data",
31+
SyslogMessageKey: "message",
32+
TotalLimitSize: "1G",
33+
workers: utils.ToPtr[int32](2),
34+
}
35+
36+
// Define the expected Key-Value pairs based on your Params() logic
37+
expected := params.NewKVs()
38+
expected.Insert("Host", "127.0.0.1")
39+
expected.Insert("port", "514")
40+
expected.Insert("mode", "tcp")
41+
expected.Insert("syslog_hostname_key", "hostname")
42+
expected.Insert("syslog_appname_key", "appname")
43+
expected.Insert("syslog_message_key", "message")
44+
expected.Insert("syslog_format", "rfc5424")
45+
expected.Insert("syslog_severity_key", "severity")
46+
expected.Insert("syslog_facility_key", "facility")
47+
expected.Insert("syslog_procid_key", "pid") // Note: matches your implementation
48+
expected.Insert("syslog_msgid_key", "msgid")
49+
expected.Insert("syslog_sd_key", "structured_data") // Note: matches your implementation
50+
expected.Insert("storage.total_limit_size", "1G")
51+
expected.Insert("syslog_maxsize", "2048")
52+
expected.Insert("workers", "2")
53+
54+
// Execute the translation
55+
kvs, err := syslog.Params(sl)
56+
57+
// Assertions
58+
g.Expect(err).NotTo(HaveOccurred())
59+
g.Expect(kvs).To(Equal(expected))
60+
}

0 commit comments

Comments
 (0)