Signed-off-by: John Howard <jhoward@microsoft.com>
| ... | ... |
@@ -191,7 +191,7 @@ func (s *DockerSuite) TestContainerApiStartVolumeBinds(c *check.C) {
|
| 191 | 191 |
c.Assert(err, check.IsNil) |
| 192 | 192 |
c.Assert(status, check.Equals, http.StatusCreated) |
| 193 | 193 |
|
| 194 |
- bindPath := randomUnixTmpDirPath("test")
|
|
| 194 |
+ bindPath := randomTmpDirPath("test")
|
|
| 195 | 195 |
config = map[string]interface{}{
|
| 196 | 196 |
"Binds": []string{bindPath + ":/tmp"},
|
| 197 | 197 |
} |
| ... | ... |
@@ -222,8 +222,8 @@ func (s *DockerSuite) TestContainerApiStartDupVolumeBinds(c *check.C) {
|
| 222 | 222 |
c.Assert(err, check.IsNil) |
| 223 | 223 |
c.Assert(status, check.Equals, http.StatusCreated) |
| 224 | 224 |
|
| 225 |
- bindPath1 := randomUnixTmpDirPath("test1")
|
|
| 226 |
- bindPath2 := randomUnixTmpDirPath("test2")
|
|
| 225 |
+ bindPath1 := randomTmpDirPath("test1")
|
|
| 226 |
+ bindPath2 := randomTmpDirPath("test2")
|
|
| 227 | 227 |
|
| 228 | 228 |
config = map[string]interface{}{
|
| 229 | 229 |
"Binds": []string{bindPath1 + ":/tmp", bindPath2 + ":/tmp"},
|
| ... | ... |
@@ -322,8 +322,8 @@ func (s *DockerSuite) TestRunNoDupVolumes(c *check.C) {
|
| 322 | 322 |
// TODO Windows: This test cannot run on a Windows daemon as Windows does |
| 323 | 323 |
// not support volumes |
| 324 | 324 |
testRequires(c, DaemonIsLinux) |
| 325 |
- mountstr1 := randomUnixTmpDirPath("test1") + ":/someplace"
|
|
| 326 |
- mountstr2 := randomUnixTmpDirPath("test2") + ":/someplace"
|
|
| 325 |
+ mountstr1 := randomTmpDirPath("test1") + ":/someplace"
|
|
| 326 |
+ mountstr2 := randomTmpDirPath("test2") + ":/someplace"
|
|
| 327 | 327 |
|
| 328 | 328 |
if out, _, err := dockerCmdWithError("run", "-v", mountstr1, "-v", mountstr2, "busybox", "true"); err == nil {
|
| 329 | 329 |
c.Fatal("Expected error about duplicate volume definitions")
|
| ... | ... |
@@ -2015,7 +2015,7 @@ func (s *DockerSuite) TestVolumesNoCopyData(c *check.C) {
|
| 2015 | 2015 |
c.Fatalf("Data was copied on volumes-from but shouldn't be:\n%q", out)
|
| 2016 | 2016 |
} |
| 2017 | 2017 |
|
| 2018 |
- tmpDir := randomUnixTmpDirPath("docker_test_bind_mount_copy_data")
|
|
| 2018 |
+ tmpDir := randomTmpDirPath("docker_test_bind_mount_copy_data")
|
|
| 2019 | 2019 |
if out, _, err := dockerCmdWithError("run", "-v", tmpDir+":/foo", "dataimage", "ls", "-lh", "/foo/bar"); err == nil || !strings.Contains(out, "No such file or directory") {
|
| 2020 | 2020 |
c.Fatalf("Data was copied on bind-mount but shouldn't be:\n%q", out)
|
| 2021 | 2021 |
} |
| ... | ... |
@@ -61,8 +61,8 @@ func listTar(f io.Reader) ([]string, error) {
|
| 61 | 61 |
return integration.ListTar(f) |
| 62 | 62 |
} |
| 63 | 63 |
|
| 64 |
-func randomUnixTmpDirPath(s string) string {
|
|
| 65 |
- return integration.RandomUnixTmpDirPath(s) |
|
| 64 |
+func randomTmpDirPath(s string) string {
|
|
| 65 |
+ return integration.RandomTmpDirPath(s) |
|
| 66 | 66 |
} |
| 67 | 67 |
|
| 68 | 68 |
func consumeWithSpeed(reader io.Reader, chunkSize int, interval time.Duration, stop chan bool) (n int, err error) {
|
| ... | ... |
@@ -9,8 +9,9 @@ import ( |
| 9 | 9 |
"io" |
| 10 | 10 |
"os" |
| 11 | 11 |
"os/exec" |
| 12 |
- "path" |
|
| 12 |
+ "path/filepath" |
|
| 13 | 13 |
"reflect" |
| 14 |
+ "runtime" |
|
| 14 | 15 |
"strings" |
| 15 | 16 |
"syscall" |
| 16 | 17 |
"time" |
| ... | ... |
@@ -244,10 +245,14 @@ func ListTar(f io.Reader) ([]string, error) {
|
| 244 | 244 |
} |
| 245 | 245 |
} |
| 246 | 246 |
|
| 247 |
-// RandomUnixTmpDirPath provides a temporary unix path with rand string appended. |
|
| 247 |
+// RandomTmpDirPath provides a temporary path with rand string appended. |
|
| 248 | 248 |
// does not create or checks if it exists. |
| 249 |
-func RandomUnixTmpDirPath(s string) string {
|
|
| 250 |
- return path.Join("/tmp", fmt.Sprintf("%s.%s", s, stringutils.GenerateRandomAlphaOnlyString(10)))
|
|
| 249 |
+func RandomTmpDirPath(s string) string {
|
|
| 250 |
+ tmp := "/tmp" |
|
| 251 |
+ if runtime.GOOS == "windows" {
|
|
| 252 |
+ tmp = os.Getenv("TEMP")
|
|
| 253 |
+ } |
|
| 254 |
+ return filepath.Join(tmp, fmt.Sprintf("%s.%s", s, stringutils.GenerateRandomAlphaOnlyString(10)))
|
|
| 251 | 255 |
} |
| 252 | 256 |
|
| 253 | 257 |
// ConsumeWithSpeed reads chunkSize bytes from reader after every interval. |
| ... | ... |
@@ -6,6 +6,7 @@ import ( |
| 6 | 6 |
"os" |
| 7 | 7 |
"os/exec" |
| 8 | 8 |
"path" |
| 9 |
+ "runtime" |
|
| 9 | 10 |
"strings" |
| 10 | 11 |
"testing" |
| 11 | 12 |
"time" |
| ... | ... |
@@ -341,10 +342,13 @@ func TestListTar(t *testing.T) {
|
| 341 | 341 |
} |
| 342 | 342 |
} |
| 343 | 343 |
|
| 344 |
-func TestRandomUnixTmpDirPath(t *testing.T) {
|
|
| 345 |
- path := RandomUnixTmpDirPath("something")
|
|
| 344 |
+func TestRandomTmpDirPath(t *testing.T) {
|
|
| 345 |
+ path := RandomTmpDirPath("something")
|
|
| 346 | 346 |
|
| 347 | 347 |
prefix := "/tmp/something" |
| 348 |
+ if runtime.GOOS == "windows" {
|
|
| 349 |
+ prefix = os.Getenv("TEMP") + `\something`
|
|
| 350 |
+ } |
|
| 348 | 351 |
expectedSize := len(prefix) + 11 |
| 349 | 352 |
|
| 350 | 353 |
if !strings.HasPrefix(path, prefix) {
|