mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 02:41:25 +00:00
StatefulSet minReadySeconds e2e
This commit is contained in:
parent
99c35dc37c
commit
cf9510751d
@ -1124,6 +1124,22 @@ var _ = SIGDescribe("StatefulSet", func() {
|
||||
appTester.run()
|
||||
})
|
||||
})
|
||||
// Make sure minReadySeconds is honored
|
||||
// Don't mark it as conformance yet
|
||||
ginkgo.It("MinReadySeconds should be honored when enabled [Feature:StatefulSetMinReadySeconds] [alpha]", func() {
|
||||
ssName := "test-ss"
|
||||
headlessSvcName := "test"
|
||||
// Define StatefulSet Labels
|
||||
ssPodLabels := map[string]string{
|
||||
"name": "sample-pod",
|
||||
"pod": WebserverImageName,
|
||||
}
|
||||
ss := e2estatefulset.NewStatefulSet(ssName, ns, headlessSvcName, 1, nil, nil, ssPodLabels)
|
||||
setHTTPProbe(ss)
|
||||
ss, err := c.AppsV1().StatefulSets(ns).Create(context.TODO(), ss, metav1.CreateOptions{})
|
||||
framework.ExpectNoError(err)
|
||||
e2estatefulset.WaitForStatusAvailableReplicas(c, ss, 1)
|
||||
})
|
||||
})
|
||||
|
||||
func kubectlExecWithRetries(ns string, args ...string) (out string) {
|
||||
|
@ -121,6 +121,31 @@ func WaitForStatusReadyReplicas(c clientset.Interface, ss *appsv1.StatefulSet, e
|
||||
}
|
||||
}
|
||||
|
||||
// WaitForStatusAvailableReplicas waits for the ss.Status.Available to be equal to expectedReplicas
|
||||
func WaitForStatusAvailableReplicas(c clientset.Interface, ss *appsv1.StatefulSet, expectedReplicas int32) {
|
||||
framework.Logf("Waiting for statefulset status.AvailableReplicas updated to %d", expectedReplicas)
|
||||
|
||||
ns, name := ss.Namespace, ss.Name
|
||||
pollErr := wait.PollImmediate(StatefulSetPoll, StatefulSetTimeout,
|
||||
func() (bool, error) {
|
||||
ssGet, err := c.AppsV1().StatefulSets(ns).Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if ssGet.Status.ObservedGeneration < ss.Generation {
|
||||
return false, nil
|
||||
}
|
||||
if ssGet.Status.AvailableReplicas != expectedReplicas {
|
||||
framework.Logf("Waiting for stateful set status.AvailableReplicas to become %d, currently %d", expectedReplicas, ssGet.Status.ReadyReplicas)
|
||||
return false, nil
|
||||
}
|
||||
return true, nil
|
||||
})
|
||||
if pollErr != nil {
|
||||
framework.Failf("Failed waiting for stateful set status.AvailableReplicas updated to %d: %v", expectedReplicas, pollErr)
|
||||
}
|
||||
}
|
||||
|
||||
// WaitForStatusReplicas waits for the ss.Status.Replicas to be equal to expectedReplicas
|
||||
func WaitForStatusReplicas(c clientset.Interface, ss *appsv1.StatefulSet, expectedReplicas int32) {
|
||||
framework.Logf("Waiting for statefulset status.replicas updated to %d", expectedReplicas)
|
||||
|
Loading…
Reference in New Issue
Block a user