freedomofpress / securedrop

GitHub repository for the SecureDrop whistleblower platform. Do not submit tips here!
https://securedrop.org/
Other
3.62k stars 686 forks source link

GPG agent processes are not cleaned up during testing #4332

Open heartsucker opened 5 years ago

heartsucker commented 5 years ago

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

  1. ./bin/dev-shell
  2. In the container, ./bin/run-test -vv tests/test_*.py
  3. 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.

nabla-c0d3 commented 2 years ago

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.