Upgrade test framework to talk to containerd sock.

Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
Lantao Liu 2018-01-18 03:27:28 +00:00
parent 62e6921145
commit a9d846af23
4 changed files with 22 additions and 14 deletions

View File

@ -31,7 +31,10 @@ test_setup ${REPORT_DIR}
# Run integration test.
# Set STANDALONE_CRI_CONTAINERD so that integration test can see it.
# Some integration test needs the env to skip itself.
sudo STANDALONE_CRI_CONTAINERD=${STANDALONE_CRI_CONTAINERD} ${ROOT}/_output/integration.test --test.run="${FOCUS}" --test.v
sudo ${ROOT}/_output/integration.test --test.run="${FOCUS}" --test.v \
--standalone-cri-containerd=${STANDALONE_CRI_CONTAINERD} \
--cri-containerd-endpoint=${CRICONTAINERD_SOCK}
test_exit_code=$?
test_teardown

View File

@ -25,6 +25,9 @@ RESTART_WAIT_PERIOD=${RESTART_WAIT_PERIOD:-10}
STANDALONE_CRI_CONTAINERD=${STANDALONE_CRI_CONTAINERD:-true}
CRICONTAINERD_SOCK=/var/run/cri-containerd.sock
if ! ${STANDALONE_CRI_CONTAINERD}; then
CRICONTAINERD_SOCK=/var/run/containerd/containerd.sock
fi
cri_containerd_pid=
containerd_pid=

View File

@ -34,7 +34,7 @@ import (
// NOTE(random-liu): Current restart test only support standalone cri-containerd mode.
func TestSandboxAcrossCRIContainerdRestart(t *testing.T) {
if os.Getenv(standaloneEnvKey) == "false" {
if !*standaloneCRIContainerd {
t.Skip("Skip because cri-containerd does not run in standalone mode")
}
ctx := context.Background()
@ -153,7 +153,7 @@ func TestSandboxAcrossCRIContainerdRestart(t *testing.T) {
// teardown the network properly.
// This test uses host network sandbox to avoid resource leakage.
func TestSandboxDeletionAcrossCRIContainerdRestart(t *testing.T) {
if os.Getenv(standaloneEnvKey) == "false" {
if !*standaloneCRIContainerd {
t.Skip("Skip because cri-containerd does not run in standalone mode")
}
ctx := context.Background()

View File

@ -18,6 +18,7 @@ package integration
import (
"errors"
"flag"
"fmt"
"os/exec"
"time"
@ -34,14 +35,11 @@ import (
)
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"
criContainerdEndpoint = "/var/run/cri-containerd.sock"
criContainerdRoot = "/var/lib/cri-containerd"
standaloneEnvKey = "STANDALONE_CRI_CONTAINERD"
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"
criContainerdRoot = "/var/lib/cri-containerd"
)
var (
@ -51,7 +49,11 @@ var (
criContainerdClient api.CRIContainerdServiceClient
)
var standaloneCRIContainerd = flag.Bool("standalone-cri-containerd", true, "Whether cri-containerd is running in standalone mode.")
var criContainerdEndpoint = flag.String("cri-containerd-endpoint", "/var/run/cri-containerd.sock", "The endpoint of cri-containerd.")
func init() {
flag.Parse()
if err := ConnectDaemons(); err != nil {
logrus.WithError(err).Fatalf("Failed to connect daemons")
}
@ -60,11 +62,11 @@ func init() {
// ConnectDaemons connect cri-containerd and containerd, and initialize the clients.
func ConnectDaemons() error {
var err error
runtimeService, err = remote.NewRemoteRuntimeService(sock, timeout)
runtimeService, err = remote.NewRemoteRuntimeService(*criContainerdEndpoint, timeout)
if err != nil {
return fmt.Errorf("failed to create runtime service: %v", err)
}
imageService, err = remote.NewRemoteImageService(sock, timeout)
imageService, err = remote.NewRemoteImageService(*criContainerdEndpoint, timeout)
if err != nil {
return fmt.Errorf("failed to create image service: %v", err)
}
@ -83,7 +85,7 @@ func ConnectDaemons() error {
if err != nil {
return fmt.Errorf("failed to connect containerd: %v", err)
}
criContainerdClient, err = client.NewCRIContainerdClient(criContainerdEndpoint, timeout)
criContainerdClient, err = client.NewCRIContainerdClient(*criContainerdEndpoint, timeout)
if err != nil {
return fmt.Errorf("failed to connect cri-containerd: %v", err)
}