Skip to content
2 changes: 1 addition & 1 deletion test/e2e/anp-domain/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ var _ = framework.SerialDescribe("[group:admin-network-policy]", func() {
}

testNetworkConnectivity := func(target string, shouldSucceed bool, description string) {
testNetworkConnectivityWithRetry(target, shouldSucceed, description, 20, 2*time.Second)
testNetworkConnectivityWithRetry(target, shouldSucceed, description, 20, time.Second)
}

framework.ConformanceIt("should create ANP with domainName deny rule and verify connectivity behavior", func() {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/cnp-domain/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ var _ = framework.SerialDescribe("[group:cluster-network-policy]", func() {
dnsClient := f.DNSNameResolverClient()
labelSelector := fmt.Sprintf("anp=%s", name)

framework.WaitUntil(2*time.Second, 30*time.Second, func(_ context.Context) (bool, error) {
framework.WaitUntil(time.Second, 30*time.Second, func(_ context.Context) (bool, error) {
resolverList := dnsClient.ListByLabel(labelSelector)
if len(resolverList.Items) < expectedCount {
framework.Logf("Found %d/%d DNSNameResolver(s) for CNP %s", len(resolverList.Items), expectedCount, name)
Expand Down
14 changes: 7 additions & 7 deletions test/e2e/connectivity/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ var _ = framework.OrderedDescribe("[group:disaster]", func() {

ginkgo.By("Waiting for newly created ovs-ovn pod running on node " + suiteCtx.Node)
pod = nil
framework.WaitUntil(2*time.Second, 2*time.Minute, func(_ context.Context) (bool, error) {
framework.WaitUntil(time.Second, 2*time.Minute, func(_ context.Context) (bool, error) {
ds = dsClient.Get("ovs-ovn")
pods, err = dsClient.GetPods(ds)
if err != nil {
Expand Down Expand Up @@ -329,8 +329,8 @@ var _ = framework.OrderedDescribe("[group:disaster]", func() {
framework.ExpectNoError(err, "failed to send STOP signal to ovn sb process: %v, %s", err, string(stderr))
}

ginkgo.By("Waiting 60s")
time.Sleep(60 * time.Second)
ginkgo.By("Waiting 5s for process outage simulation")
time.Sleep(5 * time.Second)

for _, pod := range pods.Items {
ginkgo.By("Getting ovn sb pid of pod " + pod.Name + " running on " + pod.Spec.NodeName)
Expand Down Expand Up @@ -380,8 +380,8 @@ var _ = framework.OrderedDescribe("[group:disaster]", func() {
_, stderr, err = framework.KubectlExec(pod.Namespace, pod.Name, cmd...)
framework.ExpectNoError(err, "failed to send STOP signal to ovn-controller process: %v, %s", err, string(stderr))

ginkgo.By("Waiting 60s")
time.Sleep(60 * time.Second)
ginkgo.By("Waiting 5s for process outage simulation")
time.Sleep(5 * time.Second)

ginkgo.By("Continuing the stopped ovn-controller process by sending a CONT signal")
cmd = []string{"sh", "-c", fmt.Sprintf(`"kill -CONT %s"`, pid)}
Expand Down Expand Up @@ -422,8 +422,8 @@ var _ = framework.OrderedDescribe("[group:disaster]", func() {
_, stderr, err = framework.KubectlExec(pod.Namespace, pod.Name, cmd...)
framework.ExpectNoError(err, "failed to send STOP signal to ovs-vswitchd process: %v, %s", err, string(stderr))

ginkgo.By("Waiting 60s")
time.Sleep(60 * time.Second)
ginkgo.By("Waiting 5s for process outage simulation")
time.Sleep(5 * time.Second)

ginkgo.By("Continuing the stopped ovs-vswitchd process by sending a CONT signal")
cmd = []string{"sh", "-c", fmt.Sprintf(`"kill -CONT %s"`, pid)}
Expand Down
36 changes: 23 additions & 13 deletions test/e2e/framework/daemonset.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"errors"
"fmt"
"strings"
"time"

appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
Expand All @@ -17,6 +16,7 @@ import (
"k8s.io/apimachinery/pkg/util/wait"
clientset "k8s.io/client-go/kubernetes"
v1apps "k8s.io/client-go/kubernetes/typed/apps/v1"
"k8s.io/client-go/util/retry"
"k8s.io/kubectl/pkg/polymorphichelpers"

"github.com/onsi/ginkgo/v2"
Expand Down Expand Up @@ -100,7 +100,7 @@ func (c *DaemonSetClient) Patch(daemonset *appsv1.DaemonSet) *appsv1.DaemonSet {
}
ExpectNoError(err)
var patchedDaemonSet *appsv1.DaemonSet
err = wait.PollUntilContextTimeout(context.Background(), 2*time.Second, timeout, true, func(ctx context.Context) (bool, error) {
err = wait.PollUntilContextTimeout(context.Background(), poll, timeout, true, func(ctx context.Context) (bool, error) {
daemonSet, err := c.DaemonSetInterface.Patch(ctx, daemonset.Name, types.MergePatchType, modifiedBytes, metav1.PatchOptions{}, "")
if err != nil {
return handleWaitingAPIError(err, false, "patch daemonset %s/%s", daemonset.Namespace, daemonset.Name)
Expand Down Expand Up @@ -130,7 +130,7 @@ func (c *DaemonSetClient) RolloutStatus(name string) *appsv1.DaemonSet {
ginkgo.GinkgoHelper()

var daemonSet *appsv1.DaemonSet
WaitUntil(2*time.Second, timeout, func(_ context.Context) (bool, error) {
WaitUntil(poll, timeout, func(_ context.Context) (bool, error) {
var err error
daemonSet = c.Get(name)
unstructured := &unstructured.Unstructured{}
Expand Down Expand Up @@ -158,21 +158,31 @@ func (c *DaemonSetClient) RolloutStatus(name string) *appsv1.DaemonSet {
func (c *DaemonSetClient) Restart(ds *appsv1.DaemonSet) *appsv1.DaemonSet {
ginkgo.GinkgoHelper()

buf, err := polymorphichelpers.ObjectRestarterFn(ds)
ExpectNoError(err)
var result *appsv1.DaemonSet
err := retry.RetryOnConflict(retry.DefaultBackoff, func() error {
latest := c.Get(ds.Name)

m := make(map[string]any)
err = json.Unmarshal(buf, &m)
ExpectNoError(err)
buf, err := polymorphichelpers.ObjectRestarterFn(latest)
if err != nil {
return err
}

ds = new(appsv1.DaemonSet)
err = runtime.DefaultUnstructuredConverter.FromUnstructured(m, ds)
ExpectNoError(err)
m := make(map[string]any)
if err = json.Unmarshal(buf, &m); err != nil {
return err
}

d := new(appsv1.DaemonSet)
if err = runtime.DefaultUnstructuredConverter.FromUnstructured(m, d); err != nil {
return err
}

ds, err = c.Update(context.TODO(), ds, metav1.UpdateOptions{})
result, err = c.Update(context.TODO(), d, metav1.UpdateOptions{})
return err
})
ExpectNoError(err)

return ds.DeepCopy()
return result.DeepCopy()
}

// RestartSync restarts the DaemonSet and wait it to be ready
Expand Down
40 changes: 26 additions & 14 deletions test/e2e/framework/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"k8s.io/apimachinery/pkg/util/wait"
clientset "k8s.io/client-go/kubernetes"
v1apps "k8s.io/client-go/kubernetes/typed/apps/v1"
"k8s.io/client-go/util/retry"
"k8s.io/kubectl/pkg/polymorphichelpers"
"k8s.io/kubernetes/test/e2e/framework"
"k8s.io/kubernetes/test/e2e/framework/deployment"
Expand Down Expand Up @@ -98,7 +99,7 @@ func (c *DeploymentClient) RolloutStatus(name string) *appsv1.Deployment {
ginkgo.GinkgoHelper()

var deploy *appsv1.Deployment
WaitUntil(2*time.Second, timeout, func(_ context.Context) (bool, error) {
WaitUntil(poll, timeout, func(_ context.Context) (bool, error) {
var err error
deploy = c.Get(name)
unstructured := &unstructured.Unstructured{}
Expand Down Expand Up @@ -129,7 +130,7 @@ func (c *DeploymentClient) Patch(original, modified *appsv1.Deployment) *appsv1.
ExpectNoError(err)

var patchedDeploy *appsv1.Deployment
err = wait.PollUntilContextTimeout(context.Background(), 2*time.Second, timeout, true, func(ctx context.Context) (bool, error) {
err = wait.PollUntilContextTimeout(context.Background(), poll, timeout, true, func(ctx context.Context) (bool, error) {
deploy, err := c.DeploymentInterface.Patch(ctx, original.Name, types.StrategicMergePatchType, patch, metav1.PatchOptions{}, "")
if err != nil {
return handleWaitingAPIError(err, false, "patch deployment %s/%s", original.Namespace, original.Name)
Expand Down Expand Up @@ -159,21 +160,31 @@ func (c *DeploymentClient) PatchSync(original, modified *appsv1.Deployment) *app
func (c *DeploymentClient) Restart(deploy *appsv1.Deployment) *appsv1.Deployment {
ginkgo.GinkgoHelper()

buf, err := polymorphichelpers.ObjectRestarterFn(deploy)
ExpectNoError(err)
var result *appsv1.Deployment
err := retry.RetryOnConflict(retry.DefaultBackoff, func() error {
latest := c.Get(deploy.Name)

m := make(map[string]any)
err = json.Unmarshal(buf, &m)
ExpectNoError(err)
buf, err := polymorphichelpers.ObjectRestarterFn(latest)
if err != nil {
return err
}

deploy = new(appsv1.Deployment)
err = runtime.DefaultUnstructuredConverter.FromUnstructured(m, deploy)
ExpectNoError(err)
m := make(map[string]any)
if err = json.Unmarshal(buf, &m); err != nil {
return err
}

d := new(appsv1.Deployment)
if err = runtime.DefaultUnstructuredConverter.FromUnstructured(m, d); err != nil {
return err
}

deploy, err = c.Update(context.TODO(), deploy, metav1.UpdateOptions{})
result, err = c.Update(context.TODO(), d, metav1.UpdateOptions{})
return err
})
ExpectNoError(err)

return deploy.DeepCopy()
return result.DeepCopy()
}

// RestartSync restarts the deployment and wait it to be ready
Expand Down Expand Up @@ -212,11 +223,11 @@ func (c *DeploymentClient) Delete(name string) {
func (c *DeploymentClient) DeleteSync(name string) {
ginkgo.GinkgoHelper()
c.Delete(name)
gomega.Expect(c.WaitToDisappear(name, 2*time.Second, timeout)).To(gomega.Succeed(), "wait for deployment %q to disappear", name)
gomega.Expect(c.WaitToDisappear(name, poll, timeout)).To(gomega.Succeed(), "wait for deployment %q to disappear", name)
}

func (c *DeploymentClient) WaitToComplete(deploy *appsv1.Deployment) error {
return testutils.WaitForDeploymentComplete(c.clientSet, deploy, Logf, 2*time.Second, 2*time.Minute)
return testutils.WaitForDeploymentComplete(c.clientSet, deploy, Logf, poll, 2*time.Minute)
}

// WaitToDisappear waits the given timeout duration for the specified deployment to disappear.
Expand All @@ -238,5 +249,6 @@ func MakeDeployment(name string, replicas int32, podLabels, podAnnotations map[s
deploy := deployment.NewDeployment(name, replicas, podLabels, containerName, image, strategyType)
deploy.Spec.Template.Annotations = podAnnotations
deploy.Spec.Template.Spec.Containers[0].ImagePullPolicy = corev1.PullIfNotPresent
deploy.Spec.Template.Spec.TerminationGracePeriodSeconds = new(int64(1))
return deploy
}
2 changes: 1 addition & 1 deletion test/e2e/framework/dns-name-resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (c *DNSNameResolverClient) WaitToBeReady(name string, timeout time.Duration
result := c.WaitUntil(name, func(dnsNameResolver *apiv1.DNSNameResolver) (bool, error) {
// DNSNameResolver is considered ready if it has at least one resolved name
return len(dnsNameResolver.Status.ResolvedNames) > 0, nil
}, "Ready", 2*time.Second, timeout)
}, "Ready", poll, timeout)
return result != nil
}

Expand Down
10 changes: 5 additions & 5 deletions test/e2e/framework/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (c *EndpointsClient) Create(endpoints *corev1.Endpoints) *corev1.Endpoints
func (c *EndpointsClient) CreateSync(endpoints *corev1.Endpoints, cond func(s *corev1.Endpoints) (bool, error), condDesc string) *corev1.Endpoints {
ginkgo.GinkgoHelper()
_ = c.Create(endpoints)
return c.WaitUntil(endpoints.Name, cond, condDesc, 2*time.Second, timeout)
return c.WaitUntil(endpoints.Name, cond, condDesc, poll, timeout)
}

// Patch patches the endpoints
Expand All @@ -69,7 +69,7 @@ func (c *EndpointsClient) Patch(original, modified *corev1.Endpoints) *corev1.En
ExpectNoError(err)

var patchedEndpoints *corev1.Endpoints
err = wait.PollUntilContextTimeout(context.Background(), 2*time.Second, timeout, true, func(_ context.Context) (bool, error) {
err = wait.PollUntilContextTimeout(context.Background(), poll, timeout, true, func(_ context.Context) (bool, error) {
s, err := c.EndpointsInterface.Patch(context.TODO(), original.Name, types.MergePatchType, patch, metav1.PatchOptions{}, "")
if err != nil {
return handleWaitingAPIError(err, false, "patch endpoints %q", original.Name)
Expand All @@ -93,7 +93,7 @@ func (c *EndpointsClient) Patch(original, modified *corev1.Endpoints) *corev1.En
func (c *EndpointsClient) PatchSync(original, modified *corev1.Endpoints, cond func(s *corev1.Endpoints) (bool, error), condDesc string) *corev1.Endpoints {
ginkgo.GinkgoHelper()
_ = c.Patch(original, modified)
return c.WaitUntil(original.Name, cond, condDesc, 2*time.Second, timeout)
return c.WaitUntil(original.Name, cond, condDesc, poll, timeout)
}

// Delete deletes an Endpoints resource if it exists
Expand All @@ -110,15 +110,15 @@ func (c *EndpointsClient) Delete(name string) {
func (c *EndpointsClient) DeleteSync(name string) {
ginkgo.GinkgoHelper()
c.Delete(name)
gomega.Expect(c.WaitToDisappear(name, 2*time.Second, timeout)).To(gomega.Succeed(), "wait for endpoints %q to disappear", name)
gomega.Expect(c.WaitToDisappear(name, poll, timeout)).To(gomega.Succeed(), "wait for endpoints %q to disappear", name)
}

// WaitUntil waits the given timeout duration for the specified condition to be met.
func (c *EndpointsClient) WaitUntil(name string, cond func(s *corev1.Endpoints) (bool, error), condDesc string, _, timeout time.Duration) *corev1.Endpoints {
ginkgo.GinkgoHelper()

var endpoints *corev1.Endpoints
err := wait.PollUntilContextTimeout(context.Background(), 2*time.Second, timeout, true, func(_ context.Context) (bool, error) {
err := wait.PollUntilContextTimeout(context.Background(), poll, timeout, true, func(_ context.Context) (bool, error) {
Logf("Waiting for endpoints %s to meet condition %q", name, condDesc)
endpoints = c.Get(name).DeepCopy()
met, err := cond(endpoints)
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const (

const (
// poll is how often to Poll resources.
poll = 2 * time.Second
poll = time.Second

timeout = 2 * time.Minute
)
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/framework/ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (c *IPClient) Patch(original, modified *apiv1.IP, timeout time.Duration) *a
ExpectNoError(err)

var patchedIP *apiv1.IP
err = wait.PollUntilContextTimeout(context.Background(), 2*time.Second, timeout, true, func(ctx context.Context) (bool, error) {
err = wait.PollUntilContextTimeout(context.Background(), poll, timeout, true, func(ctx context.Context) (bool, error) {
p, err := c.IPInterface.Patch(ctx, original.Name, types.MergePatchType, patch, metav1.PatchOptions{}, "")
if err != nil {
return handleWaitingAPIError(err, false, "patch IP %q", original.Name)
Expand Down Expand Up @@ -115,7 +115,7 @@ func (c *IPClient) Delete(name string) {
func (c *IPClient) DeleteSync(name string) {
ginkgo.GinkgoHelper()
c.Delete(name)
gomega.Expect(c.WaitToDisappear(name, 2*time.Second, timeout)).To(gomega.Succeed(), "wait for ovn eip %q to disappear", name)
gomega.Expect(c.WaitToDisappear(name, poll, timeout)).To(gomega.Succeed(), "wait for ovn eip %q to disappear", name)
}

// WaitToDisappear waits the given timeout duration for the specified IP to disappear.
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/framework/ippool.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (c *IPPoolClient) Update(ippool *apiv1.IPPool, options metav1.UpdateOptions
ginkgo.GinkgoHelper()

var updatedIPPool *apiv1.IPPool
err := wait.PollUntilContextTimeout(context.Background(), 2*time.Second, timeout, true, func(ctx context.Context) (bool, error) {
err := wait.PollUntilContextTimeout(context.Background(), poll, timeout, true, func(ctx context.Context) (bool, error) {
s, err := c.IPPoolInterface.Update(ctx, ippool, options)
if err != nil {
// On conflict, refresh the resource and retry
Expand Down Expand Up @@ -113,7 +113,7 @@ func (c *IPPoolClient) Patch(original, modified *apiv1.IPPool, timeout time.Dura
ExpectNoError(err)

var patchedIPPool *apiv1.IPPool
err = wait.PollUntilContextTimeout(context.Background(), 2*time.Second, timeout, true, func(ctx context.Context) (bool, error) {
err = wait.PollUntilContextTimeout(context.Background(), poll, timeout, true, func(ctx context.Context) (bool, error) {
s, err := c.IPPoolInterface.Patch(ctx, original.Name, types.MergePatchType, patch, metav1.PatchOptions{}, "")
if err != nil {
return handleWaitingAPIError(err, false, "patch ippool %q", original.Name)
Expand Down Expand Up @@ -158,7 +158,7 @@ func (c *IPPoolClient) Delete(name string) {
func (c *IPPoolClient) DeleteSync(name string) {
ginkgo.GinkgoHelper()
c.Delete(name)
gomega.Expect(c.WaitToDisappear(name, 2*time.Second, timeout)).To(gomega.Succeed(), "wait for ippool %q to disappear", name)
gomega.Expect(c.WaitToDisappear(name, poll, timeout)).To(gomega.Succeed(), "wait for ippool %q to disappear", name)
}

func isIPPoolConditionSetAsExpected(ippool *apiv1.IPPool, conditionType apiv1.ConditionType, wantTrue, silent bool) bool {
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/framework/iptables-dnat.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (c *IptablesDnatClient) Patch(original, modified *apiv1.IptablesDnatRule) *
ExpectNoError(err)

var patchedIptablesDnatRule *apiv1.IptablesDnatRule
err = wait.PollUntilContextTimeout(context.Background(), 2*time.Second, timeout, true, func(ctx context.Context) (bool, error) {
err = wait.PollUntilContextTimeout(context.Background(), poll, timeout, true, func(ctx context.Context) (bool, error) {
dnat, err := c.IptablesDnatRuleInterface.Patch(ctx, original.Name, types.MergePatchType, patch, metav1.PatchOptions{}, "")
if err != nil {
return handleWaitingAPIError(err, false, "patch iptables dnat %q", original.Name)
Expand Down Expand Up @@ -116,7 +116,7 @@ func (c *IptablesDnatClient) Delete(name string) {
func (c *IptablesDnatClient) DeleteSync(name string) {
ginkgo.GinkgoHelper()
c.Delete(name)
gomega.Expect(c.WaitToDisappear(name, 2*time.Second, timeout)).To(gomega.Succeed(), "wait for iptables dnat %q to disappear", name)
gomega.Expect(c.WaitToDisappear(name, poll, timeout)).To(gomega.Succeed(), "wait for iptables dnat %q to disappear", name)
}

// WaitToBeReady returns whether the iptables dnat is ready within timeout.
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/framework/iptables-eip.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (c *IptablesEIPClient) Patch(original, modified *apiv1.IptablesEIP) *apiv1.
ExpectNoError(err)

var patchedIptablesEIP *apiv1.IptablesEIP
err = wait.PollUntilContextTimeout(context.Background(), 2*time.Second, timeout, true, func(ctx context.Context) (bool, error) {
err = wait.PollUntilContextTimeout(context.Background(), poll, timeout, true, func(ctx context.Context) (bool, error) {
eip, err := c.IptablesEIPInterface.Patch(ctx, original.Name, types.MergePatchType, patch, metav1.PatchOptions{}, "")
if err != nil {
return handleWaitingAPIError(err, false, "patch iptables eip %q", original.Name)
Expand Down Expand Up @@ -126,7 +126,7 @@ func (c *IptablesEIPClient) Delete(name string) {
func (c *IptablesEIPClient) DeleteSync(name string) {
ginkgo.GinkgoHelper()
c.Delete(name)
gomega.Expect(c.WaitToDisappear(name, 2*time.Second, timeout)).To(gomega.Succeed(), "wait for iptables eip %q to disappear", name)
gomega.Expect(c.WaitToDisappear(name, poll, timeout)).To(gomega.Succeed(), "wait for iptables eip %q to disappear", name)
}

// WaitToBeReady returns whether the iptables eip is ready within timeout.
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/framework/iptables-fip.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (c *IptablesFIPClient) Patch(original, modified *apiv1.IptablesFIPRule) *ap
ExpectNoError(err)

var patchedIptablesFIPRule *apiv1.IptablesFIPRule
err = wait.PollUntilContextTimeout(context.Background(), 2*time.Second, timeout, true, func(ctx context.Context) (bool, error) {
err = wait.PollUntilContextTimeout(context.Background(), poll, timeout, true, func(ctx context.Context) (bool, error) {
fip, err := c.IptablesFIPRuleInterface.Patch(ctx, original.Name, types.MergePatchType, patch, metav1.PatchOptions{}, "")
if err != nil {
return handleWaitingAPIError(err, false, "patch iptables fip %q", original.Name)
Expand Down Expand Up @@ -113,7 +113,7 @@ func (c *IptablesFIPClient) Delete(name string) {
func (c *IptablesFIPClient) DeleteSync(name string) {
ginkgo.GinkgoHelper()
c.Delete(name)
gomega.Expect(c.WaitToDisappear(name, 2*time.Second, timeout)).To(gomega.Succeed(), "wait for iptables fip %q to disappear", name)
gomega.Expect(c.WaitToDisappear(name, poll, timeout)).To(gomega.Succeed(), "wait for iptables fip %q to disappear", name)
}

// WaitToBeReady returns whether the iptables fip is ready within timeout.
Expand Down
Loading