Esempio n. 1
0
def process_state(datas, fails, stop, force, is_initializing, is_running, msg):
    ret = {
        "has_exited": False,
        "is_initializing": is_initializing,
        "is_running": is_running
    }
    status = datas['result']['status']

    if len(fails) > 0:
        if status != 'TERMINATED' and stop:
            print("\nStopping test, force={0}".format(force))
            tools.set_batch(True)
            running_tools.stop(datas["id"], force)
        ret["has_exited"] = True
    elif status == 'TERMINATED':
        ret["has_exited"] = True
    elif status == 'INIT':
        printif(not is_initializing, 'Initializing', end='')
        is_initializing = True
    elif status == 'RUNNING':
        printif(not is_running, '\nRunning', end='')
        is_running = True

    ret["is_initializing"] = is_initializing
    ret["is_running"] = is_running

    return ret
Esempio n. 2
0
def cli(name, force):
    if not name or name == "cur":
        name = user_data.get_meta(test_results.meta_key)
    if not name:
        raise cli_exception.CliException('No test id is provided')

    if not tools.is_id(name):
        name = test_results.__resolver.resolve_name(name)

    running_tools.stop(name, force)
Esempio n. 3
0
def process_state(datas, fails, fail_options, is_initializing, is_running):

    stop = fail_options['stop']
    force = fail_options['force']
    stop_command = fail_options['stop_command']

    ret = {
        "has_exited": False,
        "is_initializing": is_initializing,
        "is_running": is_running
    }
    status = datas['result']['status']

    if len(fails) > 0:
        if status != 'TERMINATED' and stop:
            if stop_command is not None:
                out = subprocess.run(stop_command,
                                     shell=True,
                                     capture_output=True)
                print(
                    f"\nStopping test with the system command {out.args}\n - return code={out.returncode}"
                )
                print(f" - stdout={out.stdout}\n - stderr={out.stderr}")
            else:
                print("\nStopping test, force={0}".format(force))
                tools.set_batch(True)
                running_tools.stop(datas["id"], force)
        ret["has_exited"] = True
    elif status == 'TERMINATED':
        ret["has_exited"] = True
    elif status == 'INIT':
        printif(not is_initializing, 'Initializing', end='')
        is_initializing = True
    elif status == 'RUNNING':
        printif(not is_running, '\nRunning', end='')
        is_running = True

    ret["is_initializing"] = is_initializing
    ret["is_running"] = is_running

    return ret