Skip to content

Commit

Permalink
Add nolint to async send method again
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklas-dohrn committed Dec 29, 2024
1 parent b73bec2 commit 6a6a850
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
6 changes: 4 additions & 2 deletions src/pkg/egress/syslog/https_batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (

const BATCHSIZE = 256 * 1024

var DefaultSendInterval = 1 * time.Second

type HTTPSBatchWriter struct {
HTTPSWriter
msgs chan []byte
Expand Down Expand Up @@ -40,7 +42,7 @@ func NewHTTPSBatchWriter(
syslogConverter: c,
},
batchSize: BATCHSIZE,
sendInterval: 1 * time.Second,
sendInterval: DefaultSendInterval,
egrMsgCount: 0,
msgs: make(chan []byte),
}
Expand Down Expand Up @@ -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
}
Expand Down
16 changes: 10 additions & 6 deletions src/pkg/egress/syslog/https_batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
})
})

Expand Down

0 comments on commit 6a6a850

Please sign in to comment.