Skip to content

Commit

Permalink
removed e2e tests, will be added as integration tests intead
Browse files Browse the repository at this point in the history
  • Loading branch information
Edwinhr716 committed Dec 28, 2024
1 parent a856b3d commit 1faace7
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 79 deletions.
58 changes: 0 additions & 58 deletions test/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ limitations under the License.
package e2e

import (
"fmt"

"github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
appsv1 "k8s.io/api/apps/v1"
Expand Down Expand Up @@ -303,60 +301,4 @@ var _ = ginkgo.Describe("leaderWorkerSet e2e tests", func() {
return numberOfPodsInCommon, nil
}, timeout, interval).Should(gomega.Equal(0))
})
ginkgo.It("Not updated worker StatefulSet restarted during rolling update will be restored with old worker spec", func() {
lws = testing.BuildLeaderWorkerSet(ns.Name).Replica(2).Size(2).Obj()
testing.MustCreateLws(ctx, k8sClient, lws)
testing.ExpectLeaderWorkerSetAvailable(ctx, k8sClient, lws, "All replicas are ready")

testing.ExpectValidLeaderStatefulSet(ctx, k8sClient, lws, 2)
testing.UpdateWorkerTemplate(ctx, k8sClient, lws)
gomega.Expect(k8sClient.Delete(ctx, &corev1.Pod{ObjectMeta: metav1.ObjectMeta{Namespace: lws.Namespace, Name: lws.Name + "-0-1"}})).To(gomega.Succeed())
gomega.Eventually(func() error {
var sts appsv1.StatefulSet
if err := k8sClient.Get(ctx, types.NamespacedName{Name: lws.Name + "-0", Namespace: lws.Namespace}, &sts); err != nil {
return err
}
// use the original lws object instead of newest, since we are comparing with the old worker template
podTemplateSpec := *lws.Spec.LeaderWorkerTemplate.WorkerTemplate.DeepCopy()
if sts.Spec.Template.Spec.Containers[0].Name != podTemplateSpec.Spec.Containers[0].Name {
return fmt.Errorf("StatefulSet did not have the expected container name")
}
return nil
}, timeout, interval).Should(gomega.Succeed())

// Rolling update finishes
testing.ExpectValidLeaderStatefulSet(ctx, k8sClient, lws, 2)
// All worker statfulsets have the updated version
testing.ExpectValidWorkerStatefulSets(ctx, lws, k8sClient, true)
testing.ExpectValidPods(ctx, k8sClient, lws, &corev1.PodList{})
testing.ExpectLeaderWorkerSetAvailable(ctx, k8sClient, lws, "All replicas are ready")

})
ginkgo.It("Rolling update with restart policy RecreateGroupOnPodRestart only restarts the leader once", func() {
lws = testing.BuildLeaderWorkerSet(ns.Name).Replica(2).Size(2).MaxSurge(1).RestartPolicy(v1.RecreateGroupOnPodRestart).Obj()
testing.MustCreateLws(ctx, k8sClient, lws)
testing.ExpectLeaderWorkerSetAvailable(ctx, k8sClient, lws, "All replicas are ready")

initialLeaderPod := &corev1.Pod{}
testing.GetLeaderPod(ctx, lws, k8sClient, initialLeaderPod)
testing.UpdateWorkerTemplate(ctx, k8sClient, lws)

// Happens during update
testing.ExpectValidLeaderStatefulSet(ctx, k8sClient, lws, 3)
midUpdateLeaderPod := &corev1.Pod{}
testing.GetLeaderPod(ctx, lws, k8sClient, midUpdateLeaderPod)

gomega.Eventually(func() (bool, error) {
return initialLeaderPod.UID == midUpdateLeaderPod.UID, nil
}, timeout, interval).Should(gomega.Equal(false))

testing.ExpectValidLeaderStatefulSet(ctx, k8sClient, lws, 2)
testing.ExpectValidWorkerStatefulSets(ctx, lws, k8sClient, true)
finalLeaderPod := &corev1.Pod{}
testing.GetLeaderPod(ctx, lws, k8sClient, finalLeaderPod)

gomega.Eventually(func() (bool, error) {
return finalLeaderPod.UID == midUpdateLeaderPod.UID, nil
}, timeout, interval).Should(gomega.Equal(true))
})
})
21 changes: 0 additions & 21 deletions test/testutils/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,27 +215,6 @@ func GetLeaderStatefulset(ctx context.Context, lws *leaderworkerset.LeaderWorker
}, Timeout, Interval).Should(gomega.Succeed())
}

func GetLeaderPod(ctx context.Context, lws *leaderworkerset.LeaderWorkerSet, k8sClient client.Client, pod *corev1.Pod) {
gomega.Eventually(func() error {
if err := k8sClient.Get(ctx, types.NamespacedName{Name: lws.Name, Namespace: lws.Namespace}, lws); err != nil {
return err
}
leaderReplicaIndex := fmt.Sprintf("-%v", (int(*lws.Spec.Replicas) - 1))
if err := k8sClient.Get(ctx, types.NamespacedName{Name: lws.Name + leaderReplicaIndex, Namespace: lws.Namespace}, pod); err != nil {
return err
}

cr, err := revisionutils.NewRevision(ctx, k8sClient, lws, "")
if err != nil {
return err
}
if revisionutils.GetRevisionKey(cr) != revisionutils.GetRevisionKey(pod) {
return fmt.Errorf("TemplateHash does not match, expected %s, got %s", revisionutils.GetRevisionKey(cr), revisionutils.GetRevisionKey(pod))
}
return nil
}, Timeout, Interval).Should(gomega.Succeed())
}

func GetStatefulSets(ctx context.Context, lws *leaderworkerset.LeaderWorkerSet, k8sClient client.Client, stsl *appsv1.StatefulSetList) {
gomega.Eventually(func() (int, error) {
if err := k8sClient.List(ctx, stsl, client.InNamespace(lws.Namespace)); err != nil {
Expand Down

0 comments on commit 1faace7

Please sign in to comment.