sahara-scenario: set PYTHON when starting the test

Make sure that the internally-generated test uses the same PYTHON
variable that started sahara-scenario. Otherwise, when running inside
a virtualenv, the python executable from the venv is not used.

This change allows us to enable again the Python 3 scenario test.
Change-Id: I42d16b4acf72ff279d6b31840e11f2e7f939b113
This commit is contained in:
Luigi Toscano 2019-08-12 13:57:52 +02:00
parent 1e016405f8
commit a225824efc
3 changed files with 13 additions and 2 deletions

View File

@ -14,8 +14,7 @@
voting: false
- sahara-tests-scenario
- sahara-tests-scenario-v2
- sahara-tests-scenario-py3:
voting: false
- sahara-tests-scenario-py3
- sahara-tests-tempest
- sahara-tests-tempest-v2
- sahara-tests-scenario-rocky
@ -26,6 +25,7 @@
jobs:
- sahara-tests-scenario
- sahara-tests-scenario-v2
- sahara-tests-scenario-py3
- sahara-tests-tempest
- sahara-tests-tempest-v2
experimental:

View File

@ -0,0 +1,5 @@
---
fixes:
- |
Fix a strange error where the internally generated test does not start
because sahara_tests.scenario is not found when running inside a virtualenv.

View File

@ -60,6 +60,12 @@ def run_tests(concurrency, test_dir_path):
if concurrency:
command.extend(['--concurrency=%d' % concurrency])
new_env = os.environ.copy()
# Use the same python executable which has started sahara-scenario,
# if the PYTHON value has not been set explicitly.
# This is important whenever sahara-scenario is executed in a virtualenv
# or there are multiple Python versions around.
if not new_env.get('PYTHON', ''):
new_env['PYTHON'] = sys.executable
tester_runner = subprocess.Popen(command, env=new_env, cwd=test_dir_path)
tester_runner.communicate()
return tester_runner.returncode