Even though some commands exited with non-zero exit code, we sometimes
believed it exited with zero code due to a race condition. This patch
fixes that and also moves the code to a separate function
run_and_print in os_utils.
Details
Details
- Reviewers
lbrabec - Group Reviewers
libtaskotron - Commits
- rLTRN355c415d4f98: shell_directive: fix race condition when running commands
in order to test this, first reproduce the issue on existing code base. Apply this patch:
diff --git a/testing/functest_shell_directive.py b/testing/functest_shell_directive.py index a1cc0f6..81a19e9 100644 --- a/testing/functest_shell_directive.py +++ b/testing/functest_shell_directive.py @@ -69,7 +69,11 @@ class TestCheckCommand(object): assert output == OUTPUT - def test_multi_command_error(self): + @pytest.fixture(params=xrange(1000)) + def moore(self, request): + return + + def test_multi_command_error(self, moore): test_params = ['true', 'echo -n %s' % OUTPUT[::-1], 'false',
and then run the test suite like this:
py.test -F testing/functest_shell_directive.py -x -k test_multi_command_error
During the execution, open up a new terminal and run yes command in order to simulate some load on your machine (or do something else to cause larger load on the machine). In my case, the race condition is triggered (and the test suite fails) immediately after running yes.
Now apply the patch and try the same with new codebase. It should no longer happen.
Diff Detail
Diff Detail
- Repository
- rLTRN libtaskotron
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.