Add integration tests for StatefulSetStartOrdinal feature (#115466)

* Add integration tests for StatefulSetStartOrdinal feature

* Move expensive test setup (apiserver and running controller) to be run once in StatefulSetStartOrdinal parameterized tests
This commit is contained in:
pwschuurman
2023-02-03 05:26:29 -08:00
committed by GitHub
parent 7a55b76f28
commit 7bf175d5a2
2 changed files with 107 additions and 3 deletions

View File

@@ -199,9 +199,8 @@ func createHeadlessService(t *testing.T, clientSet clientset.Interface, headless
}
}
func createSTSsPods(t *testing.T, clientSet clientset.Interface, stss []*appsv1.StatefulSet, pods []*v1.Pod) ([]*appsv1.StatefulSet, []*v1.Pod) {
func createSTSs(t *testing.T, clientSet clientset.Interface, stss []*appsv1.StatefulSet) []*appsv1.StatefulSet {
var createdSTSs []*appsv1.StatefulSet
var createdPods []*v1.Pod
for _, sts := range stss {
createdSTS, err := clientSet.AppsV1().StatefulSets(sts.Namespace).Create(context.TODO(), sts, metav1.CreateOptions{})
if err != nil {
@@ -209,6 +208,11 @@ func createSTSsPods(t *testing.T, clientSet clientset.Interface, stss []*appsv1.
}
createdSTSs = append(createdSTSs, createdSTS)
}
return createdSTSs
}
func createPods(t *testing.T, clientSet clientset.Interface, pods []*v1.Pod) []*v1.Pod {
var createdPods []*v1.Pod
for _, pod := range pods {
createdPod, err := clientSet.CoreV1().Pods(pod.Namespace).Create(context.TODO(), pod, metav1.CreateOptions{})
if err != nil {
@@ -217,7 +221,11 @@ func createSTSsPods(t *testing.T, clientSet clientset.Interface, stss []*appsv1.
createdPods = append(createdPods, createdPod)
}
return createdSTSs, createdPods
return createdPods
}
func createSTSsPods(t *testing.T, clientSet clientset.Interface, stss []*appsv1.StatefulSet, pods []*v1.Pod) ([]*appsv1.StatefulSet, []*v1.Pod) {
return createSTSs(t, clientSet, stss), createPods(t, clientSet, pods)
}
// Verify .Status.Replicas is equal to .Spec.Replicas