Skip to content

Commit

Permalink
tests: ioutil.TempDir() adds a pseudo-random suffix
Browse files Browse the repository at this point in the history
no need to add our own pseudo-random "unique" suffix
  • Loading branch information
ploxiln committed Jan 9, 2017
1 parent b715e6e commit d5955b2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion nsqadmin/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
3 changes: 1 addition & 2 deletions nsqadmin/nsqadmin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"os"
"os/exec"
"testing"
"time"

"github.com/nsqio/nsq/internal/test"
"github.com/nsqio/nsq/nsqd"
Expand Down Expand Up @@ -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)
}
Expand Down
20 changes: 10 additions & 10 deletions nsqd/diskqueue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion nsqd/protocol_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit d5955b2

Please sign in to comment.