Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporary files not being cleared inside a container #219

Open
BasitAli opened this issue May 23, 2023 · 6 comments
Open

Temporary files not being cleared inside a container #219

BasitAli opened this issue May 23, 2023 · 6 comments

Comments

@BasitAli
Copy link

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
Copy link
Author

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
Copy link

@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
Copy link
Author

@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
Copy link
Owner

tarpas commented Nov 15, 2023

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
Copy link
Author

BasitAli commented Nov 15, 2023 via email

@tarpas
Copy link
Owner

tarpas commented Nov 15, 2023

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

I'm not following.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants