From 6a6a850efad56772902cfcde57d6b4c251b4ac85 Mon Sep 17 00:00:00 2001 From: nicklas dohrn Date: Tue, 17 Dec 2024 18:42:26 +0100 Subject: [PATCH] Add nolint to async send method again --- src/pkg/egress/syslog/https_batch.go | 6 ++++-- src/pkg/egress/syslog/https_batch_test.go | 16 ++++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/pkg/egress/syslog/https_batch.go b/src/pkg/egress/syslog/https_batch.go index d3d2288f5..2cf264027 100644 --- a/src/pkg/egress/syslog/https_batch.go +++ b/src/pkg/egress/syslog/https_batch.go @@ -13,6 +13,8 @@ import ( const BATCHSIZE = 256 * 1024 +var DefaultSendInterval = 1 * time.Second + type HTTPSBatchWriter struct { HTTPSWriter msgs chan []byte @@ -40,7 +42,7 @@ func NewHTTPSBatchWriter( syslogConverter: c, }, batchSize: BATCHSIZE, - sendInterval: 1 * time.Second, + sendInterval: DefaultSendInterval, egrMsgCount: 0, msgs: make(chan []byte), } @@ -74,7 +76,7 @@ func (w *HTTPSBatchWriter) startSender() { sendBatch := func() { if msgBatch.Len() > 0 { - w.sendHttpRequest(msgBatch.Bytes(), msgCount) + w.sendHttpRequest(msgBatch.Bytes(), msgCount) //nolint:errcheck msgBatch.Reset() msgCount = 0 } diff --git a/src/pkg/egress/syslog/https_batch_test.go b/src/pkg/egress/syslog/https_batch_test.go index 35789bcb6..b16bfc32e 100644 --- a/src/pkg/egress/syslog/https_batch_test.go +++ b/src/pkg/egress/syslog/https_batch_test.go @@ -19,6 +19,10 @@ import ( var string_to_1024_chars = "saljdflajsdssdfsdfljkfkajafjajlköflkjöjaklgljksdjlakljkflkjweljklkwjejlkfekljwlkjefjklwjklsdajkljklwerlkaskldgjksakjekjwrjkljasdjkgfkljwejklrkjlklasdkjlsadjlfjlkadfljkajklsdfjklslkdfjkllkjasdjkflsdlakfjklasldfkjlasdjfkjlsadlfjklaljsafjlslkjawjklerkjljklasjkdfjklwerjljalsdjkflwerjlkwejlkarjklalkklfsdjlfhkjsdfkhsewhkjjasdjfkhwkejrkjahjefkhkasdjhfkashfkjwehfkksadfjaskfkhjdshjfhewkjhasdfjdajskfjwehkfajkankaskjdfasdjhfkkjhjjkasdfjhkjahksdf" +func init() { + syslog.DefaultSendInterval = 100 * time.Millisecond // Modify behavior for tests +} + var _ = Describe("HTTPS_batch", func() { var ( netConf syslog.NetworkTimeoutConfig @@ -86,21 +90,21 @@ var _ = Describe("HTTPS_batch", func() { env1 := buildLogEnvelope("APP", "1", "string to get log to 1024 characters:"+string_to_1024_chars, loggregator_v2.Log_OUT) for i := 0; i < 10; i++ { Expect(writer.Write(env1)).To(Succeed()) - time.Sleep(99 * time.Millisecond) + time.Sleep(5 * time.Millisecond) } Expect(drain.getMessagesSize()).Should(Equal(0)) time.Sleep(100 * time.Millisecond) Expect(drain.getMessagesSize()).Should(Equal(10)) }) - It("probabilistic test for race condition", func() { + It("test for hanging after some ticks", func() { env1 := buildLogEnvelope("APP", "1", "string to get log to 1024 characters:"+string_to_1024_chars, loggregator_v2.Log_OUT) - for i := 0; i < 10; i++ { + for i := 0; i < 5; i++ { Expect(writer.Write(env1)).To(Succeed()) - time.Sleep(99 * time.Millisecond) + time.Sleep(300 * time.Millisecond) } - time.Sleep(100 * time.Millisecond) - Expect(drain.getMessagesSize()).Should(Equal(10)) + time.Sleep(101 * time.Millisecond) + Expect(drain.getMessagesSize()).Should(Equal(5)) }) })