tests: Refactors container image usage

Currently, the cri-integration tests do not work on Windows due to various reasons.
One of the reasons is because all the tests are using Linux-specific images. This
commit refactors the image pulling / usage in the cri-integration tests, making it
easier to update, and easier to configure the a custom registry to pull those images
from.

For Windows runs, custom registries can be created, which will also contain Windows
images, and the cri-integration tests can be configured to use those registries by
specifying the "--image-list" argument, a TOML file which will contain an alternative
mapping of the default images.

Signed-off-by: Claudiu Belu <cbelu@cloudbasesolutions.com>
This commit is contained in:
Claudiu Belu
2021-02-16 12:45:45 +00:00
parent b0fb8a5a04
commit 5847340a7d
17 changed files with 139 additions and 31 deletions

View File

@@ -49,13 +49,11 @@ import (
const (
timeout = 1 * time.Minute
pauseImage = "k8s.gcr.io/pause:3.5" // This is the same with default sandbox image.
k8sNamespace = constants.K8sContainerdNamespace
)
var (
runtimeService cri.RuntimeService
imageService cri.ImageManagerService
containerdClient *containerd.Client
containerdEndpoint string
)
@@ -64,9 +62,11 @@ var criEndpoint = flag.String("cri-endpoint", "unix:///run/containerd/containerd
var criRoot = flag.String("cri-root", "/var/lib/containerd/io.containerd.grpc.v1.cri", "The root directory of cri plugin.")
var runtimeHandler = flag.String("runtime-handler", "", "The runtime handler to use in the test.")
var containerdBin = flag.String("containerd-bin", "containerd", "The containerd binary name. The name is used to restart containerd during test.")
var imageListFile = flag.String("image-list", "", "The TOML file containing the non-default images to be used in tests.")
func TestMain(m *testing.M) {
flag.Parse()
initImages(*imageListFile)
if err := ConnectDaemons(); err != nil {
logrus.WithError(err).Fatalf("Failed to connect daemons")
}