Browse Source

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
tags/0.9.1^0
Luigi Toscano 2 months ago
parent
commit
a225824efc

+ 2
- 2
.zuul.yaml View File

@@ -14,8 +14,7 @@
14 14
             voting: false
15 15
         - sahara-tests-scenario
16 16
         - sahara-tests-scenario-v2
17
-        - sahara-tests-scenario-py3:
18
-            voting: false
17
+        - sahara-tests-scenario-py3
19 18
         - sahara-tests-tempest
20 19
         - sahara-tests-tempest-v2
21 20
         - sahara-tests-scenario-rocky
@@ -26,6 +25,7 @@
26 25
       jobs:
27 26
         - sahara-tests-scenario
28 27
         - sahara-tests-scenario-v2
28
+        - sahara-tests-scenario-py3
29 29
         - sahara-tests-tempest
30 30
         - sahara-tests-tempest-v2
31 31
     experimental:

+ 5
- 0
releasenotes/notes/sahara-scenario-fix-runner-59350d608d19caf9.yaml View File

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

+ 6
- 0
sahara_tests/scenario/utils.py View File

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

Loading…
Cancel
Save