XL/fs: Initialize export paths supplied on command line (#2020)

Fixes #2013
This commit is contained in:
Harshavardhana
2016-06-29 03:13:44 -07:00
committed by Anand Babu (AB) Periasamy
parent 8e8f6f90a4
commit 0e3907072c
6 changed files with 101 additions and 4 deletions
+28
View File
@@ -30,7 +30,9 @@ import (
"os"
"regexp"
"sort"
"strconv"
"strings"
"sync"
"testing"
"time"
"unicode/utf8"
@@ -61,6 +63,32 @@ const (
letterIdxMax = 63 / letterIdxBits // # of letter indices fitting in 63 bits
)
// Random number state.
// We generate random temporary file names so that there's a good
// chance the file doesn't exist yet.
var randN uint32
var randmu sync.Mutex
// reseed - returns a new seed everytime the function is called.
func reseed() uint32 {
return uint32(time.Now().UnixNano() + int64(os.Getpid()))
}
// nextSuffix - provides a new unique suffix everytime the function is called.
func nextSuffix() string {
randmu.Lock()
r := randN
// Initial seed required, generate one.
if r == 0 {
r = reseed()
}
// constants from Numerical Recipes
r = r*1664525 + 1013904223
randN = r
randmu.Unlock()
return strconv.Itoa(int(1e9 + r%1e9))[1:]
}
// TestServer encapsulates an instantiation of a Minio instance with a temporary backend.
// Example usage:
// s := StartTestServer(t,"XL")