Skip to content

Commit

Permalink
fix e2e
Browse files Browse the repository at this point in the history
Signed-off-by: 守辰 <shouchen.zz@alibaba-inc.com>
  • Loading branch information
furykerry committed Mar 15, 2024
1 parent c33088b commit c29d601
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 19 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/docker-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name: Docker Image CI
on:
workflow_dispatch:

# Declare default permissions as read only.
permissions: read-all

jobs:

build:
Expand Down
30 changes: 15 additions & 15 deletions test/e2e/apps/ephemeraljob.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,21 +288,6 @@ var _ = SIGDescribe("EphemeralJob", func() {
},
}})

job2 := tester.CreateTestEphemeralJob(randStr+"2", 1, 1, metav1.LabelSelector{
MatchLabels: map[string]string{
"run": "nginx",
}}, []v1.EphemeralContainer{
{
TargetContainerName: "nginx",
EphemeralContainerCommon: v1.EphemeralContainerCommon{
Name: "debugger",
Image: BusyboxImage,
ImagePullPolicy: v1.PullIfNotPresent,
Command: []string{"sleep", "3000"},
TerminationMessagePolicy: v1.TerminationMessageReadFile,
},
}})

ginkgo.By("Check the status of job")

gomega.Eventually(func() int {
Expand All @@ -320,6 +305,21 @@ var _ = SIGDescribe("EphemeralJob", func() {
return len(targetPod.Status.EphemeralContainerStatuses)
}, 60*time.Second, 3*time.Second).Should(gomega.Equal(1))

job2 := tester.CreateTestEphemeralJob(randStr+"2", 1, 1, metav1.LabelSelector{
MatchLabels: map[string]string{
"run": "nginx",
}}, []v1.EphemeralContainer{
{
TargetContainerName: "nginx",
EphemeralContainerCommon: v1.EphemeralContainerCommon{
Name: "debugger",
Image: BusyboxImage,
ImagePullPolicy: v1.PullIfNotPresent,
Command: []string{"sleep", "3000"},
TerminationMessagePolicy: v1.TerminationMessageReadFile,
},
}})
ginkgo.By("Check whether ephemeral container can updated (not possible yet)")
gomega.Eventually(func() int32 {
job, _ := tester.GetEphemeralJob(job2.Name)
return job.Status.Matches
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/apps/imagelistpulljobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,12 @@ var _ = SIGDescribe("PullImages", func() {
return job.Status.Desired
}, 3*time.Second, time.Second).Should(gomega.Equal(int32(len(job.Spec.Images))))

ginkgo.By("Wait completed in 180s")
ginkgo.By("Wait completed in 360s")
gomega.Eventually(func() bool {
job, err = testerForImageListPullJob.GetJob(job)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
return job.Status.CompletionTime != nil
}, 180*time.Second, 3*time.Second).Should(gomega.Equal(true))
}, 360*time.Second, 10*time.Second).Should(gomega.Equal(true))
gomega.Expect(job.Status.Succeeded).To(gomega.Equal(int32(len(job.Spec.Images))))

ginkgo.By("Delete job")
Expand Down
5 changes: 3 additions & 2 deletions test/e2e/apps/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ var _ = SIGDescribe("StatefulSet", func() {
gomega.Expect(err).NotTo(gomega.HaveOccurred())

ginkgo.By("InPlace update Pods at the new revision")
sst.WaitForPodNotReady(ss, pods.Items[0].Name)
sst.WaitForPodUpdatedAndRunning(ss, pods.Items[0].Name, currentRevision)
sst.WaitForRunningAndReady(3, ss)
ss = sst.GetStatefulSet(ss.Namespace, ss.Name)
pods = sst.GetPodList(ss)
Expand Down Expand Up @@ -761,8 +761,9 @@ var _ = SIGDescribe("StatefulSet", func() {
gomega.Expect(err).NotTo(gomega.HaveOccurred())

ginkgo.By("InPlace update Pods at the new revision")
sst.WaitForPodNotReady(ss, pods.Items[0].Name)
sst.WaitForPodUpdatedAndRunning(ss, pods.Items[0].Name, currentRevision)
sst.WaitForRunningAndReady(3, ss)

ss = sst.GetStatefulSet(ss.Namespace, ss.Name)
pods = sst.GetPodList(ss)
for i := range pods.Items {
Expand Down
22 changes: 22 additions & 0 deletions test/e2e/framework/statefulset_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,28 @@ func (s *StatefulSetTester) WaitForPodNotReady(set *appsv1beta1.StatefulSet, pod

}

// WaitForPodNotReady waist for the Pod named podName in set to exist and to not have a Ready condition.
func (s *StatefulSetTester) WaitForPodUpdatedAndRunning(set *appsv1beta1.StatefulSet, podName string, currentRevision string) (*appsv1beta1.StatefulSet, *v1.PodList) {
var pods *v1.PodList
s.WaitForState(set, func(set2 *appsv1beta1.StatefulSet, pods2 *v1.PodList) (bool, error) {
set = set2
pods = pods2
for i := range pods.Items {
if pods.Items[i].Name != podName {
continue
}

if pods.Items[i].Labels[apps.StatefulSetRevisionLabel] != currentRevision &&
podutil.IsPodReady(&pods.Items[i]) {
return true, nil
}
return false, nil
}
return false, nil
})
return set, pods
}

// WaitForRollingUpdate waits for all Pods in set to exist and have the correct revision and for the RollingUpdate to
// complete. set must have a RollingUpdateStatefulSetStrategyType.
func (s *StatefulSetTester) WaitForRollingUpdate(set *appsv1beta1.StatefulSet) (*appsv1beta1.StatefulSet, *v1.PodList) {
Expand Down

0 comments on commit c29d601

Please sign in to comment.