예제 #1
0
    def _setUpPyro(self):
        global _pyomo_ns_port
        global _pyomo_ns_process
        global _dispatch_srvr_port
        global _dispatch_srvr_process
        global _taskworker_processes
        if _pyomo_ns_process is None:
            _pyomo_ns_process, _pyomo_ns_port = \
                _get_test_nameserver(ns_host=_pyomo_ns_host)
        assert _pyomo_ns_process is not None
        if _dispatch_srvr_process is None:
            _dispatch_srvr_process, _dispatch_srvr_port = \
                _get_test_dispatcher(ns_host=_pyomo_ns_host,
                                     ns_port=_pyomo_ns_port)
        assert _dispatch_srvr_process is not None
        class_name, test_name = self.id().split('.')[-2:]
        if len(_taskworker_processes) == 0:
            for i in range(3):
                outname = os.path.join(thisdir,
                                       class_name+"."+test_name+".scenariotreeserver_"+str(i+1)+".out")
                self._tempfiles.append(outname)
                with open(outname, "w") as f:
                    _taskworker_processes.append(
                        subprocess.Popen(["scenariotreeserver", "--traceback"] + \
                                         (["--verbose"] if _run_verbose else []) + \
                                         ["--pyro-host="+str(_pyomo_ns_host)] + \
                                         ["--pyro-port="+str(_pyomo_ns_port)],
                                         stdout=f,
                                         stderr=subprocess.STDOUT))

            time.sleep(2)
            [_poll(proc) for proc in _taskworker_processes]
예제 #2
0
 def test_solve_distributed(self):
     ns_host = '127.0.0.1'
     ns_process = None
     dispatcher_process = None
     scenariotreeserver_processes = []
     try:
         ns_process, ns_port = \
             _get_test_nameserver(ns_host=ns_host)
         self.assertNotEqual(ns_process, None)
         dispatcher_process, dispatcher_port = \
             _get_test_dispatcher(ns_host=ns_host,
                                  ns_port=ns_port)
         self.assertNotEqual(dispatcher_process, None)
         scenariotreeserver_processes = []
         for i in range(3):
             scenariotreeserver_processes.append(\
                 subprocess.Popen(["scenariotreeserver", "--traceback"] + \
                                  ["--pyro-host="+str(ns_host)] + \
                                  ["--pyro-port="+str(ns_port)]))
         cmd = ('python ' + \
                join(examples_dir, 'solve_distributed.py') + \
                ' %d') % (ns_port)
         print("Testing command: "+cmd)
         time.sleep(2)
         [_poll(proc) for proc in scenariotreeserver_processes]
         _run_cmd(cmd, shell=True)
     finally:
         _kill(ns_process)
         _kill(dispatcher_process)
         [_kill(proc) for proc in scenariotreeserver_processes]
예제 #3
0
    def _setUpPyro(self):
        global _pyomo_ns_port
        global _pyomo_ns_process
        global _dispatch_srvr_port
        global _dispatch_srvr_process
        global _taskworker_processes
        if _pyomo_ns_process is None:
            _pyomo_ns_process, _pyomo_ns_port = \
                _get_test_nameserver(ns_host=_pyomo_ns_host)
        assert _pyomo_ns_process is not None
        if _dispatch_srvr_process is None:
            _dispatch_srvr_process, _dispatch_srvr_port = \
                _get_test_dispatcher(ns_host=_pyomo_ns_host,
                                     ns_port=_pyomo_ns_port)
        assert _dispatch_srvr_process is not None
        class_name, test_name = self.id().split('.')[-2:]
        if len(_taskworker_processes) == 0:
            for i in range(3):
                outname = os.path.join(
                    thisdir, class_name + "." + test_name +
                    ".scenariotreeserver_" + str(i + 1) + ".out")
                self._tempfiles.append(outname)
                with open(outname, "w") as f:
                    _taskworker_processes.append(
                        subprocess.Popen(["scenariotreeserver", "--traceback"] + \
                                         (["--verbose"] if _run_verbose else []) + \
                                         ["--pyro-host="+str(_pyomo_ns_host)] + \
                                         ["--pyro-port="+str(_pyomo_ns_port)],
                                         stdout=f,
                                         stderr=subprocess.STDOUT))

            time.sleep(2)
            [_poll(proc) for proc in _taskworker_processes]
예제 #4
0
 def _run_cmd_with_pyro(self, cmd, num_servers):
     ns_host = '127.0.0.1'
     ns_process = None
     dispatcher_process = None
     scenariotreeserver_processes = []
     try:
         ns_process, ns_port = \
             _get_test_nameserver(ns_host=ns_host)
         self.assertNotEqual(ns_process, None)
         dispatcher_process, dispatcher_port = \
             _get_test_dispatcher(ns_host=ns_host,
                                  ns_port=ns_port)
         self.assertNotEqual(dispatcher_process, None)
         scenariotreeserver_processes = []
         for i in range(num_servers):
             scenariotreeserver_processes.append(\
                 subprocess.Popen(["scenariotreeserver", "--traceback"] + \
                                  ["--pyro-host="+str(ns_host)] + \
                                  ["--pyro-port="+str(ns_port)]))
         cmd += " --scenario-tree-manager=pyro"
         cmd += " --pyro-host=" + ns_host
         cmd += " --pyro-port=" + str(ns_port)
         print("Testing command: " + cmd)
         time.sleep(2)
         [_poll(proc) for proc in scenariotreeserver_processes]
         _run_cmd(cmd, shell=True)
     finally:
         _kill(ns_process)
         _kill(dispatcher_process)
         [_kill(proc) for proc in scenariotreeserver_processes]
         if os.path.exists(os.path.join(thisDir, 'Pyro_NS_URI')):
             try:
                 os.remove(os.path.join(thisDir, 'Pyro_NS_URI'))
             except OSError:
                 pass
예제 #5
0
def _setUpModule():
    global _pyomo_ns_port
    global _pyomo_ns_process
    global _dispatch_srvr_port
    global _dispatch_srvr_process
    global _taskworker_processes
    if _pyomo_ns_process is None:
        _pyomo_ns_process, _pyomo_ns_port = \
            _get_test_nameserver(ns_host=_pyomo_ns_host)
    assert _pyomo_ns_process is not None
    if _dispatch_srvr_process is None:
        _dispatch_srvr_process, _dispatch_srvr_port = \
            _get_test_dispatcher(ns_host=_pyomo_ns_host,
                                 ns_port=_pyomo_ns_port)
    assert _dispatch_srvr_process is not None
    if len(_taskworker_processes) == 0:
        for i in range(3):
            _taskworker_processes.append(\
                subprocess.Popen(["scenariotreeserver", "--traceback"] + \
                                 (["--verbose"] if _run_verbose else []) + \
                                 ["--pyro-host="+str(_pyomo_ns_host)] + \
                                 ["--pyro-port="+str(_pyomo_ns_port)]))

        time.sleep(2)
        [_poll(proc) for proc in _taskworker_processes]
예제 #6
0
def _setUpPyro():
    global _pyomo_ns_port
    global _pyomo_ns_process
    global _dispatch_srvr_port
    global _dispatch_srvr_process
    global _taskworker_processes
    if _pyomo_ns_process is None:
        _pyomo_ns_process, _pyomo_ns_port = \
            _get_test_nameserver(ns_host=_pyomo_ns_host)
    assert _pyomo_ns_process is not None
    if _dispatch_srvr_process is None:
        _dispatch_srvr_process, _dispatch_srvr_port = \
            _get_test_dispatcher(ns_host=_pyomo_ns_host,
                                 ns_port=_pyomo_ns_port)
    assert _dispatch_srvr_process is not None
    if len(_taskworker_processes) == 0:
        for i in range(3):
            outname = os.path.join(thisdir,
                                   "TestCapture_scenariotreeserver_" + \
                                   str(i+1) + ".out")
            with open(outname, "w") as f:
                _taskworker_processes.append(
                    subprocess.Popen(["scenariotreeserver", "--traceback"] + \
                                     ["--import-module="+thisfile] + \
                                     (["--verbose"] if _run_verbose else []) + \
                                     ["--pyro-host="+str(_pyomo_ns_host)] + \
                                     ["--pyro-port="+str(_pyomo_ns_port)],
                                     stdout=f,
                                     stderr=subprocess.STDOUT))
        time.sleep(2)
        [_poll(proc) for proc in _taskworker_processes]
예제 #7
0
def _setUpModule():
    global _pyomo_ns_port
    global _pyomo_ns_process
    global _dispatch_srvr_port
    global _dispatch_srvr_process
    global _taskworker_processes
    if _pyomo_ns_process is None:
        _pyomo_ns_process, _pyomo_ns_port = \
            _get_test_nameserver(ns_host=_pyomo_ns_host)
    assert _pyomo_ns_process is not None
    if _dispatch_srvr_process is None:
        _dispatch_srvr_process, _dispatch_srvr_port = \
            _get_test_dispatcher(ns_host=_pyomo_ns_host,
                                 ns_port=_pyomo_ns_port)
    assert _dispatch_srvr_process is not None
    if len(_taskworker_processes) == 0:
        for i in range(3):
            _taskworker_processes.append(\
                subprocess.Popen(["scenariotreeserver", "--traceback"] + \
                                 (["--verbose"] if _run_verbose else []) + \
                                 ["--pyro-host="+str(_pyomo_ns_host)] + \
                                 ["--pyro-port="+str(_pyomo_ns_port)]))

        time.sleep(2)
        [_poll(proc) for proc in _taskworker_processes]
예제 #8
0
def _setUpPyro():
    global _pyomo_ns_port
    global _pyomo_ns_process
    global _dispatch_srvr_port
    global _dispatch_srvr_process
    global _taskworker_processes
    if _pyomo_ns_process is None:
        _pyomo_ns_process, _pyomo_ns_port = \
            _get_test_nameserver(ns_host=_pyomo_ns_host)
    assert _pyomo_ns_process is not None
    if _dispatch_srvr_process is None:
        _dispatch_srvr_process, _dispatch_srvr_port = \
            _get_test_dispatcher(ns_host=_pyomo_ns_host,
                                 ns_port=_pyomo_ns_port)
    assert _dispatch_srvr_process is not None
    if len(_taskworker_processes) == 0:
        for i in range(3):
            outname = os.path.join(thisdir,
                                   "TestCapture_scenariotreeserver_" + \
                                   str(i+1) + ".out")
            with open(outname, "w") as f:
                _taskworker_processes.append(
                    subprocess.Popen(["scenariotreeserver", "--traceback"] + \
                                     ["--import-module="+thisfile] + \
                                     (["--verbose"] if _run_verbose else []) + \
                                     ["--pyro-host="+str(_pyomo_ns_host)] + \
                                     ["--pyro-port="+str(_pyomo_ns_port)],
                                     stdout=f,
                                     stderr=subprocess.STDOUT))
        time.sleep(2)
        [_poll(proc) for proc in _taskworker_processes]
예제 #9
0
 def _run_cmd_with_pyro(self, cmd, num_servers):
     ns_host = '127.0.0.1'
     ns_process = None
     dispatcher_process = None
     scenariotreeserver_processes = []
     try:
         ns_process, ns_port = \
             _get_test_nameserver(ns_host=ns_host)
         self.assertNotEqual(ns_process, None)
         dispatcher_process, dispatcher_port = \
             _get_test_dispatcher(ns_host=ns_host,
                                  ns_port=ns_port)
         self.assertNotEqual(dispatcher_process, None)
         scenariotreeserver_processes = []
         for i in range(num_servers):
             scenariotreeserver_processes.append(\
                 subprocess.Popen(["scenariotreeserver", "--traceback"] + \
                                  ["--pyro-host="+str(ns_host)] + \
                                  ["--pyro-port="+str(ns_port)]))
         cmd += " --scenario-tree-manager=pyro"
         cmd += " --pyro-host=" + ns_host
         cmd += " --pyro-port=" + str(ns_port)
         print("Testing command: "+cmd)
         time.sleep(2)
         [_poll(proc) for proc in scenariotreeserver_processes]
         _run_cmd(cmd, shell=True)
     finally:
         _kill(ns_process)
         _kill(dispatcher_process)
         [_kill(proc) for proc in scenariotreeserver_processes]
         if os.path.exists(os.path.join(thisDir,'Pyro_NS_URI')):
             try:
                 os.remove(os.path.join(thisDir,'Pyro_NS_URI'))
             except OSError:
                 pass
예제 #10
0
 def test_solve_distributed(self):
     ns_host = '127.0.0.1'
     ns_process = None
     dispatcher_process = None
     scenariotreeserver_processes = []
     try:
         ns_process, ns_port = \
             _get_test_nameserver(ns_host=ns_host)
         self.assertNotEqual(ns_process, None)
         dispatcher_process, dispatcher_port = \
             _get_test_dispatcher(ns_host=ns_host,
                                  ns_port=ns_port)
         self.assertNotEqual(dispatcher_process, None)
         scenariotreeserver_processes = []
         class_name, test_name = self.id().split('.')[-2:]
         for i in range(3):
             outname = os.path.join(
                 thisdir, class_name + "." + test_name +
                 ".scenariotreeserver_" + str(i + 1) + ".out")
             self._tempfiles.append(outname)
             with open(outname, "w") as f:
                 scenariotreeserver_processes.append(
                     subprocess.Popen(["scenariotreeserver", "--traceback"] + \
                                      ["--pyro-host="+str(ns_host)] + \
                                      ["--pyro-port="+str(ns_port)],
                                      stdout=f,
                                      stderr=subprocess.STDOUT))
         cmd = [
             sys.executable,
             join(examples_dir, 'solve_distributed.py'),
             str(ns_port)
         ]
         time.sleep(2)
         [_poll(proc) for proc in scenariotreeserver_processes]
         self._run_cmd(cmd)
     finally:
         _kill(ns_process)
         _kill(dispatcher_process)
         [_kill(proc) for proc in scenariotreeserver_processes]
         if os.path.exists(os.path.join(thisdir, 'Pyro_NS_URI')):
             try:
                 os.remove(os.path.join(thisdir, 'Pyro_NS_URI'))
             except OSError:
                 pass
     self._cleanup()
예제 #11
0
 def _run_cmd_with_pyro(self, cmd, num_servers):
     ns_host = '127.0.0.1'
     ns_process = None
     dispatcher_process = None
     scenariotreeserver_processes = []
     try:
         ns_process, ns_port = \
             _get_test_nameserver(ns_host=ns_host)
         self.assertNotEqual(ns_process, None)
         dispatcher_process, dispatcher_port = \
             _get_test_dispatcher(ns_host=ns_host,
                                  ns_port=ns_port)
         self.assertNotEqual(dispatcher_process, None)
         scenariotreeserver_processes = []
         class_name, test_name = self.id().split('.')[-2:]
         for i in range(num_servers):
             outname = os.path.join(
                 thisdir, class_name + "." + test_name +
                 ".scenariotreeserver_" + str(i + 1) + ".out")
             self._tempfiles.append(outname)
             with open(outname, "w") as f:
                 scenariotreeserver_processes.append(
                     subprocess.Popen(["scenariotreeserver", "--traceback"] + \
                                      ["--pyro-host="+str(ns_host)] + \
                                      ["--pyro-port="+str(ns_port)],
                                      stdout=f,
                                      stderr=subprocess.STDOUT))
         cmd.append("--scenario-tree-manager=pyro")
         cmd.append("--pyro-host=" + str(ns_host))
         cmd.append("--pyro-port=" + str(ns_port))
         time.sleep(2)
         [_poll(proc) for proc in scenariotreeserver_processes]
         self._run_cmd(cmd)
     finally:
         _kill(ns_process)
         _kill(dispatcher_process)
         [_kill(proc) for proc in scenariotreeserver_processes]
         if os.path.exists(os.path.join(thisdir, 'Pyro_NS_URI')):
             try:
                 os.remove(os.path.join(thisdir, 'Pyro_NS_URI'))
             except OSError:
                 pass
예제 #12
0
 def _run_cmd_with_pyro(self, cmd, num_servers):
     ns_host = '127.0.0.1'
     ns_process = None
     dispatcher_process = None
     scenariotreeserver_processes = []
     try:
         ns_process, ns_port = \
             _get_test_nameserver(ns_host=ns_host)
         self.assertNotEqual(ns_process, None)
         dispatcher_process, dispatcher_port = \
             _get_test_dispatcher(ns_host=ns_host,
                                  ns_port=ns_port)
         self.assertNotEqual(dispatcher_process, None)
         scenariotreeserver_processes = []
         class_name, test_name = self.id().split('.')[-2:]
         for i in range(num_servers):
             outname = os.path.join(thisdir,
                                    class_name+"."+test_name+".scenariotreeserver_"+str(i+1)+".out")
             self._tempfiles.append(outname)
             with open(outname, "w") as f:
                 scenariotreeserver_processes.append(
                     subprocess.Popen(["scenariotreeserver", "--traceback"] + \
                                      ["--pyro-host="+str(ns_host)] + \
                                      ["--pyro-port="+str(ns_port)],
                                      stdout=f,
                                      stderr=subprocess.STDOUT))
         cmd.append("--scenario-tree-manager=pyro")
         cmd.append("--pyro-host="+str(ns_host))
         cmd.append("--pyro-port="+str(ns_port))
         time.sleep(2)
         [_poll(proc) for proc in scenariotreeserver_processes]
         self._run_cmd(cmd)
     finally:
         _kill(ns_process)
         _kill(dispatcher_process)
         [_kill(proc) for proc in scenariotreeserver_processes]
         if os.path.exists(os.path.join(thisdir,'Pyro_NS_URI')):
             try:
                 os.remove(os.path.join(thisdir,'Pyro_NS_URI'))
             except OSError:
                 pass