mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-24 11:01:26 +00:00
cleanup:e2e:stop using deprecated framework.ExpectNotEqual
This commit is contained in:
parent
9fca4ec44a
commit
a774887262
@ -178,7 +178,7 @@ var _ = SIGDescribe("Secrets", func() {
|
||||
LabelSelector: "testsecret-constant=true",
|
||||
})
|
||||
framework.ExpectNoError(err, "failed to list secrets")
|
||||
framework.ExpectNotEqual(len(secretsList.Items), 0, "no secrets found")
|
||||
gomega.Expect(secretsList.Items).ToNot(gomega.BeEmpty(), "no secrets found")
|
||||
|
||||
foundCreatedSecret := false
|
||||
var secretCreatedName string
|
||||
|
@ -138,8 +138,8 @@ var _ = SIGDescribe("Pods Extended", func() {
|
||||
})
|
||||
framework.ExpectNoError(err, "kubelet never observed the termination notice")
|
||||
|
||||
framework.ExpectNotEqual(lastPod.DeletionTimestamp, nil)
|
||||
framework.ExpectNotEqual(lastPod.Spec.TerminationGracePeriodSeconds, 0)
|
||||
gomega.Expect(lastPod.DeletionTimestamp).ToNot(gomega.BeNil())
|
||||
gomega.Expect(lastPod.Spec.TerminationGracePeriodSeconds).ToNot(gomega.BeZero())
|
||||
|
||||
selector = labels.SelectorFromSet(labels.Set(map[string]string{"time": value}))
|
||||
options = metav1.ListOptions{LabelSelector: selector.String()}
|
||||
|
@ -711,8 +711,7 @@ func verifyEvictionOrdering(ctx context.Context, f *framework.Framework, testSpe
|
||||
}
|
||||
}
|
||||
gomega.Expect(priorityPod).NotTo(gomega.BeNil())
|
||||
framework.ExpectNotEqual(priorityPod.Status.Phase, v1.PodSucceeded,
|
||||
fmt.Sprintf("pod: %s succeeded unexpectedly", priorityPod.Name))
|
||||
gomega.Expect(priorityPod.Status.Phase).ToNot(gomega.Equal(v1.PodSucceeded), "pod: %s succeeded unexpectedly", priorityPod.Name)
|
||||
|
||||
// Check eviction ordering.
|
||||
// Note: it is alright for a priority 1 and priority 2 pod (for example) to fail in the same round,
|
||||
@ -726,9 +725,8 @@ func verifyEvictionOrdering(ctx context.Context, f *framework.Framework, testSpe
|
||||
}
|
||||
gomega.Expect(lowPriorityPod).NotTo(gomega.BeNil())
|
||||
if priorityPodSpec.evictionPriority < lowPriorityPodSpec.evictionPriority && lowPriorityPod.Status.Phase == v1.PodRunning {
|
||||
framework.ExpectNotEqual(priorityPod.Status.Phase, v1.PodFailed,
|
||||
fmt.Sprintf("priority %d pod: %s failed before priority %d pod: %s",
|
||||
priorityPodSpec.evictionPriority, priorityPodSpec.pod.Name, lowPriorityPodSpec.evictionPriority, lowPriorityPodSpec.pod.Name))
|
||||
gomega.Expect(priorityPod.Status.Phase).ToNot(gomega.Equal(v1.PodFailed), "priority %d pod: %s failed before priority %d pod: %s",
|
||||
priorityPodSpec.evictionPriority, priorityPodSpec.pod.Name, lowPriorityPodSpec.evictionPriority, lowPriorityPodSpec.pod.Name)
|
||||
}
|
||||
}
|
||||
|
||||
@ -739,8 +737,7 @@ func verifyEvictionOrdering(ctx context.Context, f *framework.Framework, testSpe
|
||||
|
||||
// EvictionPriority 0 pods should not fail
|
||||
if priorityPodSpec.evictionPriority == 0 {
|
||||
framework.ExpectNotEqual(priorityPod.Status.Phase, v1.PodFailed,
|
||||
fmt.Sprintf("priority 0 pod: %s failed", priorityPod.Name))
|
||||
gomega.Expect(priorityPod.Status.Phase).ToNot(gomega.Equal(v1.PodFailed), "priority 0 pod: %s failed", priorityPod.Name)
|
||||
}
|
||||
|
||||
// If a pod that is not evictionPriority 0 has not been evicted, we are not done
|
||||
|
@ -125,7 +125,9 @@ func runPodFailingConditionsTest(f *framework.Framework, hasInitContainers, chec
|
||||
// Verify PodInitialized is set if init containers are not present (since without init containers, it gets set very early)
|
||||
initializedTime, err := getTransitionTimeForPodConditionWithStatus(p, v1.PodInitialized, true)
|
||||
framework.ExpectNoError(err)
|
||||
framework.ExpectNotEqual(initializedTime.Before(scheduledTime), true, fmt.Sprintf("pod without init containers is initialized at: %v which is before pod scheduled at: %v", initializedTime, scheduledTime))
|
||||
if initializedTime.Before(scheduledTime) {
|
||||
framework.Failf("pod without init containers is initialized at: %v which is before pod scheduled at: %v", initializedTime, scheduledTime)
|
||||
}
|
||||
}
|
||||
|
||||
// Verify ContainersReady is not set (since sandboxcreation is blocked)
|
||||
@ -165,28 +167,42 @@ func runPodReadyConditionsTest(f *framework.Framework, hasInitContainers, checkP
|
||||
|
||||
if hasInitContainers {
|
||||
// With init containers, verify the sequence of conditions is: Scheduled => PodReadyToStartContainers => Initialized
|
||||
framework.ExpectNotEqual(readyToStartContainersTime.Before(scheduledTime), true, fmt.Sprintf("pod with init containers is initialized at: %v which is before pod has ready to start at: %v", initializedTime, readyToStartContainersTime))
|
||||
framework.ExpectNotEqual(initializedTime.Before(readyToStartContainersTime), true, fmt.Sprintf("pod with init containers is initialized at: %v which is before pod has ready to start at: %v", initializedTime, readyToStartContainersTime))
|
||||
if readyToStartContainersTime.Before(scheduledTime) {
|
||||
framework.Failf("pod with init containers is initialized at: %v which is before pod has ready to start at: %v", initializedTime, readyToStartContainersTime)
|
||||
}
|
||||
if initializedTime.Before(readyToStartContainersTime) {
|
||||
framework.Failf("pod with init containers is initialized at: %v which is before pod has ready to start at: %v", initializedTime, readyToStartContainersTime)
|
||||
}
|
||||
} else {
|
||||
// Without init containers, verify the sequence of conditions is: Scheduled => Initialized => PodReadyToStartContainers
|
||||
condBeforeContainersReadyTransitionTime = readyToStartContainersTime
|
||||
errSubstrIfContainersReadyTooEarly = "ready to start"
|
||||
framework.ExpectNotEqual(initializedTime.Before(scheduledTime), true, fmt.Sprintf("pod without init containers initialized at: %v which is before pod scheduled at: %v", initializedTime, scheduledTime))
|
||||
framework.ExpectNotEqual(readyToStartContainersTime.Before(initializedTime), true, fmt.Sprintf("pod without init containers has ready to start at: %v which is before pod is initialized at: %v", readyToStartContainersTime, initializedTime))
|
||||
if initializedTime.Before(scheduledTime) {
|
||||
framework.Failf("pod without init containers initialized at: %v which is before pod scheduled at: %v", initializedTime, scheduledTime)
|
||||
}
|
||||
if readyToStartContainersTime.Before(initializedTime) {
|
||||
framework.Failf("pod without init containers has ready to start at: %v which is before pod is initialized at: %v", readyToStartContainersTime, initializedTime)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// In the absence of PodHasReadyToStartContainers feature disabled, verify the sequence is: Scheduled => Initialized
|
||||
framework.ExpectNotEqual(initializedTime.Before(scheduledTime), true, fmt.Sprintf("pod initialized at: %v which is before pod scheduled at: %v", initializedTime, scheduledTime))
|
||||
if initializedTime.Before(scheduledTime) {
|
||||
framework.Failf("pod initialized at: %v which is before pod scheduled at: %v", initializedTime, scheduledTime)
|
||||
}
|
||||
}
|
||||
// Verify the next condition to get set is ContainersReady
|
||||
containersReadyTime, err := getTransitionTimeForPodConditionWithStatus(p, v1.ContainersReady, true)
|
||||
framework.ExpectNoError(err)
|
||||
framework.ExpectNotEqual(containersReadyTime.Before(condBeforeContainersReadyTransitionTime), true, fmt.Sprintf("containers ready at: %v which is before pod %s: %v", containersReadyTime, errSubstrIfContainersReadyTooEarly, initializedTime))
|
||||
if containersReadyTime.Before(condBeforeContainersReadyTransitionTime) {
|
||||
framework.Failf("containers ready at: %v which is before pod %s: %v", containersReadyTime, errSubstrIfContainersReadyTooEarly, initializedTime)
|
||||
}
|
||||
|
||||
// Verify ContainersReady => PodReady
|
||||
podReadyTime, err := getTransitionTimeForPodConditionWithStatus(p, v1.PodReady, true)
|
||||
framework.ExpectNoError(err)
|
||||
framework.ExpectNotEqual(podReadyTime.Before(containersReadyTime), true, fmt.Sprintf("pod ready at: %v which is before pod containers ready at: %v", podReadyTime, containersReadyTime))
|
||||
if podReadyTime.Before(containersReadyTime) {
|
||||
framework.Failf("pod ready at: %v which is before pod containers ready at: %v", podReadyTime, containersReadyTime)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -359,7 +359,7 @@ func findKubeletServiceName(running bool) string {
|
||||
framework.ExpectNoError(err)
|
||||
regex := regexp.MustCompile("(kubelet-\\w+)")
|
||||
matches := regex.FindStringSubmatch(string(stdout))
|
||||
framework.ExpectNotEqual(len(matches), 0, "Found more than one kubelet service running: %q", stdout)
|
||||
gomega.Expect(matches).ToNot(gomega.BeEmpty(), "Found more than one kubelet service running: %q", stdout)
|
||||
kubeletServiceName := matches[0]
|
||||
framework.Logf("Get running kubelet with systemctl: %v, %v", string(stdout), kubeletServiceName)
|
||||
return kubeletServiceName
|
||||
|
Loading…
Reference in New Issue
Block a user