Use random name for test sockets to avoid intermittent failure

This commit is contained in:
Daniel Nelson
2018-06-03 19:43:06 -07:00
parent a04cfee349
commit df1fe7a2b4
7 changed files with 106 additions and 34 deletions

View File

@@ -2,8 +2,10 @@ package syslog
import (
"fmt"
"io/ioutil"
"net"
"os"
"path/filepath"
"sync/atomic"
"testing"
"time"
@@ -274,15 +276,21 @@ func TestStrict_udp(t *testing.T) {
}
func TestBestEffort_unixgram(t *testing.T) {
sockname := "/tmp/telegraf_test.sock"
os.Create(sockname)
testRFC5426(t, "unixgram", sockname, true)
tmpdir, err := ioutil.TempDir("", "telegraf")
require.NoError(t, err)
defer os.RemoveAll(tmpdir)
sock := filepath.Join(tmpdir, "syslog.TestBestEffort_unixgram.sock")
os.Create(sock)
testRFC5426(t, "unixgram", sock, true)
}
func TestStrict_unixgram(t *testing.T) {
sockname := "/tmp/telegraf_test.sock"
os.Create(sockname)
testRFC5426(t, "unixgram", sockname, false)
tmpdir, err := ioutil.TempDir("", "telegraf")
require.NoError(t, err)
defer os.RemoveAll(tmpdir)
sock := filepath.Join(tmpdir, "syslog.TestStrict_unixgram.sock")
os.Create(sock)
testRFC5426(t, "unixgram", sock, false)
}
func TestTimeIncrement_udp(t *testing.T) {