Skip to content

Commit

Permalink
Update: Test avoiding race conditions for RFC5426 (syslog input plugin)
Browse files Browse the repository at this point in the history
  • Loading branch information
leodido committed May 25, 2018
1 parent 716da76 commit 625d18b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion plugins/inputs/syslog/rfc5425_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ func getTestCasesForRFC5425() []testCase5425 {

func newTCPSyslogReceiver(address string, keepAlive *internal.Duration, maxConn int, bestEffort bool) *Syslog {
d := &internal.Duration{
Duration: 50 * time.Millisecond,
Duration: defaultReadTimeout,
}
s := &Syslog{
Address: address,
Expand Down
8 changes: 5 additions & 3 deletions plugins/inputs/syslog/rfc5426_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"net"
"os"
"sync/atomic"
"testing"
"time"

Expand Down Expand Up @@ -285,9 +286,10 @@ func TestStrict_unixgram(t *testing.T) {
}

func TestTimeIncrement_udp(t *testing.T) {
i := 0
var i int64
atomic.StoreInt64(&i, 0)
getNow := func() time.Time {
if i%2 == 0 {
if atomic.LoadInt64(&i)%2 == 0 {
return time.Unix(1, 0)
}
return time.Unix(1, 1)
Expand Down Expand Up @@ -336,7 +338,7 @@ func TestTimeIncrement_udp(t *testing.T) {
}

// New one with different time
i++
atomic.StoreInt64(&i, atomic.LoadInt64(&i)+1)

// Clear
acc.ClearMetrics()
Expand Down

0 comments on commit 625d18b

Please sign in to comment.