-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove most of the time.Sleep from the e2e tests #2374
Conversation
232ef22
to
d962ecd
Compare
4961256
to
5584235
Compare
5ae19cb
to
779ad7f
Compare
74c26c8
to
7288e2e
Compare
I did some digging into why the The problem is from the ngx.timer.every call that syncs the backends in the lua balancer module. This call runs asynchronously every second. From ngx.timer.every docs:
Although sleeps are undesirable in tests, I feel that the simplest solution is to use one in this case. I have tested a few times with a 1 second sleep and this has been enough to prevent the error from occuring in |
@zrdaley thank you for digging into that issue. I am still cleaning the tests but I will add a timeout in the dynamic scenario you mention |
No problem! One will also be needed in the dynamic configuration test |
fc2f0da
to
f79ed0a
Compare
083c690
to
fb4fe94
Compare
Codecov Report
@@ Coverage Diff @@
## master #2374 +/- ##
=======================================
Coverage 39.12% 39.12%
=======================================
Files 73 73
Lines 5204 5204
=======================================
Hits 2036 2036
Misses 2878 2878
Partials 290 290 Continue to review full report at Codecov.
|
/assign @ElvinEfendi |
test/e2e/framework/framework.go
Outdated
@@ -180,52 +189,46 @@ func (f *Framework) GetNginxURL(scheme RequestScheme) (string, error) { | |||
// WaitForNginxServer waits until the nginx configuration contains a particular server section | |||
func (f *Framework) WaitForNginxServer(name string, matcher func(cfg string) bool) error { | |||
// initial wait to allow the update of the ingress controller |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this comment is not needed anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
test/e2e/framework/framework.go
Outdated
@@ -180,52 +189,46 @@ func (f *Framework) GetNginxURL(scheme RequestScheme) (string, error) { | |||
// WaitForNginxServer waits until the nginx configuration contains a particular server section | |||
func (f *Framework) WaitForNginxServer(name string, matcher func(cfg string) bool) error { | |||
// initial wait to allow the update of the ingress controller | |||
time.Sleep(5 * time.Second) | |||
return wait.PollImmediate(Poll, time.Minute*2, f.matchNginxConditions(name, matcher)) | |||
} | |||
|
|||
// WaitForNginxConfiguration waits until the nginx configuration contains a particular configuration | |||
func (f *Framework) WaitForNginxConfiguration(matcher func(cfg string) bool) error { | |||
// initial wait to allow the update of the ingress controller |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
pod.Status.ContainerStatuses[0].State.Running != nil { | ||
return f.Logs(&pod) | ||
if strings.HasPrefix(pod.GetName(), "nginx-ingress-controller") { | ||
if isRunning, err := podRunningReady(&pod); err == nil && isRunning { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
test/e2e/framework/test_context.go
Outdated
@@ -46,6 +46,10 @@ func RegisterCommonFlags() { | |||
// Randomize specs as well as suites | |||
config.GinkgoConfig.RandomizeAllSpecs = true | |||
|
|||
// Default SlowSpecThreshold is 5 seconds. | |||
// To low for the king of operations we need to tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/To/Too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
test/e2e/up.sh
Outdated
@@ -27,7 +27,7 @@ curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.25.2/minik | |||
|
|||
echo "starting minikube..." | |||
# Using sync-frequency=5s helps to speed up the tests (during the cleanup of resources inside a namespace) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can probably reword this to "Using lower value for sync-frequency helps..." so that we don't have to keep this up-to-date with the value we set.(currently they are not in sync 1s vs 5s)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
I love that we now have an isolated ingress-nginx deployment per test suite 😍 |
test/e2e/wait-for-nginx.sh
Outdated
kubectl logs -n ingress-nginx -l app=ingress-nginx | ||
exit 1 | ||
fi | ||
sleep 5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you decide to not keep the existing waitForPod
approach? That seemed more resilient to me than hard coded 5s sleep.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only because of the sleep of 30 seconds. Also now we use the same wait logic than the rest of the tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But that 30s is a timeout threshold, it does not necessarily wait 30s. It checks every next second and breaks out once the pods are ready - so if the pods are ready before 5s it would return faster
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also now we use the same wait logic than the rest of the tests
In the rest of the tests for ingress-nginx deployment we use WaitForPodsReady
(i.e
https://github.com/kubernetes/ingress-nginx/pull/2374/files#diff-e427cee5cedcaaa18c6ac5414ea08183R379) which is more aligned with the previous implementation in this script IMHO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just few small comments/questions - LGTM in general!
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: aledbf, ElvinEfendi The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Great work on this PR @aledbf - didn't think I'd see this in master so soon! |
What this PR does / why we need it:
A first step to remove hardcoded
time.Sleep
from e2e testsChanges:
make e2e-test
against minikube (previous upload of the docker image)After this PR we can start running the e2e tests in parallel