Exemplo n.º 1
0
def main():
    #Make sure logging stuff is bootstrapped
    try:
        option_parser.parse_options()
        option_parser.options.no_logging = True  #Don't log anything
        heHandle = None
        heAppRunner = None

        dcgm_structs._LoadDcgmLibrary()

        if g_embeddedMode:
            host = 0
        else:
            #Start host engine
            heAppRunner = apps.NvHostEngineApp()
            heAppRunner.start(timeout=1000000000)
            time.sleep(2.0)
            host = "127.0.0.1"

        heHandle = dcgm_agent.dcgmInit()

        pssObj = ProcessStatsStress(g_embeddedMode, heHandle)
        pssObj.Run()
        del (pssObj)  #Force destructor
        heAppRunner.wait()
    except Exception as e:
        raise
    finally:
        apps.AppRunner.clean_all()
        if heHandle is not None:
            dcgm_agent.dcgmShutdown()
Exemplo n.º 2
0
def test_logging_modules():
    """
    Verifies that module logging is functional
    """

    PASSED = "passed"
    FAILED = "FAILED"
    SKIPPED = "SKIPPED"

    result = FAILED

    nvhost_engine = apps.NvHostEngineApp()
    nvhost_engine.start(timeout=10)
    contents = None

    # Try for 5 seconds
    for i in range(25):
        time.sleep(0.2)
        with closing(open(nvhost_engine.dcgm_trace_fname)) as f:
            # pylint: disable=no-member
            contents = f.read()
            logger.debug("Read %d bytes from %s" %
                         (len(contents), nvhost_engine.dcgm_trace_fname))

            # NVSwitch module is loaded on startup. So we check for records from that module
            test_string = "Initialized logging for module 1"

            # Note that if --eris is passsed, we only log at WARNING level
            # If logging is not at DEBUG level, then skip the test
            if test_utils.loggingLevel != 'DEBUG':
                # Skipping in a roundabout way to ensure we terminate the processes we launch
                result = SKIPPED
                break
            if test_string in contents:
                result = PASSED
                break

    # Cleaning up
    nvhost_engine.terminate()
    nvhost_engine.validate()

    if (result == SKIPPED):
        test_utils.skip_test(
            "Detected logLevel = WARN. This test requires DEBUG. Likely cause: --eris option"
        )

    errorString = ""
    if (result != PASSED):
        if contents is not None:
            errorString = "Unable to find $test_string in log file"
        else:
            errorString = "log file %s was never read" % nvhost_engine.dcgm_trace_fname

    assert result == PASSED, errorString
Exemplo n.º 3
0
def test_logging_env_var():
    """
    Verifies that we log to the supplied env var
    """

    if test_utils.loggingLevel != 'DEBUG':
        test_utils.skip_test(
            "Detected logLevel != DEBUG. This test requires DEBUG. Likely cause: --eris option"
        )

    passed = False

    # Env var is automatically set in NvHostEngineApp
    nvhost_engine = apps.NvHostEngineApp()
    nvhost_engine.start(timeout=10)
    contents = None

    # Try for 5 seconds
    for i in range(25):
        time.sleep(0.2)
        with closing(open(nvhost_engine.dcgm_trace_fname,
                          encoding='utf-8')) as f:
            # pylint: disable=no-member
            contents = f.read()
            logger.debug("Read %d bytes from %s" %
                         (len(contents), nvhost_engine.dcgm_trace_fname))
            # This is checking two things:
            #   - that we are logging to the file specified in ENV
            #   - that we are setting severity according to ENV (DEBUG)
            if 'DEBUG' in contents:
                passed = True
                break

    # Cleaning up
    nvhost_engine.terminate()
    nvhost_engine.validate()

    errorString = ""
    if (not passed):
        if contents is not None:
            errorString = "Unable to find 'DEBUG' in log file"
        else:
            errorString = "log file %s was never read" % nvhost_engine.dcgm_trace_fname

    assert passed, errorString
Exemplo n.º 4
0
def test_logging_env_var():
    """
    Verifies that we log to the supplied env var
    """

    passed = False

    # Env var is automatically set in NvHostEngineApp
    nvhost_engine = apps.NvHostEngineApp()
    nvhost_engine.start(timeout=10)
    contents = None

    # Try for 5 seconds
    for i in range(25):
        time.sleep(0.2)
        with closing(open(nvhost_engine.dcgm_trace_fname)) as f:
            # pylint: disable=no-member
            contents = f.read()
            logger.debug("Read %d bytes from %s" %
                         (len(contents), nvhost_engine.dcgm_trace_fname))
            # This is checking two things:
            #   - that we are logging to the file specified in ENV
            #   - that we are setting severity according to ENV (DEBUG)
            # Note that if --eris is passsed in we only log at WARNING level, which is not guaranteed to generate any entries.
            # If logging is not at DEBUG level, then just make sure that we have a log file with contents.
            if test_utils.loggingLevel == 'DEBUG':
                if 'DEBUG' in contents:
                    passed = True
                    break
            elif len(contents) > 0:
                passed = True
                break

    # Cleaning up
    nvhost_engine.terminate()
    nvhost_engine.validate()

    errorString = ""
    if (not passed):
        if contents is not None:
            errorString = "Unable to find 'DEBUG' in log file"
        else:
            errorString = "log file %s was never read" % nvhost_engine.dcgm_trace_fname

    assert passed, errorString
Exemplo n.º 5
0
def test_nv_hostengine_app():
    """
    Verifies that nv-hostengine can be lauched properly and 
    can run for whatever timeout it's given in seconds
    """

    # Start nv-hostengine and run for 15 seconds
    nvhost_engine = apps.NvHostEngineApp()
    nvhost_engine.start(timeout=15)

    # Getting nv-hostenging process id
    pid = nvhost_engine.getpid()

    # Cleanning up
    time.sleep(5)
    nvhost_engine.terminate()
    nvhost_engine.validate()

    logger.debug("nv-hostengine PID was %d" % pid)