Skip to content
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

tweaking tests #257

Merged
merged 4 commits into from
Nov 24, 2023
Merged

tweaking tests #257

merged 4 commits into from
Nov 24, 2023

Conversation

yurique
Copy link
Collaborator

@yurique yurique commented Nov 15, 2023

see my posts related to tests here: #223 (comment)

tldr; a few tweaks to make tests run faster -

  • change the image for the test pods - alpine instead of docker
  • set imagePullPolicy=IfNotPresent for test pods;
  • add terminationGracePeriodSeconds=0 to the test pods specification;
  • set propagationPolicy=Background to the delete options when deleting namespaces in afterAll

Result:

  • locally for me it now only takes only ~2 minutes to run all tests;
  • in CI - it is now under 10 minutes vs 20-30 minutes before the change.

log pod conditions while waiting in pod tests
@yurique yurique marked this pull request as ready for review November 16, 2023 00:14
@timbertson
Copy link
Contributor

propagationPolicy=Background

Does that run a chance of the namespace not really being cleaned up by the time the next test runs and maybe tries to use the same namespace? All the other changes sound good but this one sounds potentially risky and doesn't seem like it would speed things up much anyway.

@yurique
Copy link
Collaborator Author

yurique commented Nov 16, 2023

Does that run a chance of the namespace not really being cleaned up by the time the next test runs

I assume this is possible, yeah.

As of now, each suite uses a different namespace:

def defaultNamespace: String = resourceName.toLowerCase

if we keep it this way it should be fine.

But I'm also pretty sure I can drop propagationPolicy=Background (maybe even go back to deleteTerminated) - it doesn't seem to be making the namespace cleanup any faster, as the real problem was gracePeriodSeconds = 0L seemingly not having any effect (which is fixed by adding terminationGracePeriodSeconds=0 to the pods per se).

I'll test it later today.

@yurique
Copy link
Collaborator Author

yurique commented Nov 17, 2023

I changed the propagationPolicy to Foreground - it added just a few seconds to the testing time (on my machine):

  • 88.33 secs with Foreground
  • 84.85 secs with Background

I also tried reverting to client.namespaces.deleteTerminated instead of client.namespaces.delete, and that made the tests run for 269.87 secs locally 🙀.
I'd say it should be fine with propagationPolicy=Foreground and without deleteTerminated.

If one day a test happens to use a namespace that another test has already used and deleted - worst case scenario is k8s will reject to create it because it's still deleting the previous one, or something like that. And in that case fixing that test will as easy as using a different namespace name. I vote 3x faster tests is worth the risk :).

Another thing we can do is try to make the namespace names in the MinikubeClientProvider unique. Something like:

def defaultNamespace: String = resourceName.toLowerCase + "-"+ someGlobalCounter.inc().toString

+make sure all tests are deriving the namespace names from the defaultNamespace (which I suspect is not the case right now)

@joan38
Copy link
Owner

joan38 commented Nov 24, 2023

@yurique Looks good to me. Feel free to merge this.

@joan38 joan38 merged commit 1c8159c into joan38:main Nov 24, 2023
7 checks passed
@joan38
Copy link
Owner

joan38 commented Nov 24, 2023

I merged it

@yurique
Copy link
Collaborator Author

yurique commented Nov 25, 2023

Nice!

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

Successfully merging this pull request may close these issues.

3 participants