diff --git a/nsqadmin/http_test.go b/nsqadmin/http_test.go index de5ffc9f4..b45e22fa3 100644 --- a/nsqadmin/http_test.go +++ b/nsqadmin/http_test.go @@ -73,7 +73,7 @@ func bootstrapNSQCluster(t *testing.T) (string, []*nsqd.NSQD, []*nsqlookupd.NSQL nsqdOpts.BroadcastAddress = "127.0.0.1" nsqdOpts.NSQLookupdTCPAddresses = []string{nsqlookupd1.RealTCPAddr().String()} nsqdOpts.Logger = lgr - tmpDir, err := ioutil.TempDir("", fmt.Sprintf("nsq-test-%d", time.Now().UnixNano())) + tmpDir, err := ioutil.TempDir("", "nsq-test-") if err != nil { panic(err) } diff --git a/nsqadmin/nsqadmin_test.go b/nsqadmin/nsqadmin_test.go index e77d51ef2..8de362d60 100644 --- a/nsqadmin/nsqadmin_test.go +++ b/nsqadmin/nsqadmin_test.go @@ -9,7 +9,6 @@ import ( "os" "os/exec" "testing" - "time" "github.com/nsqio/nsq/internal/test" "github.com/nsqio/nsq/nsqd" @@ -103,7 +102,7 @@ func mustStartNSQD(opts *nsqd.Options) (*net.TCPAddr, *net.TCPAddr, *nsqd.NSQD) opts.HTTPAddress = "127.0.0.1:0" opts.HTTPSAddress = "127.0.0.1:0" if opts.DataPath == "" { - tmpDir, err := ioutil.TempDir("", fmt.Sprintf("nsq-test-%d", time.Now().UnixNano())) + tmpDir, err := ioutil.TempDir("", "nsq-test-") if err != nil { panic(err) } diff --git a/nsqd/diskqueue_test.go b/nsqd/diskqueue_test.go index f0aead160..ae4076896 100644 --- a/nsqd/diskqueue_test.go +++ b/nsqd/diskqueue_test.go @@ -20,7 +20,7 @@ func TestDiskQueue(t *testing.T) { l := test.NewTestLogger(t) dqName := "test_disk_queue" + strconv.Itoa(int(time.Now().Unix())) - tmpDir, err := ioutil.TempDir("", fmt.Sprintf("nsq-test-%d", time.Now().UnixNano())) + tmpDir, err := ioutil.TempDir("", "nsq-test-") if err != nil { panic(err) } @@ -42,7 +42,7 @@ func TestDiskQueue(t *testing.T) { func TestDiskQueueRoll(t *testing.T) { l := test.NewTestLogger(t) dqName := "test_disk_queue_roll" + strconv.Itoa(int(time.Now().Unix())) - tmpDir, err := ioutil.TempDir("", fmt.Sprintf("nsq-test-%d", time.Now().UnixNano())) + tmpDir, err := ioutil.TempDir("", "nsq-test-") if err != nil { panic(err) } @@ -73,7 +73,7 @@ func assertFileNotExist(t *testing.T, fn string) { func TestDiskQueueEmpty(t *testing.T) { l := test.NewTestLogger(t) dqName := "test_disk_queue_empty" + strconv.Itoa(int(time.Now().Unix())) - tmpDir, err := ioutil.TempDir("", fmt.Sprintf("nsq-test-%d", time.Now().UnixNano())) + tmpDir, err := ioutil.TempDir("", "nsq-test-") if err != nil { panic(err) } @@ -141,7 +141,7 @@ func TestDiskQueueEmpty(t *testing.T) { func TestDiskQueueCorruption(t *testing.T) { l := test.NewTestLogger(t) dqName := "test_disk_queue_corruption" + strconv.Itoa(int(time.Now().Unix())) - tmpDir, err := ioutil.TempDir("", fmt.Sprintf("nsq-test-%d", time.Now().UnixNano())) + tmpDir, err := ioutil.TempDir("", "nsq-test-") if err != nil { panic(err) } @@ -219,7 +219,7 @@ func readMetaDataFile(fileName string, retried int) md { func TestDiskQueueSyncAfterRead(t *testing.T) { l := test.NewTestLogger(t) dqName := "test_disk_queue_read_after_sync" + strconv.Itoa(int(time.Now().Unix())) - tmpDir, err := ioutil.TempDir("", fmt.Sprintf("nsq-test-%d", time.Now().UnixNano())) + tmpDir, err := ioutil.TempDir("", "nsq-test-") if err != nil { panic(err) } @@ -270,7 +270,7 @@ func TestDiskQueueTorture(t *testing.T) { l := test.NewTestLogger(t) dqName := "test_disk_queue_torture" + strconv.Itoa(int(time.Now().Unix())) - tmpDir, err := ioutil.TempDir("", fmt.Sprintf("nsq-test-%d", time.Now().UnixNano())) + tmpDir, err := ioutil.TempDir("", "nsq-test-") if err != nil { panic(err) } @@ -385,7 +385,7 @@ func benchmarkDiskQueuePut(size int64, b *testing.B) { b.StopTimer() l := test.NewTestLogger(b) dqName := "bench_disk_queue_put" + strconv.Itoa(b.N) + strconv.Itoa(int(time.Now().Unix())) - tmpDir, err := ioutil.TempDir("", fmt.Sprintf("nsq-test-%d", time.Now().UnixNano())) + tmpDir, err := ioutil.TempDir("", "nsq-test-") if err != nil { panic(err) } @@ -434,7 +434,7 @@ func BenchmarkDiskWrite1048576(b *testing.B) { func benchmarkDiskWrite(size int64, b *testing.B) { b.StopTimer() fileName := "bench_disk_queue_put" + strconv.Itoa(b.N) + strconv.Itoa(int(time.Now().Unix())) - tmpDir, err := ioutil.TempDir("", fmt.Sprintf("nsq-test-%d", time.Now().UnixNano())) + tmpDir, err := ioutil.TempDir("", "nsq-test-") if err != nil { panic(err) } @@ -480,7 +480,7 @@ func BenchmarkDiskWriteBuffered1048576(b *testing.B) { func benchmarkDiskWriteBuffered(size int64, b *testing.B) { b.StopTimer() fileName := "bench_disk_queue_put" + strconv.Itoa(b.N) + strconv.Itoa(int(time.Now().Unix())) - tmpDir, err := ioutil.TempDir("", fmt.Sprintf("nsq-test-%d", time.Now().UnixNano())) + tmpDir, err := ioutil.TempDir("", "nsq-test-") if err != nil { panic(err) } @@ -536,7 +536,7 @@ func benchmarkDiskQueueGet(size int64, b *testing.B) { b.StopTimer() l := test.NewTestLogger(b) dqName := "bench_disk_queue_get" + strconv.Itoa(b.N) + strconv.Itoa(int(time.Now().Unix())) - tmpDir, err := ioutil.TempDir("", fmt.Sprintf("nsq-test-%d", time.Now().UnixNano())) + tmpDir, err := ioutil.TempDir("", "nsq-test-") if err != nil { panic(err) } diff --git a/nsqd/protocol_v2_test.go b/nsqd/protocol_v2_test.go index 4db7c58ff..d4d24ebb3 100644 --- a/nsqd/protocol_v2_test.go +++ b/nsqd/protocol_v2_test.go @@ -35,7 +35,7 @@ func mustStartNSQD(opts *Options) (*net.TCPAddr, *net.TCPAddr, *NSQD) { opts.HTTPAddress = "127.0.0.1:0" opts.HTTPSAddress = "127.0.0.1:0" if opts.DataPath == "" { - tmpDir, err := ioutil.TempDir("", fmt.Sprintf("nsq-test-%d", time.Now().UnixNano())) + tmpDir, err := ioutil.TempDir("", "nsq-test-") if err != nil { panic(err) }