From ff9250259fa580f9468b1ed83cf0c9a58de5f1fe Mon Sep 17 00:00:00 2001 From: Marek Zydor Date: Wed, 6 Nov 2024 21:06:34 +0100 Subject: [PATCH 01/14] fix(common.socket): Use read buffer size config setting as a datagram reader buffer size. --- plugins/common/socket/datagram.go | 13 +++++++++---- plugins/common/socket/socket.go | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/plugins/common/socket/datagram.go b/plugins/common/socket/datagram.go index 0f84b7d66f9e2..225c99dd54144 100644 --- a/plugins/common/socket/datagram.go +++ b/plugins/common/socket/datagram.go @@ -49,7 +49,7 @@ func (l *packetListener) listenData(onData CallbackData, onError CallbackError) go func() { defer l.wg.Done() - buf := make([]byte, 64*1024) // 64kb - maximum size of IP packet + buf := make([]byte, l.ReadBufferSize) for { n, src, err := l.conn.ReadFrom(buf) receiveTime := time.Now() @@ -88,7 +88,7 @@ func (l *packetListener) listenConnection(onConnection CallbackConnection, onErr defer l.wg.Done() defer l.conn.Close() - buf := make([]byte, 64*1024) // 64kb - maximum size of IP packet + buf := make([]byte, l.ReadBufferSize) for { // Wait for packets and read them n, src, err := l.conn.ReadFrom(buf) @@ -133,7 +133,7 @@ func (l *packetListener) listenConnection(onConnection CallbackConnection, onErr }() } -func (l *packetListener) setupUnixgram(u *url.URL, socketMode string) error { +func (l *packetListener) setupUnixgram(u *url.URL, socketMode string, bufferSize int) error { l.path = filepath.FromSlash(u.Path) if runtime.GOOS == "windows" && strings.Contains(l.path, ":") { l.path = strings.TrimPrefix(l.path, `\`) @@ -162,6 +162,10 @@ func (l *packetListener) setupUnixgram(u *url.URL, socketMode string) error { } } + if bufferSize > 0 { + l.ReadBufferSize = bufferSize + } + return l.setupDecoder() } @@ -194,8 +198,9 @@ func (l *packetListener) setupUDP(u *url.URL, ifname string, bufferSize int) err if bufferSize > 0 { if err := conn.SetReadBuffer(bufferSize); err != nil { - l.Log.Warnf("Setting read buffer on %s socket failed: %v", u.Scheme, err) + l.Log.Errorf("Setting read buffer on %s socket failed: %v", u.Scheme, err) } + l.ReadBufferSize = bufferSize } l.conn = conn diff --git a/plugins/common/socket/socket.go b/plugins/common/socket/socket.go index ed5bc499cd15e..4f12a9a0fe53f 100644 --- a/plugins/common/socket/socket.go +++ b/plugins/common/socket/socket.go @@ -136,7 +136,7 @@ func (s *Socket) Setup() error { s.listener = l case "unixgram": l := newPacketListener(s.ContentEncoding, s.MaxDecompressionSize, s.MaxParallelParsers) - if err := l.setupUnixgram(s.url, s.SocketMode); err != nil { + if err := l.setupUnixgram(s.url, s.SocketMode, int(s.ReadBufferSize)); err != nil { return err } s.listener = l From 521e73a3ee7af2d5e9c05315c606110e6cd1ab4f Mon Sep 17 00:00:00 2001 From: Marek Zydor Date: Wed, 6 Nov 2024 21:20:52 +0100 Subject: [PATCH 02/14] Fix the code formatting. --- plugins/common/socket/datagram.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/common/socket/datagram.go b/plugins/common/socket/datagram.go index 225c99dd54144..005a1d65a8fd4 100644 --- a/plugins/common/socket/datagram.go +++ b/plugins/common/socket/datagram.go @@ -162,9 +162,9 @@ func (l *packetListener) setupUnixgram(u *url.URL, socketMode string, bufferSize } } - if bufferSize > 0 { - l.ReadBufferSize = bufferSize - } + if bufferSize > 0 { + l.ReadBufferSize = bufferSize + } return l.setupDecoder() } @@ -200,7 +200,7 @@ func (l *packetListener) setupUDP(u *url.URL, ifname string, bufferSize int) err if err := conn.SetReadBuffer(bufferSize); err != nil { l.Log.Errorf("Setting read buffer on %s socket failed: %v", u.Scheme, err) } - l.ReadBufferSize = bufferSize + l.ReadBufferSize = bufferSize } l.conn = conn From 434cea0e82494b4d5998518721fa03932c61c2c1 Mon Sep 17 00:00:00 2001 From: Marek Zydor Date: Wed, 6 Nov 2024 23:37:17 +0100 Subject: [PATCH 03/14] test(common.socket): Add unit test for ReadBufferSize in datagram reader --- plugins/common/socket/datagram.go | 6 +- .../socket_listener/socket_listener_test.go | 82 ++++++++++++++++++- 2 files changed, 85 insertions(+), 3 deletions(-) diff --git a/plugins/common/socket/datagram.go b/plugins/common/socket/datagram.go index 005a1d65a8fd4..def6e1ad43c10 100644 --- a/plugins/common/socket/datagram.go +++ b/plugins/common/socket/datagram.go @@ -164,6 +164,8 @@ func (l *packetListener) setupUnixgram(u *url.URL, socketMode string, bufferSize if bufferSize > 0 { l.ReadBufferSize = bufferSize + } else { + l.ReadBufferSize = 64 * 1024 // 64kb - IP packet size } return l.setupDecoder() @@ -198,9 +200,11 @@ func (l *packetListener) setupUDP(u *url.URL, ifname string, bufferSize int) err if bufferSize > 0 { if err := conn.SetReadBuffer(bufferSize); err != nil { - l.Log.Errorf("Setting read buffer on %s socket failed: %v", u.Scheme, err) + l.Log.Warnf("Setting read buffer on %s socket failed: %v", u.Scheme, err) } l.ReadBufferSize = bufferSize + } else { + l.ReadBufferSize = 64 * 1024 // 64kb - IP packet size } l.conn = conn diff --git a/plugins/inputs/socket_listener/socket_listener_test.go b/plugins/inputs/socket_listener/socket_listener_test.go index 31585d457d6fd..d2b8146a52630 100644 --- a/plugins/inputs/socket_listener/socket_listener_test.go +++ b/plugins/inputs/socket_listener/socket_listener_test.go @@ -12,6 +12,7 @@ import ( "runtime" "sort" "strings" + "syscall" "testing" "time" @@ -197,8 +198,8 @@ func TestSocketListener(t *testing.T) { } } -func TestLargeReadBuffer(t *testing.T) { - // Construct a buffer-size setting of 100KiB +func TestLargeReadBufferTCP(t *testing.T) { + // Construct a buffer-size setting of 1000KiB var bufsize config.Size require.NoError(t, bufsize.UnmarshalText([]byte("1000KiB"))) @@ -262,6 +263,83 @@ func TestLargeReadBuffer(t *testing.T) { testutil.RequireMetricsEqual(t, expected, actual, testutil.IgnoreTime()) } +func TestLargeReadBufferUnixgram(t *testing.T) { + // Construct a buffer-size setting of 100KiB + // Assuming that the testing environment has net.core.wmem_max set to a value greater than 100KiB + if runtime.GOOS == "windows" { + t.Skip("Skipping on Windows, as unixgram sockets are not supported") + } + + var bufsize config.Size + require.NoError(t, bufsize.UnmarshalText([]byte("100KiB"))) + + // Setup plugin with a sufficient read buffer + plugin := &SocketListener{ + ServiceAddress: "unixgram://127.0.0.1:0", + Config: socket.Config{ + ReadBufferSize: bufsize, + }, + Log: &testutil.Logger{}, + } + parser := &value.Parser{ + MetricName: "test", + DataType: "string", + } + require.NoError(t, parser.Init()) + plugin.SetParser(parser) + + // Create a large message with the readbuffer size + message := bytes.Repeat([]byte{'a'}, int(bufsize)) + expected := []telegraf.Metric{ + metric.New( + "test", + map[string]string{}, + map[string]interface{}{"value": string(message)}, + time.Unix(0, 0), + ), + } + + // Start the plugin + var acc testutil.Accumulator + require.NoError(t, plugin.Init()) + require.NoError(t, plugin.Start(&acc)) + defer plugin.Stop() + + addr := plugin.socket.Address() + + // Setup the client for submitting data + client, err := createClient(plugin.ServiceAddress, addr, nil) + require.NoError(t, err) + defer client.Close() + + // Check the socket write buffer size + unixConn, ok := client.(*net.UnixConn) + require.True(t, ok, "client is not a *net.UnixConn") + fd, _ := unixConn.File() + value, _ := syscall.GetsockoptInt(int(fd.Fd()), syscall.SOL_SOCKET, syscall.SO_SNDBUF) + if value < int(bufsize) { + t.Skip("Unixgram write buffer size is too small to write the message, skipping test") + } + + // Write the message + _, err = client.Write(message) + require.NoError(t, err) + client.Close() + + getError := func() error { + acc.Lock() + defer acc.Unlock() + return acc.FirstError() + } + + // Test the resulting metrics and compare against expected results + require.Eventuallyf(t, func() bool { + return acc.NMetrics() >= uint64(len(expected)) + }, time.Second, 100*time.Millisecond, "did not receive metrics (%d): %v", acc.NMetrics(), getError()) + actual := acc.GetTelegrafMetrics() + testutil.RequireMetricsEqual(t, expected, actual, testutil.IgnoreTime()) +} + func TestCases(t *testing.T) { // Get all directories in testdata folders, err := os.ReadDir("testcases") From f0acac27b355810b91e3db1d0b6c009365680090 Mon Sep 17 00:00:00 2001 From: Marek Zydor Date: Thu, 7 Nov 2024 10:10:47 +0100 Subject: [PATCH 04/14] Add checks for errors in TestLargeReadBufferUnixgram. Use IP packet size as the only possible buffer size value for UDP. --- plugins/common/socket/datagram.go | 5 ++--- plugins/inputs/socket_listener/socket_listener_test.go | 8 +++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/plugins/common/socket/datagram.go b/plugins/common/socket/datagram.go index def6e1ad43c10..1f2b0c21dfb3b 100644 --- a/plugins/common/socket/datagram.go +++ b/plugins/common/socket/datagram.go @@ -202,11 +202,9 @@ func (l *packetListener) setupUDP(u *url.URL, ifname string, bufferSize int) err if err := conn.SetReadBuffer(bufferSize); err != nil { l.Log.Warnf("Setting read buffer on %s socket failed: %v", u.Scheme, err) } - l.ReadBufferSize = bufferSize - } else { - l.ReadBufferSize = 64 * 1024 // 64kb - IP packet size } + l.ReadBufferSize = 64 * 1024 // 64kb - IP packet size l.conn = conn return l.setupDecoder() } @@ -217,6 +215,7 @@ func (l *packetListener) setupIP(u *url.URL) error { return fmt.Errorf("listening (ip) failed: %w", err) } + l.ReadBufferSize = 64 * 1024 // 64kb - IP packet size l.conn = conn return l.setupDecoder() } diff --git a/plugins/inputs/socket_listener/socket_listener_test.go b/plugins/inputs/socket_listener/socket_listener_test.go index d2b8146a52630..69d2417e9ab99 100644 --- a/plugins/inputs/socket_listener/socket_listener_test.go +++ b/plugins/inputs/socket_listener/socket_listener_test.go @@ -315,9 +315,11 @@ func TestLargeReadBufferUnixgram(t *testing.T) { // Check the socket write buffer size unixConn, ok := client.(*net.UnixConn) require.True(t, ok, "client is not a *net.UnixConn") - fd, _ := unixConn.File() - value, _ := syscall.GetsockoptInt(int(fd.Fd()), syscall.SOL_SOCKET, syscall.SO_SNDBUF) - if value < int(bufsize) { + fd, err := unixConn.File() + require.NoError(t, err) + wmemMax, err := syscall.GetsockoptInt(int(fd.Fd()), syscall.SOL_SOCKET, syscall.SO_SNDBUF) + require.NoError(t, err) + if wmemMax < int(bufsize) { t.Skip("Unixgram write buffer size is too small to write the message, skipping test") } From 6e856a5035c5983f4d6241b4d796efb1efa4b4e3 Mon Sep 17 00:00:00 2001 From: Marek Zydor Date: Thu, 7 Nov 2024 11:02:58 +0100 Subject: [PATCH 05/14] Correct the code formatting. --- plugins/common/socket/datagram.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/common/socket/datagram.go b/plugins/common/socket/datagram.go index 1f2b0c21dfb3b..d3698be9bf1f4 100644 --- a/plugins/common/socket/datagram.go +++ b/plugins/common/socket/datagram.go @@ -204,7 +204,7 @@ func (l *packetListener) setupUDP(u *url.URL, ifname string, bufferSize int) err } } - l.ReadBufferSize = 64 * 1024 // 64kb - IP packet size + l.ReadBufferSize = 64 * 1024 // 64kb - IP packet size l.conn = conn return l.setupDecoder() } @@ -215,7 +215,7 @@ func (l *packetListener) setupIP(u *url.URL) error { return fmt.Errorf("listening (ip) failed: %w", err) } - l.ReadBufferSize = 64 * 1024 // 64kb - IP packet size + l.ReadBufferSize = 64 * 1024 // 64kb - IP packet size l.conn = conn return l.setupDecoder() } From b5f3268f6fc93a722d6cf411ab48846701c3cd17 Mon Sep 17 00:00:00 2001 From: Marek Zydor Date: Thu, 7 Nov 2024 20:51:53 +0100 Subject: [PATCH 06/14] Add socket file creation. Disable linter when checking write buffer. --- plugins/inputs/socket_listener/socket_listener_test.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins/inputs/socket_listener/socket_listener_test.go b/plugins/inputs/socket_listener/socket_listener_test.go index 69d2417e9ab99..14cdf274a9e6e 100644 --- a/plugins/inputs/socket_listener/socket_listener_test.go +++ b/plugins/inputs/socket_listener/socket_listener_test.go @@ -273,9 +273,16 @@ func TestLargeReadBufferUnixgram(t *testing.T) { var bufsize config.Size require.NoError(t, bufsize.UnmarshalText([]byte("100KiB"))) + // Create a socket + sock, err := os.CreateTemp("", "sock-") + require.NoError(t, err) + defer sock.Close() + defer os.Remove(sock.Name()) + serverAddr = sock.Name() + // Setup plugin with a sufficient read buffer plugin := &SocketListener{ - ServiceAddress: "unixgram://127.0.0.1:0", + ServiceAddress: "unixgram" + "://" + serverAddr, Config: socket.Config{ ReadBufferSize: bufsize, }, @@ -317,6 +324,7 @@ func TestLargeReadBufferUnixgram(t *testing.T) { require.True(t, ok, "client is not a *net.UnixConn") fd, err := unixConn.File() require.NoError(t, err) + //nolint:all // This is for ignoring golint windows parser error wmemMax, err := syscall.GetsockoptInt(int(fd.Fd()), syscall.SOL_SOCKET, syscall.SO_SNDBUF) require.NoError(t, err) if wmemMax < int(bufsize) { From 20abc156e052347d82fa7fd99b502a7c1dbc0258 Mon Sep 17 00:00:00 2001 From: Marek Zydor Date: Thu, 7 Nov 2024 21:03:18 +0100 Subject: [PATCH 07/14] Define serverAddr var in TestLargeReadBufferUnixgram --- plugins/inputs/socket_listener/socket_listener_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/inputs/socket_listener/socket_listener_test.go b/plugins/inputs/socket_listener/socket_listener_test.go index 14cdf274a9e6e..3a04e11280a52 100644 --- a/plugins/inputs/socket_listener/socket_listener_test.go +++ b/plugins/inputs/socket_listener/socket_listener_test.go @@ -278,7 +278,7 @@ func TestLargeReadBufferUnixgram(t *testing.T) { require.NoError(t, err) defer sock.Close() defer os.Remove(sock.Name()) - serverAddr = sock.Name() + var serverAddr = sock.Name() // Setup plugin with a sufficient read buffer plugin := &SocketListener{ From 44fcea67a29e82a15fff66db9f7ba8f44437e2f5 Mon Sep 17 00:00:00 2001 From: Marek Zydor Date: Thu, 7 Nov 2024 22:14:41 +0100 Subject: [PATCH 08/14] Remove nolint --- plugins/inputs/socket_listener/socket_listener_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/inputs/socket_listener/socket_listener_test.go b/plugins/inputs/socket_listener/socket_listener_test.go index 3a04e11280a52..1348668803c94 100644 --- a/plugins/inputs/socket_listener/socket_listener_test.go +++ b/plugins/inputs/socket_listener/socket_listener_test.go @@ -324,7 +324,6 @@ func TestLargeReadBufferUnixgram(t *testing.T) { require.True(t, ok, "client is not a *net.UnixConn") fd, err := unixConn.File() require.NoError(t, err) - //nolint:all // This is for ignoring golint windows parser error wmemMax, err := syscall.GetsockoptInt(int(fd.Fd()), syscall.SOL_SOCKET, syscall.SO_SNDBUF) require.NoError(t, err) if wmemMax < int(bufsize) { From e48fa206678851244f737dfb4ab4bff8b86a33cb Mon Sep 17 00:00:00 2001 From: Marek Zydor Date: Wed, 13 Nov 2024 19:40:29 +0100 Subject: [PATCH 09/14] Use SetWriteBuffer instead of syscall. If SetWriteBuffer execution fails then skip test. --- plugins/inputs/socket_listener/socket_listener_test.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/plugins/inputs/socket_listener/socket_listener_test.go b/plugins/inputs/socket_listener/socket_listener_test.go index 1348668803c94..fc86f8759b43b 100644 --- a/plugins/inputs/socket_listener/socket_listener_test.go +++ b/plugins/inputs/socket_listener/socket_listener_test.go @@ -12,7 +12,6 @@ import ( "runtime" "sort" "strings" - "syscall" "testing" "time" @@ -322,12 +321,9 @@ func TestLargeReadBufferUnixgram(t *testing.T) { // Check the socket write buffer size unixConn, ok := client.(*net.UnixConn) require.True(t, ok, "client is not a *net.UnixConn") - fd, err := unixConn.File() - require.NoError(t, err) - wmemMax, err := syscall.GetsockoptInt(int(fd.Fd()), syscall.SOL_SOCKET, syscall.SO_SNDBUF) - require.NoError(t, err) - if wmemMax < int(bufsize) { - t.Skip("Unixgram write buffer size is too small to write the message, skipping test") + err = unixConn.SetWriteBuffer(len(message)) + if err != nil { + t.Skipf("Failed to set write buffer size: %v. Skipping test.", err) } // Write the message From 7dc17c4582aae2c8858ae74187e88510f7cc0a98 Mon Sep 17 00:00:00 2001 From: Marek Zydor Date: Wed, 13 Nov 2024 20:13:08 +0100 Subject: [PATCH 10/14] Trying to skip test if buffer space is too low. --- plugins/inputs/socket_listener/socket_listener_test.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/inputs/socket_listener/socket_listener_test.go b/plugins/inputs/socket_listener/socket_listener_test.go index fc86f8759b43b..dc0e1fec45f70 100644 --- a/plugins/inputs/socket_listener/socket_listener_test.go +++ b/plugins/inputs/socket_listener/socket_listener_test.go @@ -270,7 +270,7 @@ func TestLargeReadBufferUnixgram(t *testing.T) { } var bufsize config.Size - require.NoError(t, bufsize.UnmarshalText([]byte("100KiB"))) + require.NoError(t, bufsize.UnmarshalText([]byte("10000KiB"))) // Create a socket sock, err := os.CreateTemp("", "sock-") @@ -328,7 +328,13 @@ func TestLargeReadBufferUnixgram(t *testing.T) { // Write the message _, err = client.Write(message) - require.NoError(t, err) + if err != nil { + if strings.Contains(err.Error(), "message too long") || strings.Contains(err.Error(), "no buffer space available") { + t.Skipf("No buffer space available. Skipping test.") + } else { + require.NoError(t, err) + } + } client.Close() getError := func() error { From c45e1df40c93cec628decf7e9fa5d0ee7e51158e Mon Sep 17 00:00:00 2001 From: Marek Zydor Date: Wed, 13 Nov 2024 20:45:05 +0100 Subject: [PATCH 11/14] Revert buffer size back to 100 KiB --- plugins/inputs/socket_listener/socket_listener_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/inputs/socket_listener/socket_listener_test.go b/plugins/inputs/socket_listener/socket_listener_test.go index dc0e1fec45f70..5b500e054f61a 100644 --- a/plugins/inputs/socket_listener/socket_listener_test.go +++ b/plugins/inputs/socket_listener/socket_listener_test.go @@ -270,7 +270,7 @@ func TestLargeReadBufferUnixgram(t *testing.T) { } var bufsize config.Size - require.NoError(t, bufsize.UnmarshalText([]byte("10000KiB"))) + require.NoError(t, bufsize.UnmarshalText([]byte("100KiB"))) // Create a socket sock, err := os.CreateTemp("", "sock-") From d52625c8237b7118c31cc73ebe9c25aa9283f431 Mon Sep 17 00:00:00 2001 From: Marek Zydor Date: Wed, 13 Nov 2024 21:05:36 +0100 Subject: [PATCH 12/14] Skip on mac --- .../inputs/socket_listener/socket_listener_test.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/plugins/inputs/socket_listener/socket_listener_test.go b/plugins/inputs/socket_listener/socket_listener_test.go index 5b500e054f61a..7c05b39aeba67 100644 --- a/plugins/inputs/socket_listener/socket_listener_test.go +++ b/plugins/inputs/socket_listener/socket_listener_test.go @@ -269,6 +269,10 @@ func TestLargeReadBufferUnixgram(t *testing.T) { t.Skip("Skipping on Windows, as unixgram sockets are not supported") } + if runtime.GOOS == "mac" { + t.Skip("Skipping on macOS, as unixgram write buffer size cannot be changed (default 2048 bytes)") + } + var bufsize config.Size require.NoError(t, bufsize.UnmarshalText([]byte("100KiB"))) @@ -328,13 +332,7 @@ func TestLargeReadBufferUnixgram(t *testing.T) { // Write the message _, err = client.Write(message) - if err != nil { - if strings.Contains(err.Error(), "message too long") || strings.Contains(err.Error(), "no buffer space available") { - t.Skipf("No buffer space available. Skipping test.") - } else { - require.NoError(t, err) - } - } + require.NoError(t, err) client.Close() getError := func() error { From 3ef3dc8c29f71b74b865c3f441c3f41275576dee Mon Sep 17 00:00:00 2001 From: Marek Zydor Date: Wed, 13 Nov 2024 21:26:20 +0100 Subject: [PATCH 13/14] Skip on mac (darwin) --- plugins/inputs/socket_listener/socket_listener_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/inputs/socket_listener/socket_listener_test.go b/plugins/inputs/socket_listener/socket_listener_test.go index 7c05b39aeba67..f0a50916b923a 100644 --- a/plugins/inputs/socket_listener/socket_listener_test.go +++ b/plugins/inputs/socket_listener/socket_listener_test.go @@ -269,8 +269,8 @@ func TestLargeReadBufferUnixgram(t *testing.T) { t.Skip("Skipping on Windows, as unixgram sockets are not supported") } - if runtime.GOOS == "mac" { - t.Skip("Skipping on macOS, as unixgram write buffer size cannot be changed (default 2048 bytes)") + if runtime.GOOS == "darwin" { + t.Skip("Skipping on macOS (darwin), as unixgram write buffer size cannot be changed (default 2048 bytes)") } var bufsize config.Size From adfcaef3e9251711890e32892a44ca0005fc822f Mon Sep 17 00:00:00 2001 From: MarekZydor <97449538+MarekZydor@users.noreply.github.com> Date: Fri, 15 Nov 2024 23:18:04 +0100 Subject: [PATCH 14/14] Update plugins/inputs/socket_listener/socket_listener_test.go Co-authored-by: Sven Rebhan <36194019+srebhan@users.noreply.github.com> --- plugins/inputs/socket_listener/socket_listener_test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/inputs/socket_listener/socket_listener_test.go b/plugins/inputs/socket_listener/socket_listener_test.go index f0a50916b923a..d1b191c0d6f25 100644 --- a/plugins/inputs/socket_listener/socket_listener_test.go +++ b/plugins/inputs/socket_listener/socket_listener_test.go @@ -325,8 +325,7 @@ func TestLargeReadBufferUnixgram(t *testing.T) { // Check the socket write buffer size unixConn, ok := client.(*net.UnixConn) require.True(t, ok, "client is not a *net.UnixConn") - err = unixConn.SetWriteBuffer(len(message)) - if err != nil { + if err := unixConn.SetWriteBuffer(len(message)); err != nil { t.Skipf("Failed to set write buffer size: %v. Skipping test.", err) }