question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Coverage in parallel failing

See original GitHub issue

Describe the bug When we run pytest using multiple processes with coverage on our tests, we get an error message that seems to be related to the integration of SQLite. The error we get is available from our integration test suite here: http://apollo.cs.man.ac.uk:8080/blue/organizations/jenkins/sPyNNaker8 Integration Tests/detail/neuron_recorder_agdr/10/pipeline/102

Replicated a sample of the output here in case this disappears!

[gw7] linux -- Python 3.6.7 /usr/bin/python3
self = <SqliteDb @0x7f9efba0c1d0 debug=None filename='/var/lib/jenkins/workspace/ation_Tests_neuron_recorder_agdr/.coverage' nest=0 con=None>
sql = 'insert into meta (key, value) values (?, ?)'
parameters = ('has_arcs', '1')

    def execute(self, sql, parameters=()):
        """Same as :meth:`python:sqlite3.Connection.execute`."""
        if self.debug:
            tail = " with {!r}".format(parameters) if parameters else ""
            self.debug.write("Executing {!r}{}".format(sql, tail))
        try:
>           return self.con.execute(sql, parameters)
E           sqlite3.IntegrityError: UNIQUE constraint failed: meta.key

To Reproduce How can we reproduce the problem? Please be specific.

  1. What version of Python are you using? 3.6
  2. What version of coverage.py are you using? The output of coverage debug sys is helpful. 5.0
  3. What versions of what packages do you have installed? The output of pip freeze is helpful. See above link for details.
  4. What code are you running? Give us a specific commit of a specific repo that we can check out. Integration tests in Jenkins; see above for details.
  5. What commands did you run?
py.test SpiNNUtils/unittests -rs -n auto --forked --show-progress --cov-branch --cov spynnaker8 --cov spynnaker --cov spinn_front_end_common --cov pacman --cov data_specification --cov spinnman --cov spinn_machine --cov spinn_storage_handlers --cov spalloc --cov spinn_utilities --junitxml junit/SpiNNUtils.xml --cov-report xml:coverage.xml --cov-append --timeout 1200

Expected behavior A clear and concise description of what you expected to happen. No error message; protection against writing from mulitple processes through checking for key in database before attempted insert.

Additional context Add any other context about the problem here.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:13
  • Comments:23 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
nedbatcommented, Jan 1, 2020

One solution is to add this to a .coveragerc file:

[run]
parallel = True

Removing --cov-append also prevents the error. I’m not sure which of these gives you the proper measurements, if either. I don’t know if there’s a better solution that can be built in to coverage.py or to pytest-cov.

2reactions
nedbatcommented, Jan 20, 2022

I believe this is now fixed in commit b41be3f9

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pytest coverage with django generates wrong result when run ...
When I run my testsuite with parallel executions I receive different results compared to run only one test runner.
Read more >
Unit Tests with Code Coverage No Longer Able to Run in ...
I can run unit tests in parallel, and I can run code coverage, but I can no longer do both at the same...
Read more >
Jacoco Coverage issue with Junit Parallel Execution
Hi Guys, I am seeing significant variations in jacoco coverage report for the same set of integration tests run in "parallel" vs "sequential"....
Read more >
pytest-cov - PyPI
Fixed internal failures that are caused by tests that change the current working directory by ensuring a consistent working directory when coverage is ......
Read more >
Configuring parallel tests with Code Climate - Semaphore
Run sum-coverage to combine the parallelized test reports into one unified report. Run upload-coverage to upload the combined test report to Code Climate....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found