e2e_node: clean up non-recommended import
This commit is contained in:
@@ -26,8 +26,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/onsi/ginkgo"
|
||||
"github.com/onsi/gomega"
|
||||
"k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/uuid"
|
||||
@@ -47,11 +47,11 @@ const (
|
||||
var _ = SIGDescribe("Dockershim [Serial] [Disruptive] [Feature:Docker][Legacy:Docker]", func() {
|
||||
f := framework.NewDefaultFramework("dockerhism-checkpoint-test")
|
||||
|
||||
BeforeEach(func() {
|
||||
ginkgo.BeforeEach(func() {
|
||||
framework.RunIfContainerRuntimeIs("docker")
|
||||
})
|
||||
|
||||
It("should clean up pod sandbox checkpoint after pod deletion", func() {
|
||||
ginkgo.It("should clean up pod sandbox checkpoint after pod deletion", func() {
|
||||
podName := "pod-checkpoint-no-disrupt"
|
||||
runPodCheckpointTest(f, podName, func() {
|
||||
checkpoints := findCheckpoints(podName)
|
||||
@@ -61,33 +61,33 @@ var _ = SIGDescribe("Dockershim [Serial] [Disruptive] [Feature:Docker][Legacy:Do
|
||||
})
|
||||
})
|
||||
|
||||
It("should remove dangling checkpoint file", func() {
|
||||
ginkgo.It("should remove dangling checkpoint file", func() {
|
||||
filename := fmt.Sprintf("%x", md5.Sum([]byte(fmt.Sprintf("%s/%s", testCheckpoint, f.Namespace.Name))))
|
||||
fullpath := path.Join(framework.TestContext.DockershimCheckpointDir, filename)
|
||||
|
||||
By(fmt.Sprintf("Write a file at %q", fullpath))
|
||||
ginkgo.By(fmt.Sprintf("Write a file at %q", fullpath))
|
||||
err := writeFileAndSync(fullpath, []byte(testCheckpointContent))
|
||||
framework.ExpectNoError(err, "Failed to create file %q", fullpath)
|
||||
|
||||
By("Check if file is removed")
|
||||
Eventually(func() bool {
|
||||
ginkgo.By("Check if file is removed")
|
||||
gomega.Eventually(func() bool {
|
||||
if _, err := os.Stat(fullpath); os.IsNotExist(err) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}, gcTimeout, 10*time.Second).Should(BeTrue())
|
||||
}, gcTimeout, 10*time.Second).Should(gomega.BeTrue())
|
||||
|
||||
})
|
||||
|
||||
Context("When pod sandbox checkpoint is missing", func() {
|
||||
It("should complete pod sandbox clean up", func() {
|
||||
ginkgo.Context("When pod sandbox checkpoint is missing", func() {
|
||||
ginkgo.It("should complete pod sandbox clean up", func() {
|
||||
podName := "pod-checkpoint-missing"
|
||||
runPodCheckpointTest(f, podName, func() {
|
||||
checkpoints := findCheckpoints(podName)
|
||||
if len(checkpoints) == 0 {
|
||||
e2elog.Failf("No checkpoint for the pod was found")
|
||||
}
|
||||
By("Removing checkpoint of test pod")
|
||||
ginkgo.By("Removing checkpoint of test pod")
|
||||
for _, filename := range checkpoints {
|
||||
if len(filename) == 0 {
|
||||
continue
|
||||
@@ -100,10 +100,10 @@ var _ = SIGDescribe("Dockershim [Serial] [Disruptive] [Feature:Docker][Legacy:Do
|
||||
})
|
||||
})
|
||||
|
||||
Context("When all containers in pod are missing", func() {
|
||||
It("should complete pod sandbox clean up based on the information in sandbox checkpoint", func() {
|
||||
ginkgo.Context("When all containers in pod are missing", func() {
|
||||
ginkgo.It("should complete pod sandbox clean up based on the information in sandbox checkpoint", func() {
|
||||
runPodCheckpointTest(f, "pod-containers-missing", func() {
|
||||
By("Gathering pod container ids")
|
||||
ginkgo.By("Gathering pod container ids")
|
||||
stdout, err := exec.Command("sudo", "docker", "ps", "-q", "-f",
|
||||
fmt.Sprintf("name=%s", f.Namespace.Name)).CombinedOutput()
|
||||
framework.ExpectNoError(err, "Failed to run docker ps: %v", err)
|
||||
@@ -116,7 +116,7 @@ var _ = SIGDescribe("Dockershim [Serial] [Disruptive] [Feature:Docker][Legacy:Do
|
||||
}
|
||||
}
|
||||
|
||||
By("Stop and remove pod containers")
|
||||
ginkgo.By("Stop and remove pod containers")
|
||||
dockerStopCmd := append([]string{"docker", "stop"}, ids...)
|
||||
_, err = exec.Command("sudo", dockerStopCmd...).CombinedOutput()
|
||||
framework.ExpectNoError(err, "Failed to run command %v: %v", dockerStopCmd, err)
|
||||
@@ -127,11 +127,11 @@ var _ = SIGDescribe("Dockershim [Serial] [Disruptive] [Feature:Docker][Legacy:Do
|
||||
})
|
||||
})
|
||||
|
||||
Context("When checkpoint file is corrupted", func() {
|
||||
It("should complete pod sandbox clean up", func() {
|
||||
ginkgo.Context("When checkpoint file is corrupted", func() {
|
||||
ginkgo.It("should complete pod sandbox clean up", func() {
|
||||
podName := "pod-checkpoint-corrupted"
|
||||
runPodCheckpointTest(f, podName, func() {
|
||||
By("Corrupt checkpoint file")
|
||||
ginkgo.By("Corrupt checkpoint file")
|
||||
checkpoints := findCheckpoints(podName)
|
||||
if len(checkpoints) == 0 {
|
||||
e2elog.Failf("No checkpoint for the pod was found")
|
||||
@@ -151,7 +151,7 @@ var _ = SIGDescribe("Dockershim [Serial] [Disruptive] [Feature:Docker][Legacy:Do
|
||||
|
||||
func runPodCheckpointTest(f *framework.Framework, podName string, twist func()) {
|
||||
podName = podName + string(uuid.NewUUID())
|
||||
By(fmt.Sprintf("Creating test pod: %s", podName))
|
||||
ginkgo.By(fmt.Sprintf("Creating test pod: %s", podName))
|
||||
f.PodClient().CreateSync(&v1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: podName},
|
||||
Spec: v1.PodSpec{
|
||||
@@ -164,13 +164,13 @@ func runPodCheckpointTest(f *framework.Framework, podName string, twist func())
|
||||
},
|
||||
})
|
||||
|
||||
By("Performing disruptive operations")
|
||||
ginkgo.By("Performing disruptive operations")
|
||||
twist()
|
||||
|
||||
By("Remove test pod")
|
||||
ginkgo.By("Remove test pod")
|
||||
f.PodClient().DeleteSync(podName, &metav1.DeleteOptions{}, framework.DefaultPodDeletionTimeout)
|
||||
|
||||
By("Waiting for checkpoint to be removed")
|
||||
ginkgo.By("Waiting for checkpoint to be removed")
|
||||
if err := wait.PollImmediate(10*time.Second, gcTimeout, func() (bool, error) {
|
||||
checkpoints := findCheckpoints(podName)
|
||||
if len(checkpoints) == 0 {
|
||||
@@ -209,7 +209,7 @@ func writeFileAndSync(path string, data []byte) error {
|
||||
|
||||
// findCheckpoints returns all checkpoint files containing input string
|
||||
func findCheckpoints(match string) []string {
|
||||
By(fmt.Sprintf("Search checkpoints containing %q", match))
|
||||
ginkgo.By(fmt.Sprintf("Search checkpoints containing %q", match))
|
||||
checkpoints := []string{}
|
||||
stdout, err := exec.Command("sudo", "grep", "-rl", match, framework.TestContext.DockershimCheckpointDir).CombinedOutput()
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user