mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 09:22:44 +00:00
Fix integration test read volume dir error.
This commit is contained in:
parent
08ac126336
commit
a9e7cf8e40
@ -23,6 +23,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sync"
|
"sync"
|
||||||
@ -49,6 +50,8 @@ import (
|
|||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const testRootDir = "/tmp/kubelet"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
fakeDocker1, fakeDocker2 dockertools.FakeDockerClient
|
fakeDocker1, fakeDocker2 dockertools.FakeDockerClient
|
||||||
)
|
)
|
||||||
@ -140,10 +143,11 @@ func startComponents(manifestURL string) (apiServerURL string) {
|
|||||||
controllerManager.Run(10 * time.Minute)
|
controllerManager.Run(10 * time.Minute)
|
||||||
|
|
||||||
// Kubelet (localhost)
|
// Kubelet (localhost)
|
||||||
|
os.MkdirAll(testRootDir, 0750)
|
||||||
cfg1 := config.NewPodConfig(config.PodConfigNotificationSnapshotAndUpdates)
|
cfg1 := config.NewPodConfig(config.PodConfigNotificationSnapshotAndUpdates)
|
||||||
config.NewSourceEtcd(config.EtcdKeyForHost(machineList[0]), etcdClient, cfg1.Channel("etcd"))
|
config.NewSourceEtcd(config.EtcdKeyForHost(machineList[0]), etcdClient, cfg1.Channel("etcd"))
|
||||||
config.NewSourceURL(manifestURL, 5*time.Second, cfg1.Channel("url"))
|
config.NewSourceURL(manifestURL, 5*time.Second, cfg1.Channel("url"))
|
||||||
myKubelet := kubelet.NewIntegrationTestKubelet(machineList[0], &fakeDocker1)
|
myKubelet := kubelet.NewIntegrationTestKubelet(machineList[0], testRootDir, &fakeDocker1)
|
||||||
go util.Forever(func() { myKubelet.Run(cfg1.Updates()) }, 0)
|
go util.Forever(func() { myKubelet.Run(cfg1.Updates()) }, 0)
|
||||||
go util.Forever(func() {
|
go util.Forever(func() {
|
||||||
kubelet.ListenAndServeKubeletServer(myKubelet, cfg1.Channel("http"), "localhost", 10250)
|
kubelet.ListenAndServeKubeletServer(myKubelet, cfg1.Channel("http"), "localhost", 10250)
|
||||||
@ -154,7 +158,7 @@ func startComponents(manifestURL string) (apiServerURL string) {
|
|||||||
// have a place they can schedule.
|
// have a place they can schedule.
|
||||||
cfg2 := config.NewPodConfig(config.PodConfigNotificationSnapshotAndUpdates)
|
cfg2 := config.NewPodConfig(config.PodConfigNotificationSnapshotAndUpdates)
|
||||||
config.NewSourceEtcd(config.EtcdKeyForHost(machineList[1]), etcdClient, cfg2.Channel("etcd"))
|
config.NewSourceEtcd(config.EtcdKeyForHost(machineList[1]), etcdClient, cfg2.Channel("etcd"))
|
||||||
otherKubelet := kubelet.NewIntegrationTestKubelet(machineList[1], &fakeDocker2)
|
otherKubelet := kubelet.NewIntegrationTestKubelet(machineList[1], testRootDir, &fakeDocker2)
|
||||||
go util.Forever(func() { otherKubelet.Run(cfg2.Updates()) }, 0)
|
go util.Forever(func() { otherKubelet.Run(cfg2.Updates()) }, 0)
|
||||||
go util.Forever(func() {
|
go util.Forever(func() {
|
||||||
kubelet.ListenAndServeKubeletServer(otherKubelet, cfg2.Channel("http"), "localhost", 10251)
|
kubelet.ListenAndServeKubeletServer(otherKubelet, cfg2.Channel("http"), "localhost", 10251)
|
||||||
|
@ -89,10 +89,11 @@ func NewMainKubelet(
|
|||||||
|
|
||||||
// NewIntegrationTestKubelet creates a new Kubelet for use in integration tests.
|
// NewIntegrationTestKubelet creates a new Kubelet for use in integration tests.
|
||||||
// TODO: add more integration tests, and expand parameter list as needed.
|
// TODO: add more integration tests, and expand parameter list as needed.
|
||||||
func NewIntegrationTestKubelet(hn string, dc dockertools.DockerInterface) *Kubelet {
|
func NewIntegrationTestKubelet(hn string, rd string, dc dockertools.DockerInterface) *Kubelet {
|
||||||
return &Kubelet{
|
return &Kubelet{
|
||||||
hostname: hn,
|
hostname: hn,
|
||||||
dockerClient: dc,
|
dockerClient: dc,
|
||||||
|
rootDirectory: rd,
|
||||||
dockerPuller: &dockertools.FakeDockerPuller{},
|
dockerPuller: &dockertools.FakeDockerPuller{},
|
||||||
networkContainerImage: NetworkContainerImage,
|
networkContainerImage: NetworkContainerImage,
|
||||||
resyncInterval: 3 * time.Second,
|
resyncInterval: 3 * time.Second,
|
||||||
|
Loading…
Reference in New Issue
Block a user