Add integration test for image load
Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
@@ -26,21 +26,25 @@ import (
|
||||
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
|
||||
"k8s.io/kubernetes/pkg/kubelet/remote"
|
||||
|
||||
api "github.com/kubernetes-incubator/cri-containerd/pkg/api/v1"
|
||||
"github.com/kubernetes-incubator/cri-containerd/pkg/client"
|
||||
"github.com/kubernetes-incubator/cri-containerd/pkg/util"
|
||||
)
|
||||
|
||||
const (
|
||||
sock = "/var/run/cri-containerd.sock"
|
||||
timeout = 1 * time.Minute
|
||||
pauseImage = "gcr.io/google_containers/pause:3.0" // This is the same with default sandbox image.
|
||||
k8sNamespace = "k8s.io" // This is the same with server.k8sContainerdNamespace.
|
||||
containerdEndpoint = "/run/containerd/containerd.sock"
|
||||
sock = "/var/run/cri-containerd.sock"
|
||||
timeout = 1 * time.Minute
|
||||
pauseImage = "gcr.io/google_containers/pause:3.0" // This is the same with default sandbox image.
|
||||
k8sNamespace = "k8s.io" // This is the same with server.k8sContainerdNamespace.
|
||||
containerdEndpoint = "/run/containerd/containerd.sock"
|
||||
criContainerdEndpoint = "/var/run/cri-containerd.sock"
|
||||
)
|
||||
|
||||
var (
|
||||
runtimeService cri.RuntimeService
|
||||
imageService cri.ImageManagerService
|
||||
containerdClient *containerd.Client
|
||||
runtimeService cri.RuntimeService
|
||||
imageService cri.ImageManagerService
|
||||
containerdClient *containerd.Client
|
||||
criContainerdClient api.CRIContainerdServiceClient
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -57,6 +61,10 @@ func init() {
|
||||
if err != nil {
|
||||
glog.Exitf("Failed to connect containerd: %v", err)
|
||||
}
|
||||
criContainerdClient, err = client.NewCRIContainerdClient(criContainerdEndpoint, timeout)
|
||||
if err != nil {
|
||||
glog.Exitf("Failed to connect cri-containerd: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Opts sets specific information in pod sandbox config.
|
||||
@@ -70,7 +78,7 @@ func PodSandboxConfig(name, ns string, opts ...PodSandboxOpts) *runtime.PodSandb
|
||||
// Using random id as uuid is good enough for local
|
||||
// integration test.
|
||||
Uid: util.GenerateID(),
|
||||
Namespace: ns,
|
||||
Namespace: Randomize(ns),
|
||||
},
|
||||
Linux: &runtime.LinuxPodSandboxConfig{},
|
||||
}
|
||||
@@ -106,6 +114,14 @@ func WithResources(r *runtime.LinuxContainerResources) ContainerOpts {
|
||||
}
|
||||
}
|
||||
|
||||
// Add container command.
|
||||
func WithCommand(c string, args ...string) ContainerOpts {
|
||||
return func(cf *runtime.ContainerConfig) {
|
||||
cf.Command = []string{c}
|
||||
cf.Args = args
|
||||
}
|
||||
}
|
||||
|
||||
// ContainerConfig creates a container config given a name and image name
|
||||
// and additional container config options
|
||||
func ContainerConfig(name, image string, opts ...ContainerOpts) *runtime.ContainerConfig {
|
||||
@@ -143,3 +159,8 @@ func Eventually(f CheckFunc, period, timeout time.Duration) error {
|
||||
time.Sleep(period)
|
||||
}
|
||||
}
|
||||
|
||||
// Randomize adds uuid after a string.
|
||||
func Randomize(str string) string {
|
||||
return str + "-" + util.GenerateID()
|
||||
}
|
||||
|
Reference in New Issue
Block a user