securedrop
securedrop copied to clipboard
GPG agent processes are not cleaned up during testing
Description
While running the test suite, the test suite calls many times to gpg2
each with its own gpg-home
directory. This causes many instances of gpg-agent
to spawn. These processes are not killed and by the end of a run of the test suite, there are over 80 processes that are left around. When the container exists, these processes are killed, but they take up some amount of memory and resources. This is annoying when using a dev shell and repeatedly running sections of the test suite as it will leave hundreds of processes around if they are not manually cleaned up.
Steps to Reproduce
-
./bin/dev-shell
- In the container,
./bin/run-test -vv tests/test_*.py
- After the tests complete,
pgrep gpg-agent | wc -l
Expected Behavior
The number of gpg-agent
processes is 0 at the end of the tests.
Actual Behavior
The number is over 80.
Comments
The pytest
fixture that calls gpg2
should yield
it's fixture object and then attempt to clean up the dangling process. An example of this is in #4312.
This is not happening anymore: at the end of the tests, no gpg2
processes are running.
Might have been fixed as a side-effect of the changes in https://github.com/freedomofpress/securedrop/pull/5683 and https://github.com/freedomofpress/securedrop/pull/6184 , which reduce the number of gpg2
processes spawned by the test suite to 1, and use yield
in the GPG fixture.