dragonflydb / dragonfly

A modern replacement for Redis and Memcached
https://www.dragonflydb.io/
Other
24.46k stars 884 forks source link

fix: missing logs on pytest failures #3226

Open kostasrim opened 4 days ago

kostasrim commented 4 days ago

On failed assertions pytest would sometimes copy the logs to the failed folder before the instance is actually stopped. To further complicate things it turns out that this was a bigger issue because we copied the failures per session but sometimes certain fixtures had session scope (for example df_server) which would always cause loss of logs because the instances would stop right after we copied their logs to the tmp folder.

The solution is hacky but it works. We add another indirection to keep track of the failed logs for each test. Each time a test fails, we announce that the test failed and the name of the logs that failed and we copy their path to another file which at the end of the session copy back to the /tmp/failed and upload the logs. This works well for session fixtures as well, providing the write clean up semantics.

P.s. SetUp and Teardown evaluation is a little bit of a mess in python and it's clear to me why people discourage it. Unfortunately for our use case it's required.

kostasrim commented 4 days ago

https://github.com/dragonflydb/dragonfly/actions/runs/9681419582/job/26711964457?pr=3226 all good tested in various setups

kostasrim commented 4 days ago

new test failure https://github.com/dragonflydb/dragonfly/actions/runs/9681657533/job/26712730878?pr=3226#step:12:905

TODO create an issue