Ejemplo n.º 1
0
def display_project(res):
    if 299 > res.status_code > 199:
        tools.print_json(res.json())
    else:
        print(res.text)
        raise cli_exception.CliException("Error during get meta data code: " +
                                         res.status_code)
Ejemplo n.º 2
0
def cli(name_or_id, scenario, detached, name, description, as_code, web_vu,
        sap_vu, citrix_vu, return_0):
    """run a test"""
    if not name_or_id or name_or_id == "cur":
        name_or_id = user_data.get_meta(test_settings.meta_key)

    is_id = tools.is_id(name_or_id)
    test_settings_json = tools.get_named_or_id(name_or_id, is_id,
                                               test_settings.__resolver)
    _id = test_settings_json['id']

    if scenario:
        rest_crud.patch('v2/test_result/' + _id, {'scenarioName': scenario})

    naming_pattern = name if name else test_settings_json[
        'testResultNamingPattern']
    if not naming_pattern:
        naming_pattern = "#${runID}"
    naming_pattern = naming_pattern.replace(
        '${runID}', str(test_settings_json['nextRunId']))

    # Sorry for that, post data are in the query string :'( :'(
    post_result = rest_crud.post(
        'v2/tests/%s/start?%s' %
        (_id,
         create_data(naming_pattern, description, as_code, web_vu, sap_vu,
                     citrix_vu)), {})
    user_data.set_meta(test_settings.meta_key, _id)
    user_data.set_meta(test_results.meta_key, post_result['resultId'])
    if not detached:
        running_tools.wait(post_result['resultId'], not return_0)
    else:
        tools.print_json(post_result)
Ejemplo n.º 3
0
def cli(name_or_id, static_dynamic, human):
    """read of NeoLoad Web zones"""
    resp = rest_crud.get("/v2/resources/zones")
    resp = [
        elem for elem in resp
        if filter_result(elem, name_or_id, static_dynamic)
    ]
    if human:
        print_human(resp)
    else:
        tools.print_json(resp)
Ejemplo n.º 4
0
def cli(name_or_id, static_dynamic, human):
    """read of NeoLoad Web zones"""
    rest_crud.set_current_command()
    resp = get_zones()
    resp = [
        elem for elem in resp
        if filter_result(elem, name_or_id, static_dynamic)
    ]
    if human:
        print_human(resp)
    else:
        tools.print_json(resp)
Ejemplo n.º 5
0
def cli(name_or_id, scenario, detached, name, description, as_code, web_vu,
        sap_vu, citrix_vu, return_0):
    """run a test"""
    rest_crud.set_current_command()
    if not name_or_id or name_or_id == "cur":
        name_or_id = user_data.get_meta(test_settings.meta_key)

    is_id = tools.is_id(name_or_id)
    test_settings_json = tools.get_named_or_id(name_or_id, is_id,
                                               test_settings.__resolver)
    _id = test_settings_json['id']

    if scenario:
        rest_crud.patch(test_settings.get_end_point(_id),
                        {'scenarioName': scenario})

    naming_pattern = name if name else test_settings_json[
        'testResultNamingPattern']
    if not naming_pattern:
        naming_pattern = "#${runID}"
    naming_pattern = naming_pattern.replace(
        '${runID}', str(test_settings_json['nextRunId']))

    hooks.trig("test.start", test_settings_json)

    # Sorry for that, post data are in the query string :'( :'(
    post_result = rest_crud.post(
        test_settings.get_end_point(_id) + '/start?' + create_data(
            naming_pattern, description, as_code, web_vu, sap_vu, citrix_vu),
        {})
    user_data.set_meta(test_settings.meta_key, _id)
    user_data.set_meta(test_results.meta_key, post_result['resultId'])
    # Wait 5 seconds until the test result is created.
    time.sleep(5)
    if not detached:
        running_tools.wait(post_result['resultId'], not return_0)
    else:
        tools.print_json(post_result)
Ejemplo n.º 6
0
def delete(__id):
    rep = tools.delete(__endpoint, __id, "settings")
    tools.print_json(rep.json())
    user_data.set_meta(meta_key, None)
Ejemplo n.º 7
0
def print_result_summary(json_result, sla_json_global, sla_json_test, sla_json_interval, json_stats):
    __print_sla(sla_json_global, sla_json_test, sla_json_interval)
    tools.print_json({
        'result': json_result,
        'statistics': json_stats
    })