diff --git a/cmd/integration/integration.go b/cmd/integration/integration.go index 97ca7731c56..7a2da6477cd 100644 --- a/cmd/integration/integration.go +++ b/cmd/integration/integration.go @@ -64,8 +64,8 @@ import ( _ "k8s.io/kubernetes/plugin/pkg/scheduler/algorithmprovider" "k8s.io/kubernetes/plugin/pkg/scheduler/factory" e2e "k8s.io/kubernetes/test/e2e/framework" - "k8s.io/kubernetes/test/integration" "k8s.io/kubernetes/test/integration/framework" + testutils "k8s.io/kubernetes/test/utils" etcd "github.com/coreos/etcd/client" "github.com/golang/glog" @@ -210,8 +210,8 @@ func startComponents(firstManifestURL, secondManifestURL string) (string, string cadvisorInterface := new(cadvisortest.Fake) // Kubelet (localhost) - testRootDir := integration.MakeTempDirOrDie("kubelet_integ_1.", "") - configFilePath := integration.MakeTempDirOrDie("config", testRootDir) + testRootDir := testutils.MakeTempDirOrDie("kubelet_integ_1.", "") + configFilePath := testutils.MakeTempDirOrDie("config", testRootDir) glog.Infof("Using %s as root dir for kubelet #1", testRootDir) cm := cm.NewStubContainerManager() kcfg := kubeletapp.SimpleKubelet( @@ -245,7 +245,7 @@ func startComponents(firstManifestURL, secondManifestURL string) (string, string // Kubelet (machine) // Create a second kubelet so that the guestbook example's two redis slaves both // have a place they can schedule. - testRootDir = integration.MakeTempDirOrDie("kubelet_integ_2.", "") + testRootDir = testutils.MakeTempDirOrDie("kubelet_integ_2.", "") glog.Infof("Using %s as root dir for kubelet #2", testRootDir) kcfg = kubeletapp.SimpleKubelet( diff --git a/pkg/kubemark/hollow_kubelet.go b/pkg/kubemark/hollow_kubelet.go index 0c0f08d1645..c08869b6eef 100644 --- a/pkg/kubemark/hollow_kubelet.go +++ b/pkg/kubemark/hollow_kubelet.go @@ -27,7 +27,7 @@ import ( containertest "k8s.io/kubernetes/pkg/kubelet/container/testing" "k8s.io/kubernetes/pkg/kubelet/dockertools" "k8s.io/kubernetes/pkg/volume/empty_dir" - "k8s.io/kubernetes/test/integration" + "k8s.io/kubernetes/test/utils" "github.com/golang/glog" ) @@ -45,8 +45,8 @@ func NewHollowKubelet( containerManager cm.ContainerManager, maxPods int, podsPerCore int, ) *HollowKubelet { - testRootDir := integration.MakeTempDirOrDie("hollow-kubelet.", "") - manifestFilePath := integration.MakeTempDirOrDie("manifest", testRootDir) + testRootDir := utils.MakeTempDirOrDie("hollow-kubelet.", "") + manifestFilePath := utils.MakeTempDirOrDie("manifest", testRootDir) glog.Infof("Using %s as root dir for hollow-kubelet", testRootDir) return &HollowKubelet{ diff --git a/test/integration/utils.go b/test/integration/utils.go index 9c3391368d7..290cc8a94c0 100644 --- a/test/integration/utils.go +++ b/test/integration/utils.go @@ -18,9 +18,7 @@ package integration import ( "fmt" - "io/ioutil" "math/rand" - "os" "testing" etcd "github.com/coreos/etcd/client" @@ -67,20 +65,6 @@ func deleteAllEtcdKeys() { } -func MakeTempDirOrDie(prefix string, baseDir string) string { - if baseDir == "" { - baseDir = "/tmp" - } - tempDir, err := ioutil.TempDir(baseDir, prefix) - if err != nil { - glog.Fatalf("Can't make a temp rootdir: %v", err) - } - if err = os.MkdirAll(tempDir, 0750); err != nil { - glog.Fatalf("Can't mkdir(%q): %v", tempDir, err) - } - return tempDir -} - func deletePodOrErrorf(t *testing.T, c *client.Client, ns, name string) { if err := c.Pods(ns).Delete(name, nil); err != nil { t.Errorf("unable to delete pod %v: %v", name, err) diff --git a/test/utils/tmpdir.go b/test/utils/tmpdir.go new file mode 100644 index 00000000000..e8cc23d4ce9 --- /dev/null +++ b/test/utils/tmpdir.go @@ -0,0 +1,38 @@ +/* +Copyright 2016 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package utils + +import ( + "io/ioutil" + "os" + + "github.com/golang/glog" +) + +func MakeTempDirOrDie(prefix string, baseDir string) string { + if baseDir == "" { + baseDir = "/tmp" + } + tempDir, err := ioutil.TempDir(baseDir, prefix) + if err != nil { + glog.Fatalf("Can't make a temp rootdir: %v", err) + } + if err = os.MkdirAll(tempDir, 0750); err != nil { + glog.Fatalf("Can't mkdir(%q): %v", tempDir, err) + } + return tempDir +}