ariatosca-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mxm...@apache.org
Subject incubator-ariatosca git commit: fixed test waitinge [Forced Update!]
Date Tue, 27 Jun 2017 11:19:22 GMT
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-285-Cancel-execution-may-leave-running-processes d32315d22 -> 38d45d08b
(forced update)


fixed test waitinge


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/38d45d08
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/38d45d08
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/38d45d08

Branch: refs/heads/ARIA-285-Cancel-execution-may-leave-running-processes
Commit: 38d45d08b0326716c8b74f843fe35d692b20569e
Parents: 3d5efc4
Author: max-orlov <maxim@gigaspaces.com>
Authored: Tue Jun 27 11:53:40 2017 +0300
Committer: max-orlov <maxim@gigaspaces.com>
Committed: Tue Jun 27 14:19:16 2017 +0300

----------------------------------------------------------------------
 aria/logger.py                                  |  3 +--
 aria/orchestrator/workflows/executor/process.py | 21 ++++++++------------
 .../workflows/executor/test_process_executor.py |  9 +++++----
 3 files changed, 14 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/38d45d08/aria/logger.py
----------------------------------------------------------------------
diff --git a/aria/logger.py b/aria/logger.py
index 6094f75..bd7ed4e 100644
--- a/aria/logger.py
+++ b/aria/logger.py
@@ -48,7 +48,7 @@ class LoggerMixin(object):
     logger_name = None
     logger_level = logging.DEBUG
 
-    def __init__(self, termination_timeout=10, *args, **kwargs):
+    def __init__(self, *args, **kwargs):
         self.logger_name = self.logger_name or self.__class__.__name__
         self.logger = logging.getLogger('{0}.{1}'.format(_base_logger.name, self.logger_name))
         # Set the logger handler of any object derived from LoggerMixing to NullHandler.
@@ -56,7 +56,6 @@ class LoggerMixin(object):
         # `No handlers could be found for logger "..."`.
         self.logger.addHandler(NullHandler())
         self.logger.setLevel(self.logger_level)
-        self._termination_timeout = termination_timeout
         super(LoggerMixin, self).__init__(*args, **kwargs)
 
     @classmethod

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/38d45d08/aria/orchestrator/workflows/executor/process.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/workflows/executor/process.py b/aria/orchestrator/workflows/executor/process.py
index 92c83e3..f9fd9db 100644
--- a/aria/orchestrator/workflows/executor/process.py
+++ b/aria/orchestrator/workflows/executor/process.py
@@ -29,8 +29,6 @@ from collections import namedtuple
 
 import signal
 
-import time
-
 script_dir = os.path.dirname(__file__)
 if script_dir in sys.path:
     sys.path.remove(script_dir)
@@ -125,14 +123,8 @@ class ProcessExecutor(base.BaseExecutor):
     def terminate(self, task_id):
         task = self._tasks.get(task_id)
         # The process might have managed to finished so it would not be in the tasks list
-        if task and os.getsid(os.getpid()) != os.getpgid(task.proc.pid):
-            # If the above condition is false, the process group leader is the group leader
-            # for the current session of the system, and killing it will kill the the entire
-            # os session.
-            os.killpg(os.getpgid(task.proc.pid), signal.SIGINT)
-
-            time.sleep(self._termination_timeout)
-            os.killpg(os.getpgid(task.proc.pid), signal.SIGTERM)
+        if task:
+            os.killpg(os.getpgid(task.proc.pid), signal.SIGKILL)
 
     def _execute(self, ctx):
         self._check_closed()
@@ -146,10 +138,13 @@ class ProcessExecutor(base.BaseExecutor):
         env = self._construct_subprocess_env(task=ctx.task)
         # Asynchronously start the operation in a subprocess
         proc = subprocess.Popen(
-            '{0} {1} {2}'.format(sys.executable, __file__, arguments_json_path),
+            [
+                sys.executable,
+                os.path.expanduser(os.path.expandvars(__file__)),
+                os.path.expanduser(os.path.expandvars(arguments_json_path))
+            ],
             env=env,
-            preexec_fn=os.setsid,
-            shell=True)
+            preexec_fn=os.setsid)
 
         self._tasks[ctx.task.id] = _Task(ctx=ctx, proc=proc)
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/38d45d08/tests/orchestrator/workflows/executor/test_process_executor.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/workflows/executor/test_process_executor.py b/tests/orchestrator/workflows/executor/test_process_executor.py
index be3e833..205834c 100644
--- a/tests/orchestrator/workflows/executor/test_process_executor.py
+++ b/tests/orchestrator/workflows/executor/test_process_executor.py
@@ -90,12 +90,13 @@ class TestProcessExecutor(object):
 
         executor.execute(ctx)
 
-        while fs_test_holder.get('subproc', None) is None:
-            time.sleep(1)
-        pids = [executor._tasks[ctx.task.id].proc.pid, fs_test_holder['subproc']]
+        @retrying.retry(retry_on_result=lambda r: r is False, stop_max_delay=60000, wait_fixed=500)
+        def wait_for_extra_process_id():
+            return fs_test_holder.get('subproc', False)
+
+        pids = [executor._tasks[ctx.task.id].proc.pid, wait_for_extra_process_id()]
         assert any(p.pid == pid for p in psutil.process_iter() for pid in pids)
         executor.terminate(ctx.task.id)
-        time.sleep(10)
         assert not any(p.pid == pid and p.status() != psutil.STATUS_ZOMBIE
                        for p in psutil.process_iter()
                        for pid in pids)


Mime
View raw message