diff options
author | Clark Boylan <clark.boylan@gmail.com> | 2023-02-06 09:41:34 -0800 |
---|---|---|
committer | Clark Boylan <clark.boylan@gmail.com> | 2023-02-06 10:30:18 -0800 |
commit | 753bebbb2c4d78a2be7c204865e841729c43c032 (patch) | |
tree | 1a190a711e8442a06140f20f3f62d1499400a161 /tests | |
parent | 2bf5f0ff3b2bda6bd16d3713e5a96fa48688bf55 (diff) | |
download | zuul-753bebbb2c4d78a2be7c204865e841729c43c032.tar.gz |
Cleanup some Python ResourceWarnings in the test suite
First thing we add support for PYTHONTRACEMALLOC being passed through
nox to easily enable tracebacks on emitted ResourceWarnings. We set this
value to 0 by deafult as enabling this slows things down and requires
more memory. But it is super useful locally when debugging specific
ResourceWarnings to set `PYTHONTRACEMALLOC=5` in order o correct these
issues.
With that in place we identify and correct two classes of
ResourceWarnings.
First up is the executor server not closing its statsd socket when
stopping the executor server. Address that by closing the socket if
statsd is enabled and set the statsd attribute to None to prevent
anything else from using it later.
Second is a test only issue where we don't close the fake Gerrit,
Gitlab, or Web Proxy Fixture server's HTTP socket we only shutdown the
server. Add a close call to the server after it is shutdown to correct
this.
There are potentially other ResourceWarnings to be found and cleaned up,
but sifting through the noise will be easier as we eliminate these more
widespread warnings.
Change-Id: Iddabe79be1c8557e300dde21a6b34e57b04c48e0
Diffstat (limited to 'tests')
-rw-r--r-- | tests/base.py | 2 | ||||
-rw-r--r-- | tests/fakegitlab.py | 1 |
2 files changed, 3 insertions, 0 deletions
diff --git a/tests/base.py b/tests/base.py index cdcf63390..0a0ec4ae0 100644 --- a/tests/base.py +++ b/tests/base.py @@ -1227,6 +1227,7 @@ class GerritWebServer(object): def stop(self): self.httpd.shutdown() self.thread.join() + self.httpd.server_close() class FakeGerritPoller(gerritconnection.GerritPoller): @@ -4082,6 +4083,7 @@ class WebProxyFixture(fixtures.Fixture): def _cleanup(self): self.httpd.shutdown() self.thread.join() + self.httpd.server_close() class ZuulWebFixture(fixtures.Fixture): diff --git a/tests/fakegitlab.py b/tests/fakegitlab.py index c4706b3b1..294887af0 100644 --- a/tests/fakegitlab.py +++ b/tests/fakegitlab.py @@ -262,3 +262,4 @@ class GitlabWebServer(object): def stop(self): self.httpd.shutdown() self.thread.join() + self.httpd.server_close() |