The tests with random parameter cannot run
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
os-testr |
Invalid
|
Undecided
|
Unassigned |
Bug Description
Steps to reproduce:
1. I write the following code in test.py
2. When I run "ostestr test" command, I can only run 1 test,
3. When I run 'ostestr -n test'.I can run full tests (2 tests).
I don't know what's worry about this?
#######
import random
import ddt
from manila import test
@ddt.ddt
class RandomTestCase(
def setUp(self):
@ddt.
def test_with_
pass
#######
# ostestr test
running=
OS_STDERR_
OS_TEST_
OS_LOG_
${PYTHON:-python} -m subunit.run discover -t ./ ./manila/tests --list
running=
OS_STDERR_
OS_TEST_
OS_LOG_
${PYTHON:-python} -m subunit.run discover -t ./ ./manila/tests --load-list /tmp/tmptQJ9aA
running=
OS_STDERR_
OS_TEST_
OS_LOG_
${PYTHON:-python} -m subunit.run discover -t ./ ./manila/tests --load-list /tmp/tmpdyNk6v
{1} test.RandomTest
======
Totals
======
Ran: 1 tests in 7.0000 sec.
- Passed: 1
- Skipped: 0
- Expected Fail: 0
- Unexpected Success: 0
- Failed: 0
Sum of execute time for each test: 1.1626 sec.
==============
Worker Balance
==============
- WARNING: missing Worker 0! Race in testr accounting.
- Worker 1 (1 tests) => 0:00:01.162648
Slowest Tests:
Test id Runtime (s)
-------
test.RandomTest
#######
# ostestr -n test
{0} test.RandomTest
{0} test.RandomTest
======
Totals
======
Ran: 2 tests in 1.0000 sec.
- Passed: 2
- Skipped: 0
- Expected Fail: 0
- Unexpected Success: 0
- Failed: 0
Sum of execute time for each test: 1.1351 sec.
==============
Worker Balance
==============
- Worker 0 (2 tests) => 0:00:01.135313
description: | updated |
description: | updated |
After discuss with clarkb, he gave some good explanation:
When we run "ostestr" command, the first step is --list (first process) then after partitioning that list into subsets each subset is given to a different process (second set of processes) so we import at least twice. The problem is importing multiple times in different processes produces different test names because rand int is different most of the time.