Skip to content

Conversation

luksa
Copy link
Contributor

@luksa luksa commented Oct 10, 2022

The sleep in ensureNamespaceExists was hardcoded to 100ms, regardless of r.handleEventTimeout. This timeout during unit tests is only 1ms, so the 100ms sleep caused the for loop to only run once.

Here we change the duration of the sleep to be 1/100 of r.handleEventTimeout. This change preserves the production sleep time of 100ms, but reduces the sleep time in unit tests to 10μs. This makes ensureNamespaceExists() run the for loop multiple times before giving up, fixing the test's flakiness.

The sleep in ensureNamespaceExists was hardcoded to 100ms, regardless of r.handleEventTimeout. This timeout during unit tests is only 1ms, so the 100ms sleep caused the for loop to only run once.

Here we change the duration of the sleep to be 1/100 of r.handleEventTimeout. This change preserves the production sleep time of 100ms, but reduces the sleep time in unit tests to 10μs. This makes ensureNamespaceExists() run the for loop multiple times before giving up, fixing the test's flakiness.
Copy link

@oschaaf oschaaf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - but I think that with these changes, now the pr description is a little out of sync.

@luksa
Copy link
Contributor Author

luksa commented Oct 11, 2022

I've decided to only keep my original change, as the other changes considerably slowed down the test. This test will probably be rewritten anyway.

Also, although my original change reduces the sleep to just 1/100.000s, this only applies to the test itself, not when the code runs in production (there, the sleep is .1s long). In the test, this leads to the for loop running for around 5-15 loops, so it's not a big deal. It's still better than having a tight loop with no sleep (in that case, it does around 400-500 loops on my machine).

@luksa
Copy link
Contributor Author

luksa commented Oct 11, 2022

/test istio-unit-2-1

Flaky TestStatusManager() strikes again.

@maistra maistra deleted a comment from maistra-bot Oct 11, 2022
@luksa
Copy link
Contributor Author

luksa commented Oct 11, 2022

/test istio-unit-2-1

@maistra maistra deleted a comment from maistra-bot Oct 11, 2022
@luksa
Copy link
Contributor Author

luksa commented Oct 11, 2022

/retest

3 similar comments
@luksa
Copy link
Contributor Author

luksa commented Oct 11, 2022

/retest

@luksa
Copy link
Contributor Author

luksa commented Oct 11, 2022

/retest

@luksa
Copy link
Contributor Author

luksa commented Oct 11, 2022

/retest

@maistra-bot maistra-bot merged commit 4e034e3 into maistra:maistra-2.1 Oct 11, 2022
@maistra-bot
Copy link

In response to a cherrypick label: new pull request created: #647

@maistra-bot
Copy link

In response to a cherrypick label: new pull request created: #648

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants