tarpas / pytest-testmon

Selects tests affected by changed files. Executes the right tests first. Continuous test runner when used with pytest-watch.
https://testmon.org
MIT License
800 stars 54 forks source link

Temporary files not being cleared inside a container #219

Open BasitAli opened 1 year ago

BasitAli commented 1 year ago

What is your setup and what steps did you do? When running pytest under a container or GitHub Actions ends up with the the following files

  1. .testmondata
  2. .testmondata-shm
  3. .testmondata-wal

This is how I run the tests on Docker,

docker-compose run --rm django pytest --testmon --no-cov

What was the outcome?

With these additional temporary files, subsequent runs with --testmon-nocollect still work in our pull requests, but if I run --test-mon --no-cov it fails with xdist error different tests were collected between gw1 and gw0.

What did you expect instead?

I would have expected the temporary files to be cleared and I should only end up with .testmondata. Disabling the following line db.py seems to resolve this.

connection.execute("PRAGMA journal_mode = WAL")

What is your operating system and it's version please?

I see the same issue on Docker inside WSL as well as on GitHub Actions. Everything works fine when I execute these commands on Ubuntu itself.

BasitAli commented 1 year ago

Playing around with it more suggests this may not necessarily be a docker / container issue. Disabling / Enabling some imports shows different behaviour in and out of the container. I thought I had singled out the bug to a single dependency but that still doesn't resolve it. Playing around with it more on an empty project in an attempt to get to the root of the problem.

jacksongoode commented 7 months ago

@BasitAli Do you have any idea why this happens? I've found that we get these files when we run testmon in our remote VM .

BasitAli commented 7 months ago

@BasitAli Do you have any idea why this happens? I've found that we get these files when we run testmon in our remote VM .

Unfortunately, I failed to make any progress in resolving or identifying the root cause for it. However, I worked around the issue by retrying the pytest --testmon --no-cov command when it first fails. This is what my workflow step for looks like,

    - name: Update testmon database
      uses: nick-fields/retry@v2
      with:
        timeout_minutes: 30
        max_attempts: 2
        retry_on: error
        command: 'pytest --testmon --no-cov'
tarpas commented 7 months ago

The WAL mode (the pragma) should improve the parallel processing and therefore behaviour of testmon under xdist.

I don't see how could different tests were collected between gw1 and gw0 depend on --no-cov.

BasitAli commented 7 months ago

I think the problem happens when generating the database. Running the tests is the after-effect I believe.

On Wed, Nov 15, 2023, 6:32 PM Tibor Arpas @.***> wrote:

The WAL mode (the pragma) should improve the parallel processing and therefore behaviour of testmon under xdist.

I don't see how could different tests were collected between gw1 and gw0 depend on --no-cov.

— Reply to this email directly, view it on GitHub https://github.com/tarpas/pytest-testmon/issues/219#issuecomment-1812543356, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGUIDU6CJJWM6IYA6WIP4DYES75JAVCNFSM6AAAAAAYMDLNMKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMJSGU2DGMZVGY . You are receiving this because you were mentioned.Message ID: @.***>

tarpas commented 7 months ago

I think the problem happens when generating the database. Running the tests is the after-effect I believe.

I'm not following.