salt icon indicating copy to clipboard operation
salt copied to clipboard

Add memory leak test

Open MKLeb opened this issue 2 years ago • 2 comments

What does this PR do?

Adds a test for a memory leak by running a couple of state files multiple times and then making sure that the general trend of memory usage after those state runs is downwards.

Essentially, it takes the maximum usage, $max$, during the runs of the state, and the usage just before the state runs, $start$, and gets the memory usage $current$ immediately after and (if needed) at 2 second intervals after the state runs (max 18 seconds, but never got there when local testing and usually succeeded after the first measurement). Then, the test passes if, at any of these intervals, the following is true. $$current <= 0.25 * (max - start) + start$$

What issues does this PR fix or reference?

Fixes: https://github.com/saltstack/salt/issues/61105

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

  • [ ] Docs
  • [ ] Changelog - https://docs.saltproject.io/en/master/topics/development/changelog.html
  • [x] Tests written/updated

Commits signed with GPG?

Yes

MKLeb avatar Jul 05 '22 21:07 MKLeb

Not really a review, mostly just a question/request for more information:

How do we test that this actually will expose a memory leak? That is, what do we need to do to make this test go red? Green is good but preferably we have some code that we can paste in or a --leak-memory flag or something so it's easy for someone to verify that this test still is testing what we think it's testing :joy:

waynew avatar Jul 19 '22 18:07 waynew

Not really a review, mostly just a question/request for more information:

How do we test that this actually will expose a memory leak? That is, what do we need to do to make this test go red? Green is good but preferably we have some code that we can paste in or a --leak-memory flag or something so it's easy for someone to verify that this test still is testing what we think it's testing 😂

A valid question, and one I was concerned about too. I was purely going off of the original issue's description, but if @frogunder has a state file I could use that would more assuredly expose a leak I can plug that in.

Also, if we do intentionally leak memory, we would need a way to, well, 'unleak it', which may pose some complications? I don't know the specifics, but I'm imagining some struggle with that maybe?

MKLeb avatar Jul 19 '22 18:07 MKLeb

re-run all

MKLeb avatar Aug 30 '22 17:08 MKLeb

re-run all

Ch3LL avatar Aug 31 '22 18:08 Ch3LL