Upgrade test framework to talk to containerd sock.
Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
parent
62e6921145
commit
a9d846af23
@ -31,7 +31,10 @@ test_setup ${REPORT_DIR}
|
|||||||
# Run integration test.
|
# Run integration test.
|
||||||
# Set STANDALONE_CRI_CONTAINERD so that integration test can see it.
|
# Set STANDALONE_CRI_CONTAINERD so that integration test can see it.
|
||||||
# Some integration test needs the env to skip itself.
|
# 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_exit_code=$?
|
||||||
|
|
||||||
test_teardown
|
test_teardown
|
||||||
|
@ -25,6 +25,9 @@ RESTART_WAIT_PERIOD=${RESTART_WAIT_PERIOD:-10}
|
|||||||
STANDALONE_CRI_CONTAINERD=${STANDALONE_CRI_CONTAINERD:-true}
|
STANDALONE_CRI_CONTAINERD=${STANDALONE_CRI_CONTAINERD:-true}
|
||||||
|
|
||||||
CRICONTAINERD_SOCK=/var/run/cri-containerd.sock
|
CRICONTAINERD_SOCK=/var/run/cri-containerd.sock
|
||||||
|
if ! ${STANDALONE_CRI_CONTAINERD}; then
|
||||||
|
CRICONTAINERD_SOCK=/var/run/containerd/containerd.sock
|
||||||
|
fi
|
||||||
|
|
||||||
cri_containerd_pid=
|
cri_containerd_pid=
|
||||||
containerd_pid=
|
containerd_pid=
|
||||||
|
@ -34,7 +34,7 @@ import (
|
|||||||
// NOTE(random-liu): Current restart test only support standalone cri-containerd mode.
|
// NOTE(random-liu): Current restart test only support standalone cri-containerd mode.
|
||||||
|
|
||||||
func TestSandboxAcrossCRIContainerdRestart(t *testing.T) {
|
func TestSandboxAcrossCRIContainerdRestart(t *testing.T) {
|
||||||
if os.Getenv(standaloneEnvKey) == "false" {
|
if !*standaloneCRIContainerd {
|
||||||
t.Skip("Skip because cri-containerd does not run in standalone mode")
|
t.Skip("Skip because cri-containerd does not run in standalone mode")
|
||||||
}
|
}
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
@ -153,7 +153,7 @@ func TestSandboxAcrossCRIContainerdRestart(t *testing.T) {
|
|||||||
// teardown the network properly.
|
// teardown the network properly.
|
||||||
// This test uses host network sandbox to avoid resource leakage.
|
// This test uses host network sandbox to avoid resource leakage.
|
||||||
func TestSandboxDeletionAcrossCRIContainerdRestart(t *testing.T) {
|
func TestSandboxDeletionAcrossCRIContainerdRestart(t *testing.T) {
|
||||||
if os.Getenv(standaloneEnvKey) == "false" {
|
if !*standaloneCRIContainerd {
|
||||||
t.Skip("Skip because cri-containerd does not run in standalone mode")
|
t.Skip("Skip because cri-containerd does not run in standalone mode")
|
||||||
}
|
}
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
@ -18,6 +18,7 @@ package integration
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"time"
|
"time"
|
||||||
@ -34,14 +35,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
sock = "/var/run/cri-containerd.sock"
|
timeout = 1 * time.Minute
|
||||||
timeout = 1 * time.Minute
|
pauseImage = "gcr.io/google_containers/pause:3.0" // This is the same with default sandbox image.
|
||||||
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.
|
||||||
k8sNamespace = "k8s.io" // This is the same with server.k8sContainerdNamespace.
|
containerdEndpoint = "/run/containerd/containerd.sock"
|
||||||
containerdEndpoint = "/run/containerd/containerd.sock"
|
criContainerdRoot = "/var/lib/cri-containerd"
|
||||||
criContainerdEndpoint = "/var/run/cri-containerd.sock"
|
|
||||||
criContainerdRoot = "/var/lib/cri-containerd"
|
|
||||||
standaloneEnvKey = "STANDALONE_CRI_CONTAINERD"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -51,7 +49,11 @@ var (
|
|||||||
criContainerdClient api.CRIContainerdServiceClient
|
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() {
|
func init() {
|
||||||
|
flag.Parse()
|
||||||
if err := ConnectDaemons(); err != nil {
|
if err := ConnectDaemons(); err != nil {
|
||||||
logrus.WithError(err).Fatalf("Failed to connect daemons")
|
logrus.WithError(err).Fatalf("Failed to connect daemons")
|
||||||
}
|
}
|
||||||
@ -60,11 +62,11 @@ func init() {
|
|||||||
// ConnectDaemons connect cri-containerd and containerd, and initialize the clients.
|
// ConnectDaemons connect cri-containerd and containerd, and initialize the clients.
|
||||||
func ConnectDaemons() error {
|
func ConnectDaemons() error {
|
||||||
var err error
|
var err error
|
||||||
runtimeService, err = remote.NewRemoteRuntimeService(sock, timeout)
|
runtimeService, err = remote.NewRemoteRuntimeService(*criContainerdEndpoint, timeout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create runtime service: %v", err)
|
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 {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create image service: %v", err)
|
return fmt.Errorf("failed to create image service: %v", err)
|
||||||
}
|
}
|
||||||
@ -83,7 +85,7 @@ func ConnectDaemons() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to connect containerd: %v", err)
|
return fmt.Errorf("failed to connect containerd: %v", err)
|
||||||
}
|
}
|
||||||
criContainerdClient, err = client.NewCRIContainerdClient(criContainerdEndpoint, timeout)
|
criContainerdClient, err = client.NewCRIContainerdClient(*criContainerdEndpoint, timeout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to connect cri-containerd: %v", err)
|
return fmt.Errorf("failed to connect cri-containerd: %v", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user