def pytest_configure(config): """Set default path for Selenium HTML report if explicit '--html=' not specified""" htmlpath = config.option.htmlpath if htmlpath is None: import os logdir = make_logdir(map_test_type_to_logdir('gui'), 'report') config.option.htmlpath = os.path.join(logdir, 'report.html')
def persistent_environment(request, env_description_abs_path): """ Sets up environment and returns environment description. """ logdir_path = map_test_type_to_logdir(get_test_type(request)) feature_name = request.module.__name__.split('.')[-1] logdir = make_logdir( logdir_path, os.path.join(get_file_name(env_description_abs_path), feature_name)) env_desc = run_env_up_script("env_up.py", config=env_description_abs_path, logdir=logdir, skip=False) # Make sure OP instances are connected to their zones before the test starts. print('Waiting for OZ connectivity of providers...') for op_node in env_desc['op_worker_nodes']: host = op_node.split("@")[1] ip = docker_ip(host) if not ensure_provider_oz_connectivity(ip): raise Exception( 'Could not ensure OZ connectivity of provider {0}'.format( host)) print('OZ connectivity established') def fin(): docker.remove(request.onedata_environment['docker_ids'], force=True, volumes=True) remove_symlinks(logdir) request.addfinalizer(fin) request.onedata_environment = env_desc return env_desc
def stop_profiling(op_worker, context, onedata_environment, request, providers): logdir = make_logdir(PROFILING_LOGDIR, request.function.func_name) erl_node = get_matching_op_erl_node(op_worker, onedata_environment) docker_name = erl_node.split('@')[1] stop_fprof(erl_node) copy_fprof_data(docker_name, logdir) convert_fprof_data(os.path.join(logdir, FPROF_DATA_FILE))
def setup_class(cls): logdir = make_logdir(ENV_UP_LOGDIR, get_file_name(__file__)) result = run_env_up_script("env_up.py", config=config_file('env.json'), logdir=logdir, skip=False) cls.result = result
def setup_class(cls): logdir = make_logdir(ENV_UP_LOGDIR, get_file_name(__file__)) cls.result = appmock.up(image='onedata/builder', bindir=APPMOCK_DIR, dns_server='none', uid=common.generate_uid(), config_path=os.path.join(config_file('env.json')), logdir=logdir)
def run_env_up_script(script, config=None, logdir=None, args=[], skip=True, retries=ENV_UP_RETRIES_NUMBER): """Runs given script to bring up test environment. Script must be located in docker_dir directory (see test_common.py) If script fails, functions skips test (if skip=True). """ cmd = [os.path.join(DOCKER_DIR, script)] if logdir: cmd.extend(['-l', logdir]) if args: cmd.extend(args) if config: cmd.append(config) output = "" try: output = retry_running_cmd_until(cmd, retries=retries) except Exception as e: if isinstance(e, subprocess.CalledProcessError): err_msg = e.output else: err_msg = str(e) if not logdir: # even if script doesn't have logdir option we want logs from # executing this script logdir = make_logdir(ENV_UP_DIR, script) logfile_error_path = os.path.join(logdir, PREPARE_ENV_ERROR_LOG_FILE) save_log_to_file(logfile_error_path, err_msg) msg = "{script} script failed because of {reason}"\ .format(script=script, reason=err_msg) pytest.skip(msg) if skip else pytest.fail(msg) stripped_output = strip_output_logs(output) # get dict from string output_dict = ast.literal_eval(stripped_output) if logdir: logfile_path = os.path.join(logdir, PREPARE_ENV_LOG_FILE) logfile = open(logfile_path, 'w') logfile.write(stripped_output) logfile.close() return output_dict
def persistent_environment(request, env_description_abs_path): """ Sets up environment and returns environment description. """ logdir_path = map_test_type_to_logdir(get_test_type(request)) feature_name = request.module.__name__.split('.')[-1] logdir = make_logdir(logdir_path, os.path .join(get_file_name(env_description_abs_path), feature_name)) env_desc = run_env_up_script("env_up.py", config=env_description_abs_path, logdir=logdir, skip=False) def fin(): docker.remove(request.onedata_environment['docker_ids'], force=True, volumes=True) request.addfinalizer(fin) request.onedata_environment = env_desc return env_desc
def persistent_environment(request, env_description_abs_path): """ Sets up environment and returns environment description. """ logdir_path = map_test_type_to_logdir(get_test_type(request)) feature_name = request.module.__name__.split('.')[-1] logdir = make_logdir( logdir_path, os.path.join(get_file_name(env_description_abs_path), feature_name)) env_desc = run_env_up_script("env_up.py", config=env_description_abs_path, logdir=logdir, skip=False) def fin(): docker.remove(request.onedata_environment['docker_ids'], force=True, volumes=True) request.addfinalizer(fin) request.onedata_environment = env_desc return env_desc