@@ -19,6 +19,10 @@ import (
19
19
20
20
var string_to_1024_chars = "saljdflajsdssdfsdfljkfkajafjajlköflkjöjaklgljksdjlakljkflkjweljklkwjejlkfekljwlkjefjklwjklsdajkljklwerlkaskldgjksakjekjwrjkljasdjkgfkljwejklrkjlklasdkjlsadjlfjlkadfljkajklsdfjklslkdfjkllkjasdjkflsdlakfjklasldfkjlasdjfkjlsadlfjklaljsafjlslkjawjklerkjljklasjkdfjklwerjljalsdjkflwerjlkwejlkarjklalkklfsdjlfhkjsdfkhsewhkjjasdjfkhwkejrkjahjefkhkasdjhfkashfkjwehfkksadfjaskfkhjdshjfhewkjhasdfjdajskfjwehkfajkankaskjdfasdjhfkkjhjjkasdfjhkjahksdf"
21
21
22
+ func init () {
23
+ syslog .DefaultSendInterval = 100 * time .Millisecond // Modify behavior for tests
24
+ }
25
+
22
26
var _ = Describe ("HTTPS_batch" , func () {
23
27
var (
24
28
netConf syslog.NetworkTimeoutConfig
@@ -86,21 +90,33 @@ var _ = Describe("HTTPS_batch", func() {
86
90
env1 := buildLogEnvelope ("APP" , "1" , "string to get log to 1024 characters:" + string_to_1024_chars , loggregator_v2 .Log_OUT )
87
91
for i := 0 ; i < 10 ; i ++ {
88
92
Expect (writer .Write (env1 )).To (Succeed ())
89
- time .Sleep (99 * time .Millisecond )
93
+ time .Sleep (5 * time .Millisecond )
90
94
}
91
95
Expect (drain .getMessagesSize ()).Should (Equal (0 ))
92
96
time .Sleep (100 * time .Millisecond )
93
97
Expect (drain .getMessagesSize ()).Should (Equal (10 ))
94
98
})
95
99
96
- It ("probabilistic test for race condition " , func () {
100
+ It ("test dispatching for batches before timewindow is finished " , func () {
97
101
env1 := buildLogEnvelope ("APP" , "1" , "string to get log to 1024 characters:" + string_to_1024_chars , loggregator_v2 .Log_OUT )
98
- for i := 0 ; i < 10 ; i ++ {
102
+ for i := 0 ; i < 300 ; i ++ {
99
103
Expect (writer .Write (env1 )).To (Succeed ())
100
- time .Sleep (99 * time .Millisecond )
101
104
}
102
- time .Sleep (100 * time .Millisecond )
103
- Expect (drain .getMessagesSize ()).Should (Equal (10 ))
105
+ Expect (drain .getMessagesSize ()).Should (Equal (256 ))
106
+ time .Sleep (101 * time .Millisecond )
107
+ Expect (drain .getMessagesSize ()).Should (Equal (300 ))
108
+ })
109
+
110
+ It ("test for hanging after some ticks" , func () {
111
+ // This test will not succeed on the timer based implementation,
112
+ // it works fine with a ticker based implementation.
113
+ env1 := buildLogEnvelope ("APP" , "1" , "only a short test message" , loggregator_v2 .Log_OUT )
114
+ for i := 0 ; i < 5 ; i ++ {
115
+ Expect (writer .Write (env1 )).To (Succeed ())
116
+ time .Sleep (300 * time .Millisecond )
117
+ }
118
+ time .Sleep (101 * time .Millisecond )
119
+ Expect (drain .getMessagesSize ()).Should (Equal (5 ))
104
120
})
105
121
})
106
122
0 commit comments