Fix python wrapper script timing test which has been broken since we
moved this script from st2actions into st2common.
Since test was broken, we didn't correctly detect the timing and
performance issues. It looks like we introduced a bunch of new
performance issues which now need to be tracked down again.
@@ -53,7 +53,8 @@ re-organize code if possible.
""".strip())
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
-WRAPPER_SCRIPT_PATH = os.path.join(BASE_DIR, '../../st2common/runners/python_action_wrapper.py')
+WRAPPER_SCRIPT_PATH = os.path.join(BASE_DIR, '../../../st2common/st2common/runners/python_action_wrapper.py')
+WRAPPER_SCRIPT_PATH = os.path.abspath(WRAPPER_SCRIPT_PATH)
TIME_BINARY_PATH = find_executable('time')
TIME_BINARY_AVAILABLE = TIME_BINARY_PATH is not None
@@ -61,8 +62,16 @@ TIME_BINARY_AVAILABLE = TIME_BINARY_PATH is not None
@unittest2.skipIf(not TIME_BINARY_PATH, 'time binary not available')
class PythonRunnerActionWrapperProcessTestCase(unittest2.TestCase):
def test_process_wrapper_exits_in_reasonable_timeframe(self):
- _, _, stderr = run_command('%s -f "%%e" python %s --is-subprocess' %
- (TIME_BINARY_PATH, WRAPPER_SCRIPT_PATH), shell=True)
+ # 1. First run it without time to verify path is valid
+ command_string = 'python %s --is-subprocess' % (WRAPPER_SCRIPT_PATH)
+ _, _, stderr = run_command(command_string, shell=True)
+ self.assertTrue('usage: python_action_wrapper.py' in stderr)
+ self.assertTrue('python_action_wrapper.py: error: argument' in stderr)
+
+ # 2. Now time it
+ command_string = '%s -f "%%e" python %s --is-subprocess' % (TIME_BINARY_PATH,
+ WRAPPER_SCRIPT_PATH)
+ _, _, stderr = run_command(command_string, shell=True)
stderr = stderr.strip().split('\n')[-1]
