示例#1
0
def test_health_retry_sleep_modification(accelize_drm, conf_json, cred_json,
                                         async_handler, live_server, request,
                                         log_file_factory):
    """
    Test the asynchronous health retry sleep value when changed dynamically.
    """
    driver = accelize_drm.pytest_fpga_driver[0]
    async_cb = async_handler.create()
    async_cb.reset()

    conf_json.reset()
    conf_json['licensing']['url'] = _request.url + request.function.__name__
    logfile = log_file_factory.create(2)
    conf_json['settings'].update(logfile.json)
    conf_json.save()

    healthPeriod = 3
    healthRetry = 10
    healthRetrySleep = 1
    nb_run = 3

    for i in range(nb_run):

        health_retry_sleep = healthRetrySleep + i

        # Set initial context on the live server
        context = {
            'data': list(),
            'healthPeriod': healthPeriod,
            'healthRetry': healthRetry,
            'healthRetrySleep': health_retry_sleep,
            'exit': False
        }
        set_context(context)
        assert get_context() == context

        with accelize_drm.DrmManager(conf_json.path, cred_json.path,
                                     driver.read_register_callback,
                                     driver.write_register_callback,
                                     async_cb.callback) as drm_manager:
            drm_manager.activate()
            wait_func_true(lambda: get_context()['exit'],
                           timeout=(healthRetry + healthRetry) * 2)
            drm_manager.deactivate()

        async_cb.assert_NoError()
        data_list = get_context()['data']
        data0 = data_list.pop(0)
        nb_sleep_prev = 0
        # Check the retry sleep period is correct
        for health_id, group in groupby(data_list, lambda x: x[0]):
            group = list(group)
            assert len(group) > nb_sleep_prev
            nb_sleep_prev = len(group)
            start = group.pop(0)[2]
            for _, lstart, lend in group:
                delta = parser.parse(lstart) - parser.parse(start)
                assert int(delta.total_seconds()) == health_retry_sleep
                start = lend
        assert get_proxy_error() is None
示例#2
0
def test_run_for_a_period_of_time(accelize_drm, conf_json, cred_json, async_handler):
    driver = accelize_drm.pytest_fpga_driver[0]
    async_cb = async_handler.create()
    async_cb.reset()

    period = 60
    try:
        period = accelize_drm.pytest_params['period']
    except:
        pass
    print('Using parameter "period"=%d' % period)

    with accelize_drm.DrmManager(
            conf_json.path,
            cred_json.path,
            driver.read_register_callback,
            driver.write_register_callback,
            async_cb.callback
        ) as drm_manager:
        assert not drm_manager.get('license_status')
        drm_manager.activate()
        assert drm_manager.get('license_status')
        try:
            wait_func_true(lambda: not drm_manager.get('license_status'), timeout=period, sleep_time=1)
        except RuntimeError:
            pass
        drm_manager.deactivate()
        assert not drm_manager.get('license_status')
    async_cb.assert_NoError()
示例#3
0
def test_long_to_short_retry_switch_on_authentication(accelize_drm, conf_json,
                                                      cred_json, async_handler,
                                                      live_server, request):
    """
    Test the number of expected retries and the gap between 2 retries
    on authentication requests occurring in the background thread
    """
    driver = accelize_drm.pytest_fpga_driver[0]
    async_cb = async_handler.create()
    async_cb.reset()

    expires_in = 1
    retryShortPeriod = 3
    retryLongPeriod = 10
    timeoutSecond = 25

    conf_json.reset()
    conf_json['licensing']['url'] = _request.url + request.function.__name__
    conf_json['settings']['ws_retry_period_short'] = retryShortPeriod
    conf_json['settings']['ws_retry_period_long'] = retryLongPeriod
    conf_json.save()

    with accelize_drm.DrmManager(conf_json.path, cred_json.path,
                                 driver.read_register_callback,
                                 driver.write_register_callback,
                                 async_cb.callback) as drm_manager:
        context = {
            'data': list(),
            'cnt': 0,
            'expires_in': expires_in,
            'timeoutSecond': timeoutSecond,
            'exit': False
        }
        set_context(context)
        assert get_context() == context
        drm_manager.activate()
        wait_func_true(lambda: async_cb.was_called, timeout=timeoutSecond * 2)
        context = get_context()
        context['exit'] = True
        set_context(context)
        assert get_context() == context
        drm_manager.deactivate()
    assert async_cb.was_called
    assert async_cb.errcode == accelize_drm.exceptions.DRMWSTimedOut.error_code
    assert search(r'Timeout on Authentication request after', async_cb.message,
                  IGNORECASE)
    context = get_context()
    data_list = context['data']
    data = data_list.pop(0)
    data = data_list.pop(-1)
    assert len(data_list) >= 3
    data = data_list.pop(0)
    prev_lic = parser.parse(data[1])
    for start, end in data_list:
        lic_delta = int((parser.parse(start) - prev_lic).total_seconds())
        prev_lic = parser.parse(end)
        if lic_delta > retryShortPeriod:
            assert (retryLongPeriod - 1) <= lic_delta <= retryLongPeriod
        else:
            assert (retryShortPeriod - 1) <= lic_delta <= retryShortPeriod
示例#4
0
def test_log_file_directory_creation(accelize_drm, conf_json, cred_json,
                                     async_handler):
    """ Test the non existing sub-directories in the log file path are created by the DRMLib """
    driver = accelize_drm.pytest_fpga_driver[0]
    async_cb = async_handler.create()
    log_type = 1
    log_dir = realpath(
        expanduser('~/tmp_log_dir.%s.%d' %
                   (str(time()), randrange(0xFFFFFFFF))))
    if not isdir(log_dir):
        makedirs(log_dir)
    log_path = join(log_dir, 'tmp', "drmlib.%d.%s.log" % (getpid(), time()))
    try:
        assert isdir(log_dir)
        assert access(log_dir, W_OK)
        async_cb.reset()
        conf_json.reset()
        conf_json['settings']['log_file_path'] = log_path
        conf_json['settings']['log_file_type'] = log_type
        conf_json.save()
        with accelize_drm.DrmManager(conf_json.path, cred_json.path,
                                     driver.read_register_callback,
                                     driver.write_register_callback,
                                     async_cb.callback) as drm_manager:
            pass
        wait_func_true(lambda: isfile(log_path), 10)
    finally:
        if isdir(log_dir):
            rmtree(log_dir)
示例#5
0
def test_health_retry_modification(accelize_drm, conf_json, cred_json,
                                   async_handler, live_server, request,
                                   log_file_factory):
    """
    Test the asynchronous health retry can be modified dynamically.
    """
    driver = accelize_drm.pytest_fpga_driver[0]
    async_cb = async_handler.create()
    async_cb.reset()

    conf_json.reset()
    conf_json['licensing']['url'] = _request.url + request.function.__name__
    logfile = log_file_factory.create(2)
    conf_json['settings'].update(logfile.json)
    conf_json.save()

    healthPeriod = 3
    healthRetry = 10
    healthRetrySleep = 1
    nb_run = 3

    for i in range(nb_run):

        retry_timeout = healthRetry + 5 * i

        # Set initial context on the live server
        context = {
            'data': list(),
            'healthPeriod': healthPeriod,
            'healthRetry': retry_timeout,
            'healthRetrySleep': healthRetrySleep,
            'exit': False
        }
        set_context(context)
        assert get_context() == context

        with accelize_drm.DrmManager(conf_json.path, cred_json.path,
                                     driver.read_register_callback,
                                     driver.write_register_callback,
                                     async_cb.callback) as drm_manager:
            drm_manager.activate()
            wait_func_true(lambda: get_context()['exit'],
                           timeout=(retry_timeout + 3) * 2)
            drm_manager.deactivate()
            error_gap = drm_manager.get('health_retry_sleep') + 1

        async_cb.assert_NoError()
        data_list = get_context()['data']
        data0 = data_list.pop(0)
        assert len(data_list) > 1
        assert data0[0] == 0
        # Check health_id is unchanged during the retry period
        assert sum(map(lambda x: x[0], data_list)) == len(data_list)
        # Check the retry period is correct
        start = data_list[0][1]
        end = data_list[-1][2]
        delta = parser.parse(end) - parser.parse(start)
        assert retry_timeout - error_gap <= int(
            delta.total_seconds()) <= retry_timeout + error_gap
        assert get_proxy_error() is None
示例#6
0
 def wait_and_check_on_next_health(drm):
     next_health_id = get_context()['health_id'] + 1
     wait_func_true(
         lambda: get_context()['health_id'] >= next_health_id)
     session_id = drm.get('session_id')
     saas_data = ws_admin.get_last_metering_information(session_id)
     assert saas_data['session'] == session_id
     assert saas_data['metering'] == sum(drm.get('metered_data'))
示例#7
0
def test_long_to_short_retry_switch_on_license(accelize_drm, conf_json,
                                               cred_json, async_handler,
                                               live_server, request):
    """
    Test the number of expected retries and the gap between 2 retries
    on license requests occurring in the background thread
    """
    driver = accelize_drm.pytest_fpga_driver[0]
    async_cb = async_handler.create()
    async_cb.reset()

    retryShortPeriod = 3
    retryLongPeriod = 10
    timeoutSecond = 25

    conf_json.reset()
    conf_json['licensing']['url'] = _request.url + request.function.__name__
    conf_json['settings']['ws_retry_period_short'] = retryShortPeriod
    conf_json['settings']['ws_retry_period_long'] = retryLongPeriod
    conf_json.save()

    context = {'data': list(), 'cnt': 0, 'timeoutSecond': timeoutSecond}
    set_context(context)
    assert get_context() == context

    with accelize_drm.DrmManager(conf_json.path, cred_json.path,
                                 driver.read_register_callback,
                                 driver.write_register_callback,
                                 async_cb.callback) as drm_manager:
        drm_manager.activate()
        lic_duration = drm_manager.get('license_duration')
        wait_func_true(lambda: async_cb.was_called,
                       timeout=lic_duration + 2 * timeoutSecond)
        drm_manager.deactivate()
    assert async_cb.was_called
    assert 'Timeout on License' in async_cb.message
    assert async_cb.errcode == accelize_drm.exceptions.DRMWSTimedOut.error_code
    context = get_context()
    data_list = context['data']
    data = data_list.pop(0)
    data = data_list.pop(-1)
    assert len(data_list) >= 3
    data = data_list.pop(0)
    assert data[0] == 'running'
    prev_lic = parser.parse(data[2])
    for type, start, end in data_list:
        assert type == 'running'
        lic_delta = int((parser.parse(start) - prev_lic).total_seconds())
        prev_lic = parser.parse(end)
        if lic_delta > retryShortPeriod:
            assert (retryLongPeriod - 1) <= lic_delta <= retryLongPeriod
        else:
            assert (retryShortPeriod - 1) <= lic_delta <= retryShortPeriod
示例#8
0
def test_health_period_disabled(accelize_drm, conf_json, cred_json,
                                async_handler, live_server, log_file_factory,
                                request):
    """
    Test the asynchronous health feature can be disabled.
    """
    driver = accelize_drm.pytest_fpga_driver[0]
    async_cb = async_handler.create()
    async_cb.reset()

    conf_json.reset()
    conf_json['licensing']['url'] = _request.url + request.function.__name__
    logfile = log_file_factory.create(1)
    conf_json['settings'].update(logfile.json)
    conf_json.save()

    # Set initial context on the live server
    nb_health = 2
    healthPeriod = 2
    context = {
        'cnt': 0,
        'healthPeriod': healthPeriod,
        'nb_health': nb_health,
        'exit': False
    }
    set_context(context)
    assert get_context() == context

    with accelize_drm.DrmManager(conf_json.path, cred_json.path,
                                 driver.read_register_callback,
                                 driver.write_register_callback,
                                 async_cb.callback) as drm_manager:
        drm_manager.activate()
        assert drm_manager.get('health_period') == healthPeriod
        wait_func_true(lambda: get_context()['exit'],
                       timeout=healthPeriod * (nb_health + 1) * 2)
        assert drm_manager.get('health_period') == 0
        assert get_context()['cnt'] == nb_health
        sleep(healthPeriod + 1)
        assert get_context()['cnt'] == nb_health
        drm_manager.deactivate()
    log_content = logfile.read()
    assert search(r'Exiting background thread which checks health',
                  log_content, MULTILINE)
    assert search(r'Health thread is disabled', log_content, MULTILINE)
    assert search(r'Exiting background thread which checks health',
                  log_content, MULTILINE)
    health_req = findall(r'"request"\s*:\s*"health"', log_content)
    assert len(list(health_req)) == nb_health
    assert get_proxy_error() is None
    async_cb.assert_NoError()
    logfile.remove()
示例#9
0
def test_health_retry_disabled(accelize_drm, conf_json, cred_json,
                               async_handler, live_server, request,
                               log_file_factory):
    """
    Test the asynchronous health retry feature can be disabled.
    """
    driver = accelize_drm.pytest_fpga_driver[0]
    async_cb = async_handler.create()
    async_cb.reset()

    conf_json.reset()
    conf_json['licensing']['url'] = _request.url + request.function.__name__
    logfile = log_file_factory.create(2)
    conf_json['settings'].update(logfile.json)
    conf_json.save()

    with accelize_drm.DrmManager(conf_json.path, cred_json.path,
                                 driver.read_register_callback,
                                 driver.write_register_callback,
                                 async_cb.callback) as drm_manager:

        # Set initial context on the live server
        nb_health = 2
        healthPeriod = 3
        healthRetrySleep = 1
        context = {
            'data': list(),
            'healthPeriod': healthPeriod,
            'healthRetrySleep': healthRetrySleep
        }
        set_context(context)
        assert get_context() == context

        drm_manager.activate()
        wait_func_true(lambda: len(get_context()['data']) >= nb_health,
                       timeout=(healthPeriod + 3) * (nb_health + 2))
        drm_manager.deactivate()
    async_cb.assert_NoError()
    data_list = get_context()['data']
    assert len(data_list) >= nb_health
    # Check there is no duplicated health_id
    id_list = tuple(map(lambda x: x[0], data_list))
    assert id_list == tuple(set(id_list))
    # Check the time between 2 period
    wait_start = data_list.pop(0)[2]
    for hid, start, end in data_list:
        delta = parser.parse(start) - parser.parse(wait_start)
        assert int(delta.total_seconds()) == healthPeriod
        wait_start = end
    assert get_proxy_error() is None
示例#10
0
def test_health_period_modification(accelize_drm, conf_json, cred_json,
                                    async_handler, live_server, request,
                                    log_file_factory):
    """
    Test the asynchronous health feature can be modified dynamically.
    """
    driver = accelize_drm.pytest_fpga_driver[0]
    async_cb = async_handler.create()
    async_cb.reset()

    conf_json.reset()
    conf_json['licensing']['url'] = _request.url + request.function.__name__
    logfile = log_file_factory.create(2)
    conf_json['settings'].update(logfile.json)
    conf_json.save()

    # Set initial context on the live server
    nb_health = 4
    healthPeriod = 2
    healthRetry = 0  # no retry
    healthRetrySleep = 1
    context = {
        'data': list(),
        'healthPeriod': healthPeriod,
        'healthRetry': healthRetry,
        'healthRetrySleep': healthRetrySleep
    }
    set_context(context)
    assert get_context() == context

    with accelize_drm.DrmManager(conf_json.path, cred_json.path,
                                 driver.read_register_callback,
                                 driver.write_register_callback,
                                 async_cb.callback) as drm_manager:
        drm_manager.activate()
        wait_func_true(lambda: len(get_context()['data']) >= nb_health,
                       timeout=(healthPeriod + 3) * (nb_health + 2))
        drm_manager.deactivate()
    async_cb.assert_NoError()
    data_list = get_context()['data']
    assert len(data_list) >= nb_health
    wait_start = data_list.pop(0)[1]
    for i, (start, end) in enumerate(data_list):
        delta = parser.parse(start) - parser.parse(wait_start)
        assert int(delta.total_seconds()) == healthPeriod + i
        wait_start = end
    assert get_proxy_error() is None
示例#11
0
def test_topic0_corrupted_segment_index(accelize_drm, conf_json, cred_json,
                    async_handler, live_server, request):
    """
    Test to reproduce the issue that corrupts the segment ID with
    both async and syn requests.
    !!! CAUTION: THIS TEST ENDS CORRECTLY ONLY WHEN AN ERROR IS HIT !!!
    !!!          IT SHOULD NOT BE PART OF A NORMAL REGRESSION !!!
    """
    driver = accelize_drm.pytest_fpga_driver[0]
    async_cb = async_handler.create()
    async_cb.reset()

    conf_json.reset()
    conf_json['licensing']['url'] = _request.url + request.function.__name__
    conf_json.save()

    with accelize_drm.DrmManager(
            conf_json.path,
            cred_json.path,
            driver.read_register_callback,
            driver.write_register_callback,
            async_cb.callback
        ) as drm_manager:

        # Set initial context on the live server
        healthPeriod = 10
        context = {'error':0,
                   'healthPeriod':healthPeriod
        }
        set_context(context)
        assert get_context() == context

        drm_manager.activate()
        wait_func_true(lambda: get_context()['error'], timeout=60)
        drm_manager.deactivate()
    async_cb.assert_NoError()
示例#12
0
def test_thread_retry_on_lost_connection(accelize_drm, conf_json, cred_json,
                                         async_handler, live_server,
                                         log_file_factory, request):
    """
    Test the number of expected retries and the gap between 2 retries
    are correct when the requests are lost on the background thread
    """
    driver = accelize_drm.pytest_fpga_driver[0]
    async_cb = async_handler.create()
    async_cb.reset()

    retryShortPeriod = 2
    retryLongPeriod = 20
    licDuration = 60
    requestTimeout = 5

    nb_long_retry = ceil(
        (licDuration - retryLongPeriod - 2 * retryShortPeriod) /
        (retryLongPeriod + requestTimeout))
    nb_short_retry = ceil(
        (licDuration - nb_long_retry * (retryLongPeriod + requestTimeout)) /
        (retryShortPeriod + requestTimeout))
    nb_retry = nb_long_retry + nb_short_retry

    conf_json.reset()
    conf_json['licensing']['url'] = _request.url + request.function.__name__
    conf_json['settings']['ws_retry_period_short'] = retryShortPeriod
    conf_json['settings']['ws_retry_period_long'] = retryLongPeriod
    conf_json['settings']['ws_request_timeout'] = requestTimeout
    logfile = log_file_factory.create(1)
    conf_json['settings'].update(logfile.json)
    conf_json.save()

    context = {'cnt': 0, 'timeoutSecond': licDuration}
    set_context(context)
    assert get_context() == context

    with accelize_drm.DrmManager(conf_json.path, cred_json.path,
                                 driver.read_register_callback,
                                 driver.write_register_callback,
                                 async_cb.callback) as drm_manager:
        drm_manager.activate()
        wait_func_true(lambda: async_cb.was_called, timeout=licDuration * 2)
        drm_manager.deactivate()
    assert async_cb.was_called
    assert async_cb.errcode == accelize_drm.exceptions.DRMWSTimedOut.error_code
    m = search(r'Timeout on License request after (\d+) attempts',
               async_cb.message)
    assert m is not None
    nb_attempts = int(m.group(1))
    assert nb_retry == nb_attempts
    log_content = logfile.read()
    attempts_list = [
        int(e) for e in findall(
            r'Attempt #(\d+) to obtain a new License failed with message',
            log_content)
    ]
    assert len(attempts_list) == nb_retry
    assert sorted(list(attempts_list)) == list(range(1, nb_retry + 1))
    logfile.remove()
    async_cb.assert_Error(accelize_drm.exceptions.DRMWSTimedOut.error_code,
                          HTTP_TIMEOUT_ERR_MSG)
    async_cb.reset()
示例#13
0
def test_metered_pause_resume_long_time(accelize_drm, conf_json, cred_json, async_handler, log_file_factory):
    """
    Test no error occurs in normal start/stop metering mode during a long period of time
    """
    driver = accelize_drm.pytest_fpga_driver[0]
    async_cb = async_handler.create()
    async_cb.reset()
    activators = accelize_drm.pytest_fpga_activators[0]
    activators.reset_coin()
    activators.autotest()
    cred_json.set_user('accelize_accelerator_test_02')
    logfile = log_file_factory.create(2)
    conf_json['settings'].update(logfile.json)
    conf_json.save()

    with accelize_drm.DrmManager(
                conf_json.path,
                cred_json.path,
                driver.read_register_callback,
                driver.write_register_callback,
                async_cb.callback
            ) as drm_manager:
        nb_pause_resume = 2
        assert not drm_manager.get('session_status')
        assert not drm_manager.get('license_status')
        activators.autotest(is_activated=False)
        async_cb.assert_NoError()
        drm_manager.activate()
        start = datetime.now()
        assert sum(drm_manager.get('metered_data')) == 0
        assert drm_manager.get('session_status')
        assert drm_manager.get('license_status')
        session_id = drm_manager.get('session_id')
        assert len(session_id) > 0
        lic_duration = drm_manager.get('license_duration')
        wait_numbers = [lic_duration*2-2,lic_duration*2+2]
        activators.autotest(is_activated=True)
        for i in range(nb_pause_resume):
            activators.generate_coin()
            activators.check_coin(drm_manager.get('metered_data'))
            wait_func_true(lambda: drm_manager.get('num_license_loaded') == 2, 10)
            drm_manager.deactivate(True)
            async_cb.assert_NoError()
            assert drm_manager.get('session_status')
            assert drm_manager.get('license_status')
            assert drm_manager.get('session_id') == session_id
            # Wait randomly at the limit of the expiration
            random_wait = choice(wait_numbers)
            wait_deadline(start, random_wait)
            drm_manager.activate(True)
            if random_wait > lic_duration*2:
                start = datetime.now()
                assert drm_manager.get('session_id') != session_id
                activators.reset_coin()
                session_id = drm_manager.get('session_id')
            else:
                start += timedelta(seconds=lic_duration)
                assert drm_manager.get('session_id') == session_id, 'after loop #%d' % i
        assert drm_manager.get('session_status')
        assert drm_manager.get('session_id') == session_id
        assert drm_manager.get('license_status')
        activators.autotest(is_activated=True)
        drm_manager.deactivate()
        assert not drm_manager.get('session_status')
        assert not drm_manager.get('license_status')
        activators.autotest(is_activated=False)
        assert drm_manager.get('session_id') != session_id
        async_cb.assert_NoError()
    logfile.remove()
示例#14
0
def test_segment_index(accelize_drm, conf_json, cred_json, async_handler,
                       live_server, log_file_factory, request):
    """
    Test the DRM Controller capacity to handle stressfully health and license requests
    """
    driver = accelize_drm.pytest_fpga_driver[0]
    async_cb = async_handler.create()
    async_cb.reset()

    conf_json.reset()
    conf_json['licensing']['url'] = _request.url + request.function.__name__
    logfile = log_file_factory.create(2)
    conf_json['settings'].update(logfile.json)
    conf_json.save()

    with accelize_drm.DrmManager(conf_json.path, cred_json.path,
                                 driver.read_register_callback,
                                 driver.write_register_callback,
                                 async_cb.callback) as drm_manager:

        # Set initial context on the live server
        nb_genlic = 3
        healthPeriod = 300
        healthRetry = 0  # no retry
        context = {
            'nb_genlic': 0,
            'healthPeriod': healthPeriod,
            'healthRetry': healthRetry
        }
        set_context(context)
        assert get_context() == context

        # First, get license duration to align health period on it
        drm_manager.activate()
        lic_dur = drm_manager.get('license_duration')
        drm_manager.deactivate()

        # Adjust health period to license duration
        healthPeriod = lic_dur
        context = {
            'nb_genlic': 0,
            'healthPeriod': healthPeriod,
            'healthRetry': healthRetry
        }
        set_context(context)
        assert get_context() == context

        drm_manager.activate()
        assert drm_manager.get('health_period') == healthPeriod
        wait_func_true(lambda: get_context()['nb_genlic'] >= nb_genlic,
                       timeout=lic_dur * nb_genlic + 2)
        drm_manager.deactivate()
    async_cb.assert_NoError()
    log_content = logfile.read()
    segment_idx_expected = 0
    for m in findall(r'"meteringFile"\s*:\s*"([^"]*)"', log_content):
        assert len(m) > 0
        session_id = m[0:16]
        close_flag = m[19]
        segment_idx = int(m[24:32], 16)
        if session_id == "0000000000000000":
            assert close_flag == '0'
            assert segment_idx == 0
            session_id_exp = "0000000000000000"
        else:
            if session_id_exp == "0000000000000000":
                session_id_exp == session_id
            else:
                assert session_id == session_id_exp
        assert segment_idx_expected - 1 <= segment_idx <= segment_idx_expected + 1
        segment_idx_expected += 1
        if close_flag == '1':
            segment_idx_expected = 0
    assert get_proxy_error() is None
    logfile.remove()
示例#15
0
def run_test_on_design(accelize_drm, design_name, conf_json, cred_json,
                       async_handler, log_file_factory, axiclk_freq_ref,
                       drmclk_freq_ref):

    # Program board with design
    ref_designs = accelize_drm.pytest_ref_designs
    try:
        fpga_image = ref_designs.get_image_id(design_name)
    except:
        pytest.skip(
            f"Could not find refesign name '{design_name}' for driver '{accelize_drm.pytest_fpga_driver_name}'"
        )
    driver = accelize_drm.pytest_fpga_driver[0]
    driver.program_fpga(fpga_image)
    accelize_drm.scanActivators()

    # Run test
    async_cb = async_handler.create()
    async_cb.reset()
    activators = accelize_drm.pytest_fpga_activators[0]
    activators.reset_coin()
    activators.autotest()
    logfile = log_file_factory.create(1)
    conf_json['settings'].update(logfile.json)
    conf_json['drm']['frequency_mhz'] = drmclk_freq_ref
    conf_json.save()
    with accelize_drm.DrmManager(conf_json.path, cred_json.path,
                                 driver.read_register_callback,
                                 driver.write_register_callback,
                                 async_cb.callback) as drm_manager:
        assert not drm_manager.get('session_status')
        assert not drm_manager.get('license_status')
        assert drm_manager.get('session_id') == ''
        activators.autotest(is_activated=False)
        activators.generate_coin(5)
        activators.check_coin()
        # Start session
        drm_manager.activate()
        start = datetime.now()
        assert sum(drm_manager.get('metered_data')) == 0
        assert drm_manager.get('session_status')
        assert drm_manager.get('license_status')
        session_id = drm_manager.get('session_id')
        assert len(session_id) > 0
        activators.autotest(is_activated=True)
        lic_duration = drm_manager.get('license_duration')
        activators.generate_coin()
        activators.check_coin(drm_manager.get('metered_data'))
        # Wait until 2 licenses are provisioned
        conftest.wait_func_true(
            lambda: drm_manager.get('num_license_loaded') == 2, lic_duration)
        # Pause session
        drm_manager.deactivate(True)
        assert drm_manager.get('session_status')
        assert drm_manager.get('license_status')
        assert drm_manager.get('session_id') == session_id
        activators.autotest(is_activated=True)
        # Wait right before license expiration
        conftest.wait_deadline(start, 2 * lic_duration - 3)
        assert drm_manager.get('session_status')
        assert drm_manager.get('license_status')
        assert drm_manager.get('session_id') == session_id
        activators.autotest(is_activated=True)
        # Wait expiration
        conftest.wait_deadline(start, 2 * lic_duration + 2)
        assert drm_manager.get('session_status')
        assert drm_manager.get('session_id') == session_id
        assert not drm_manager.get('license_status')
        activators.autotest(is_activated=False)
        activators.generate_coin()
        activators.check_coin(drm_manager.get('metered_data'))
        # Resume session
        drm_manager.activate(True)
        assert drm_manager.get('session_status')
        assert drm_manager.get('session_id') != session_id
        assert drm_manager.get('license_status')
        activators.reset_coin()
        activators.autotest(is_activated=True)
        activators.generate_coin()
        activators.check_coin(drm_manager.get('metered_data'))
        # Stop session
        drm_manager.deactivate()
        assert not drm_manager.get('session_status')
        assert not drm_manager.get('license_status')
        activators.autotest(is_activated=False)
        assert drm_manager.get('session_id') == ''
    # Check result
    log_content = logfile.read()
    # Check API calls
    assert search(r"Calling Impl public constructor", log_content, IGNORECASE)
    assert search(r"Calling 'activate' with 'resume_session_request'=false",
                  log_content, IGNORECASE)
    assert search(r"Calling 'deactivate' with 'pause_session_request'=true",
                  log_content, IGNORECASE)
    assert search(r"Calling 'activate' with 'resume_session_request'=true",
                  log_content, IGNORECASE)
    assert search(r"Calling 'deactivate' with 'pause_session_request'=false",
                  log_content, IGNORECASE)
    # Check DRM Controller frequencies
    drmclk_match = search(
        r'Frequency detection of drm_aclk counter after .+ => estimated frequency = (\d+) MHz',
        log_content)
    drmclk_freq_measure = int(drmclk_match.group(1))
    assert drmclk_freq_ref * 0.9 < drmclk_freq_measure < drmclk_freq_ref * 1.1
    axiclk_match = search(
        r'Frequency detection of s_axi_aclk counter after .+ => estimated frequency = (\d+) MHz',
        log_content)
    axiclk_freq_measure = int(axiclk_match.group(1))
    assert axiclk_freq_ref * 0.9 < axiclk_freq_measure < axiclk_freq_ref * 1.1
    async_cb.assert_NoError()
    # Return logfile handler for more specific verification
    logfile.remove()
    return log_content