Ejemplo n.º 1
0
def test_logparser_with_no_fields_verbose():
    assert (
        logparser.main(["-v", "./not_existing_file.txt"])
        == " An error occurred while trying to parse './not_existing_file.txt'\n"
        + "Please ensure that you requested some fields or keys.\n"
        + "No field or key specified"
    )
Ejemplo n.º 2
0
def test_logparser_level_constraint_key():
    this_dir = os.path.dirname(os.path.abspath(__file__))
    logtoparse = os.path.join(this_dir, "fixtures", "log_sample.txt")
    assert (logparser.main(["-d", "-l", "DEBUG", "-k", "event",
                            logtoparse]) == """in GlideinWMSManifests publish
Finding fe slots matching condition: GLIDECLIENT_NAME.str.startswith("hep-example-com_hepcloud_decisionengine.")"""
            )
Ejemplo n.º 3
0
def test_logparser_with_invalid_file_verbose():
    output = logparser.main(["-v", "-f", "1", "./not_existing_file.txt"])
    assert output.startswith(
        " An error occurred while trying to parse './not_existing_file.txt'\n"
        "Please ensure that the log file name is correct."
    )
    assert "No such file or directory" in output
Ejemplo n.º 4
0
def test_logparser_field_constraint_key():
    this_dir = os.path.dirname(os.path.abspath(__file__))
    logtoparse = os.path.join(this_dir, "fixtures", "log_sample.txt")
    assert (
        logparser.main(["-d", "-c", "2 publisher", "-k", "event", logtoparse])
        == "No glideclient classads found to advertise"
    )
Ejemplo n.º 5
0
def test_logparser_field():
    this_dir = os.path.dirname(os.path.abspath(__file__))
    logtoparse = os.path.join(this_dir, "fixtures", "log_sample.txt")
    assert (logparser.main(["-d", "-v", "-f", "1,2",
                            logtoparse]) == """channel,fe_group_classads
channel,fe_group_classads
channel,fe_group_classads
channel,publisher
channel,glide_frontend_element
channel,glide_frontend_element
channel,glide_frontend_element
channel,glide_frontend_element
channel,glide_frontend_element
NOT_AVAILABLE,NOT_AVAILABLE""")
Ejemplo n.º 6
0
def test_logparser_key():
    this_dir = os.path.dirname(os.path.abspath(__file__))
    logtoparse = os.path.join(this_dir, "fixtures", "log_sample.txt")
    assert (logparser.main(["-d", "-v", "-k", "event",
                            logtoparse]) == """in GlideinWMSManifests publish
Facts available in publisher GlideinWMSManifests: [{'rule_name': 'publish_aws_requests', 'fact_name': 'allow_aws_requests', 'fact_value': True}, {'rule_name': 'publish_gce_requests', 'fact_name': 'allow_gce_requests', 'fact_value': False}, {'rule_name': 'publish_grid_requests', 'fact_name': 'allow_grid_requests', 'fact_value': True}, {'rule_name': 'publish_lcf_requests', 'fact_name': 'allow_lcf_requests', 'fact_value': True}]
Setting ReqIdleGlideins=0 for fact: allow_gce_requests
No glideclient classads found to advertise
Finding fe slots matching condition: GLIDECLIENT_NAME.str.startswith("hep-example-com_hepcloud_decisionengine.")
Jobs found total 2 idle 2 (good 2, old(10min 2, 60min 2), grid 2, voms 2) running 0
Group slots found total 0 (limit 60000 curb 59000) idle 0 (limit 60000 curb 59000) running 0
Frontend slots found total 260 (limit 170000 curb 167000) idle 260 (limit 35000 curb 25000) running 0
NOT_AVAILABLE
Frontend slots found total 260 (limit 170000 curb 167000) idle 260 (limit 35000 curb 25000) running 0"""
            )
Ejemplo n.º 7
0
def test_logparser_field_key_separators():
    this_dir = os.path.dirname(os.path.abspath(__file__))
    logtoparse = os.path.join(this_dir, "fixtures", "log_sample.txt")
    assert (logparser.main([
        "-d", "-v", "-s", ";", "-i", "- ", "-f", "1,2", "-k", "level",
        logtoparse
    ]) == """channel ;fe_group_classads ;debug
channel ;fe_group_classads ;info
channel ;fe_group_classads ;info
channel ;publisher ;info
channel ;glide_frontend_element ;debug
channel ;glide_frontend_element ;info
channel ;glide_frontend_element ;info
channel ;glide_frontend_element ;info
channel ;glide_frontend_element ;NOT_AVAILABLE
NOT_AVAILABLE;NOT_AVAILABLE;info""")
Ejemplo n.º 8
0
def test_logparser_with_invalid_file():
    assert (logparser.main([
        "-f", "1", "./not_existing_file.txt"
    ]) == "An error occurred while trying to parse './not_existing_file.txt'\n"
            + "Please ensure that the log file name is correct.")