def setUp(self): # Clean the global registry of servers GLOBAL_REGISTRY.clear() CONSUMER_CONFIG_PATH = self.FEDERATED_DEPLOYMENTS + '/consumer/' PROVIDER1_CONFIG_PATH = self.FEDERATED_DEPLOYMENTS + '/provider1/' PROVIDER2_CONFIG_PATH = self.FEDERATED_DEPLOYMENTS + '/provider2/' self.consumer_handler = load_dir(CONSUMER_CONFIG_PATH).load_process('consumer_machine', 'main_instance' ) self.provider1_handler = load_dir(PROVIDER1_CONFIG_PATH).load_process('provider1_machine', 'main_instance' ) self.provider2_handler = load_dir(PROVIDER2_CONFIG_PATH).load_process('provider2_machine', 'main_instance' ) self.consumer_client = WebLabDeustoClient("http://127.0.0.1:%s/weblab/" % 18345) self.provider1_client = WebLabDeustoClient("http://127.0.0.1:%s/weblab/" % 28345) self.provider2_client = WebLabDeustoClient("http://127.0.0.1:%s/weblab/" % 38345) # dummy1: deployed in consumer, provider1, provider2 self.dummy1 = ExperimentId("dummy1", "Dummy experiments") # dummy2: deployed in consumer self.dummy2 = ExperimentId("dummy2", "Dummy experiments") # dummy3: deployed in provider1 as "dummy3_with_other_name" self.dummy3 = ExperimentId("dummy3", "Dummy experiments") # dummy4: deployed in provider2 self.dummy4 = ExperimentId("dummy4", "Dummy experiments")
def setUp(self): # Clean the global registry of servers GLOBAL_REGISTRY.clear() CONSUMER_CONFIG_PATH = self.FEDERATED_DEPLOYMENTS + '/consumer/' PROVIDER1_CONFIG_PATH = self.FEDERATED_DEPLOYMENTS + '/provider1/' PROVIDER2_CONFIG_PATH = self.FEDERATED_DEPLOYMENTS + '/provider2/' self.consumer_handler = load_dir(CONSUMER_CONFIG_PATH).load_process( 'consumer_machine', 'main_instance') self.provider1_handler = load_dir(PROVIDER1_CONFIG_PATH).load_process( 'provider1_machine', 'main_instance') self.provider2_handler = load_dir(PROVIDER2_CONFIG_PATH).load_process( 'provider2_machine', 'main_instance') self.consumer_client = WebLabDeustoClient( "http://127.0.0.1:%s/weblab/" % 18345) self.provider1_client = WebLabDeustoClient( "http://127.0.0.1:%s/weblab/" % 28345) self.provider2_client = WebLabDeustoClient( "http://127.0.0.1:%s/weblab/" % 38345) # dummy1: deployed in consumer, provider1, provider2 self.dummy1 = ExperimentId("dummy1", "Dummy experiments") # dummy2: deployed in consumer self.dummy2 = ExperimentId("dummy2", "Dummy experiments") # dummy3: deployed in provider1 as "dummy3_with_other_name" self.dummy3 = ExperimentId("dummy3", "Dummy experiments") # dummy4: deployed in provider2 self.dummy4 = ExperimentId("dummy4", "Dummy experiments")
def _start_weblab(self): """ Starts the instance and blocks while it is alive. It may take a while to actually start. You can check whether it is ready to process requests through is_ready. Meant to be called from the spawned thread. :return: """ # Load the configuration of the weblab instance that we have set up for just this test. self.global_config = load_dir("test/deployments/selenium_tests") # Override the port so that we can start & close it fast enough. port = ports.new() self.core_server_url = "http://127.0.0.1:{0}/weblab/".format(port) # TODO: The following two lines to modify the port currently do not work. # But they should. self.global_config["myhost"]["myprocess"]["mycore"].config_values["core_facade_port"] = port self.global_config["myhost"]["myprocess"]["mycore"].config_values["core_server_url"] = self.core_server_url # Start the weblab instance. The dont-start flag is set to False, so this call # WILL BLOCK and start the HTTP server. self.handler = self.global_config.load_process("myhost", "myprocess") """ type : voodoo.gen.handler.ProcessHandler """
def setUp(self): GLOBAL_REGISTRY.clear() """ Prepares the test by creating a new weblab instance from a for-testing configuration. The instance is configured *not* to start a flask server, but to allow Flask test methods instead. :return: """ # Load the configuration of the weblab instance that we have set up for just this test. self.global_config = load_dir('test/deployments/webclient_dummy') # Start the weblab instance. Because we have activated the dont-start flag it won't actually # start listening on the port, but let us use the Flask test methods instead. self.handler = self.global_config.load_process('myhost', 'myprocess') self.core_server = GLOBAL_REGISTRY['mycore:myprocess@myhost'] self.app = self.core_server.app.test_client() """ :type: flask.testing.FlaskClient """ # Login. rv = self.app.post('weblab/login', data=dict(username='******', password='******')) self.assertEqual(rv.status_code, 302, "Login POST for any / password does not return 302") # Clear REDIS. # TODO: These tests should probably start their own redis instance to avoid side-effects. compiserv._redis.delete("compiserv::jobs::20+abcdef")
def _start_weblab(self): """ Starts the instance and blocks while it is alive. It may take a while to actually start. You can check whether it is ready to process requests through is_ready. Meant to be called from the spawned thread. :return: """ # Load the configuration of the weblab instance that we have set up for just this test. self.global_config = load_dir('test/deployments/selenium_tests') # Override the port so that we can start & close it fast enough. port = ports.new() self.core_server_url = 'http://127.0.0.1:{0}/weblab/'.format(port) # TODO: The following two lines to modify the port currently do not work. # But they should. self.global_config['myhost']['myprocess']['mycore'].config_values['core_facade_port'] = port self.global_config['myhost']['myprocess']['mycore'].config_values[ 'core_server_url'] = self.core_server_url # Start the weblab instance. The dont-start flag is set to False, so this call # WILL BLOCK and start the HTTP server. self.handler = self.global_config.load_process('myhost', 'myprocess') """ type : voodoo.gen.handler.ProcessHandler """
def setUp(self): GLOBAL_REGISTRY.clear() """ Prepares the test by creating a new weblab instance from a for-testing configuration. The instance is configured *not* to start a flask server, but to allow Flask test methods instead. :return: """ # Load the configuration of the weblab instance that we have set up for just this test. self.global_config = load_dir('test/deployments/webclient_dummy') # Start the weblab instance. Because we have activated the dont-start flag it won't actually # start listening on the port, but let us use the Flask test methods instead. self.handler = self.global_config.load_process('myhost', 'myprocess') self.core_server = GLOBAL_REGISTRY['mycore:myprocess@myhost'] self.app = self.core_server.app.test_client() """ :type: flask.testing.FlaskClient """ # Login. rv = self.app.post('weblab/login', data=dict(username='******', password='******')) self.assertEqual(rv.status_code, 302, "Login POST for any / password does not return 302")
def start_test_weblab_deployment(self): # Load the configuration of the weblab instance that we have set up for just this test. self.global_config = load_dir('test/deployments/webclient_dummy') # Start the weblab instance. Because we have activated the dont-start flag it won't actually # start listening on the port, but let us use the Flask test methods instead. self.handler = self.global_config.load_process('myhost', 'myprocess') self.core_server = GLOBAL_REGISTRY['mycore:myprocess@myhost']
def launch(self): logging.config.fileConfig(self.logging_file_config) global_config = load_dir(self.config_dir) process_handler = global_config.load_process(self.host_name, self.process_name) try: self.notify_and_wait() finally: process_handler.stop()
def launch(self): logging.config.fileConfig( self.logging_file_config ) global_config = load_dir(self.config_dir) process_handler = global_config.load_process(self.host_name, self.process_name) try: self.notify_and_wait() finally: process_handler.stop()
def launch(self): global_configuration = load_dir(self.config_dir) host_configuration = global_configuration.get(self.host_name) if host_configuration is None: raise Exception("Machine %s not found" % self.host_name) os_processes = [] for process_name in host_configuration: if isinstance(self.logging_file_config, dict): logging_file_config = self.logging_file_config[process_name] else: logging_file_config = self.logging_file_config if self.debugger_ports is None: debugger_port = "None" else: debugger_port = self.debugger_ports.get(process_name, "None") args = ( sys.executable, "-OO", __file__, self.config_dir, self.host_name, process_name, logging_file_config, str(debugger_port) ) subprocess_kargs = dict( args = args, stdin = subprocess.PIPE ) os_process = process_starter.start_process((), subprocess_kargs) os_processes.append(os_process) self.notify_and_wait() if len(os_processes) > 0: for os_process in os_processes: try: os_process.terminate() except: pass self.wait_for_subprocesses(os_processes) if len(os_processes) > 0: for os_process in os_processes: os_process.kill() self.wait_for_subprocesses(os_processes)
def setUp(self): self.global_config = load_dir(self.DEPLOYMENT_DIR) self.process_handlers = [] for process in self.PROCESSES: process_handler = self.global_config.load_process('myhost', process) self.process_handlers.append(process_handler) self.core_server = GLOBAL_REGISTRY[self.CORE_ADDRESS] self.experiment_dummy1 = GLOBAL_REGISTRY[self.EXPERIMENT_DUMMY1] self.experiment_dummy2 = GLOBAL_REGISTRY[self.EXPERIMENT_DUMMY2] self.core_config = self.core_server.config self.client = WebLabDeustoClient('http://localhost:%s/weblab/' % self.core_config[configuration_doc.CORE_FACADE_PORT])
def setUp(self): self.global_config = load_dir(self.DEPLOYMENT_DIR) self.process_handlers = [] for process in self.PROCESSES: process_handler = self.global_config.load_process( 'myhost', process) self.process_handlers.append(process_handler) self.core_server = GLOBAL_REGISTRY[self.CORE_ADDRESS] self.experiment_dummy1 = GLOBAL_REGISTRY[self.EXPERIMENT_DUMMY1] self.experiment_dummy2 = GLOBAL_REGISTRY[self.EXPERIMENT_DUMMY2] self.core_config = self.core_server.config self.client = WebLabDeustoClient( 'http://localhost:%s/weblab/' % self.core_config[configuration_doc.CORE_FACADE_PORT])
def run_with_config(directory, func): check_dir_exists(directory) old_cwd = os.getcwd() os.chdir(directory) try: if os.path.exists(os.path.join('.', 'configuration.yml')): global_config = load_dir('.') configuration_files, configuration_values = global_config.get_all_config() elif os.path.exists(os.path.join('.', 'configuration.xml')): print("Loading old-style configuration...", file=sys.stderr) parser = LegacyParser() configuration_files = parser.get_config_files('.') configuration_values = [] else: print("ERROR: not a valid configuration directory. Missing configuration.yml (or configuration.xml)", file=sys.stderr) sys.exit(-1) return func('.', configuration_files, configuration_values) finally: os.chdir(old_cwd)
def setUp(self): GLOBAL_REGISTRY.clear() """ Prepares the test by creating a new weblab instance from a for-testing configuration. The instance is configured *not* to start a flask server, but to allow Flask test methods instead. :return: """ # Load the configuration of the weblab instance that we have set up for just this test. self.global_config = load_dir('test/deployments/webclient_dummy') # Start the weblab instance. Because we have activated the dont-start flag it won't actually # start listening on the port, but let us use the Flask test methods instead. self.handler = self.global_config.load_process('myhost', 'myprocess') self.core_server = GLOBAL_REGISTRY['mycore:myprocess@myhost'] self.app = self.core_server.app.test_client() """ :type: flask.testing.FlaskClient """
def run_with_config(directory, func): check_dir_exists(directory) old_cwd = os.getcwd() os.chdir(directory) try: if os.path.exists(os.path.join('.', 'configuration.yml')): global_config = load_dir('.') configuration_files, configuration_values = global_config.get_all_config( ) elif os.path.exists(os.path.join('.', 'configuration.xml')): print("Loading old-style configuration...", file=sys.stderr) parser = LegacyParser() configuration_files = parser.get_config_files('.') configuration_values = [] else: print( "ERROR: not a valid configuration directory. Missing configuration.yml (or configuration.xml)", file=sys.stderr) sys.exit(-1) return func('.', configuration_files, configuration_values) finally: os.chdir(old_cwd)
def setUp(self): GLOBAL_REGISTRY.clear() """ Prepares the test by creating a new weblab instance from a for-testing configuration. The instance is configured *not* to start a flask server, but to allow Flask test methods instead. :return: """ # Load the configuration of the weblab instance that we have set up for just this test. self.global_config = load_dir("test/deployments/webclient_dummy") # Start the weblab instance. Because we have activated the dont-start flag it won't actually # start listening on the port, but let us use the Flask test methods instead. self.handler = self.global_config.load_process("myhost", "myprocess") self.core_server = GLOBAL_REGISTRY["mycore:myprocess@myhost"] self.app = self.core_server.app.test_client() """ :type: flask.testing.FlaskClient """ # Login. rv = self.app.post("weblab/login", data=dict(username="******", password="******")) self.assertEqual(rv.status_code, 302, "Login POST for any / password does not return 302")
def weblab_start(directory): parser = OptionParser(usage="%prog start DIR [options]") parser.add_option('-m', '--host', '--machine', dest='host', default=None, metavar='HOST', help = 'If there is more than one host in the configuration, which one should be started.') parser.add_option('-l', '--list-hosts', '--list-machines', dest='list_hosts', action='store_true', default=False, help = 'List hosts.') parser.add_option('-s', '--script', dest='script', default=None, metavar='SCRIPT', help = 'If the runner option is not available, which script should be used.') options, args = parser.parse_args() check_dir_exists(directory, parser) if not run_with_config(directory, check_updated): print("Error: WebLab-Deusto instance outdated! You may have updated WebLab-Deusto recently. Run: weblab-admin.py upgrade %s" % directory, file=sys.stderr) sys.exit(-1) old_cwd = os.getcwd() os.chdir(directory) # Ensure we aren't already running. The check is not currently supported on Windows. if sys.platform.lower().startswith('win'): if os.path.exists("weblab.pid"): pid = int(open("weblab.pid").read()) running = check_pid(pid) if not running: os.remove("weblab.pid") else: print("Error: WebLab-Deusto instance seems to be running already!", file=sys.stderr) sys.exit(-1) try: if options.script: # If a script is provided, ignore the rest if os.path.exists(options.script): execfile(options.script) elif os.path.exists(os.path.join(old_cwd, options.script)): execfile(os.path.join(old_cwd, options.script)) else: print("Provided script %s does not exist" % options.script, file=sys.stderr) sys.exit(-1) else: global_configuration = load_dir('.') if options.list_hosts: for host in global_configuration: print(' - %s' % host) sys.exit(0) host_name = options.host if host_name is None: if len(global_configuration) == 1: host_name = global_configuration.keys()[0] else: print("System has more than one host (see -l). Please detail which host you want to start with the --host option.", file=sys.stderr) sys.exit(-1) if not host_name in global_configuration: print("Error: %s host does not exist. Use -l to see the list of existing hosts." % host_name, file=sys.stderr) sys.exit(-1) host_config = global_configuration[host_name] if host_config.runner is None: if os.path.exists('run.py'): execfile('run.py') else: print("No runner was specified, and run.py was not available. Please the -s argument to specify the script or add the <runner file='run.py'/> option in %s." % host_name, file=sys.stderr) sys.exit(-1) else: if os.path.exists(host_config.runner): execfile(host_config.runner) else: print("Misconfigured system. Machine %s points to %s which does not exist." % (host_name, os.path.abspath(host_config.runner)), file=sys.stderr) sys.exit(-1) finally: os.chdir(old_cwd)
def weblab_start(directory): parser = OptionParser(usage="%prog start DIR [options]") parser.add_option( '-m', '--host', '--machine', dest='host', default=None, metavar='HOST', help= 'If there is more than one host in the configuration, which one should be started.' ) parser.add_option('-l', '--list-hosts', '--list-machines', dest='list_hosts', action='store_true', default=False, help='List hosts.') parser.add_option( '-s', '--script', dest='script', default=None, metavar='SCRIPT', help= 'If the runner option is not available, which script should be used.') options, args = parser.parse_args() check_dir_exists(directory, parser) if not run_with_config(directory, check_updated): print( "Error: WebLab-Deusto instance outdated! You may have updated WebLab-Deusto recently. Run: weblab-admin.py upgrade %s" % directory, file=sys.stderr) sys.exit(-1) old_cwd = os.getcwd() os.chdir(directory) # Ensure we aren't already running. The check is not currently supported on Windows. if sys.platform.lower().startswith('win'): if os.path.exists("weblab.pid"): pid = int(open("weblab.pid").read()) running = check_pid(pid) if not running: os.remove("weblab.pid") else: print( "Error: WebLab-Deusto instance seems to be running already!", file=sys.stderr) sys.exit(-1) try: if options.script: # If a script is provided, ignore the rest if os.path.exists(options.script): execfile(options.script) elif os.path.exists(os.path.join(old_cwd, options.script)): execfile(os.path.join(old_cwd, options.script)) else: print("Provided script %s does not exist" % options.script, file=sys.stderr) sys.exit(-1) else: global_configuration = load_dir('.') if options.list_hosts: for host in global_configuration: print(' - %s' % host) sys.exit(0) host_name = options.host if host_name is None: if len(global_configuration) == 1: host_name = global_configuration.keys()[0] else: print( "System has more than one host (see -l). Please detail which host you want to start with the --host option.", file=sys.stderr) sys.exit(-1) if not host_name in global_configuration: print( "Error: %s host does not exist. Use -l to see the list of existing hosts." % host_name, file=sys.stderr) sys.exit(-1) host_config = global_configuration[host_name] if host_config.runner is None: if os.path.exists('run.py'): execfile('run.py') else: print( "No runner was specified, and run.py was not available. Please the -s argument to specify the script or add the <runner file='run.py'/> option in %s." % host_name, file=sys.stderr) sys.exit(-1) else: if os.path.exists(host_config.runner): execfile(host_config.runner) else: print( "Misconfigured system. Machine %s points to %s which does not exist." % (host_name, os.path.abspath(host_config.runner)), file=sys.stderr) sys.exit(-1) finally: os.chdir(old_cwd)