Closed yurique closed 11 months ago
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.
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.
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)
@yurique Looks good to me. Feel free to merge this.
I merged it
Nice!
see my posts related to tests here: https://github.com/joan38/kubernetes-client/pull/223#issuecomment-1807430308
tldr; a few tweaks to make tests run faster -
alpine
instead ofdocker
imagePullPolicy=IfNotPresent
for test pods;terminationGracePeriodSeconds=0
to the test pods specification;propagationPolicy=Background
to the delete options when deleting namespaces inafterAll
Result: