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

xdist misidentifies failing test on teardown crash #124

Closed
reginaldl opened this issue Feb 23, 2017 · 5 comments · Fixed by #218
Closed

xdist misidentifies failing test on teardown crash #124

reginaldl opened this issue Feb 23, 2017 · 5 comments · Fixed by #218
Labels

Comments

@reginaldl
Copy link
Contributor

reginaldl commented Feb 23, 2017

Hi!

I'm seeing xdist flagging the wrong test when a crash happens at test teardown.
Given 2 tests:

  • test_a, passes but crashes at teardown
  • test_b, passes

xdist will identify test_b as failing.
I have been able to reproduce while using pytest-xdist and pytest-timeout.
Here are the steps I've been following:

  • Test file:
import pytest
import time

@pytest.fixture
def timeout_fixture(request):
    def long_wait():
        time.sleep(20)
    request.addfinalizer(long_wait)

def test_a(timeout_fixture):
    print("hello")

def test_b():
    print("world")

def test_c():
    print("bonjour")

def test_d():
    print("monde")
  • Run test with --timeout-method=thread, so pytest-timeout will kill our process and xdist will see it crashed:
    $ py.test -s -x -vv --timeout=2 --timeout-method=thread -n 1

Result:

[...]
test_bug.py::test_a 
[gw0] PASSED test_bug.py::test_a 
+++++++++++++++++++++++++++++++++++ Timeout ++++++++++++++++++++++++++++++++++++
[...]
[gw0] node down: Not properly terminated
[gw0] FAILED test_bug.py::test_b 
Replacing crashed slave gw0
[gw1] darwin Python 2.7.10 cwd: /private/tmp/test
[gw1] Python 2.7.10 (default, Jul 30 2016, 19:40:32)  -- [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)]
gw1 [4]
test_bug.py::test_d 
[gw1] PASSED test_bug.py::test_d 
test_bug.py::test_c 
[gw1] PASSED test_bug.py::test_c 
========================================================================================================================================================== FAILURES ==========================================================================================================================================================
________________________________________________________________________________________________________________________________________________________ test_bug.py _________________________________________________________________________________________________________________________________________________________
[gw0] darwin -- Python 2.7.10 /usr/bin/python
Slave 'gw0' crashed while running 'test_bug.py::test_b'
============================================================================================================================================= 1 failed, 3 passed in 4.01 seconds =============================================================================================================================================

test_b is seen as failing but hasn't been executed at all.

I believe this is due to the way xdist handles crashed items. When a node crashes, it pops the running item and reschedule it on a new node. However, when the node crashes at teardown, the running item has already been dequeued.

@reginaldl
Copy link
Contributor Author

Hi! I see that the PR has been merged, thanks!

Any ETA for a release?

@nicoddemus
Copy link
Member

That's out in 1.16.0, no?

@reginaldl
Copy link
Contributor Author

This is looking at master, v1.16.0 tag does not include this merge.
I think my initial update to the Changelog is at the wrong place, I'll send an update.

nicoddemus added a commit that referenced this issue Jun 9, 2017
@nicoddemus
Copy link
Member

Fixed in 1.17.0.

@nicoddemus nicoddemus reopened this Jun 10, 2017
@nicoddemus
Copy link
Member

We had to pull this back in 1.17.1 (#157). I will see if I can reproduce the problem in pytest-xdist itself.

Also, @reginaldl would you like to give this another try? 😁

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