Exemple #1
0
def test_concurrent_sequences_with_no_handler(scale, clients):
    total_resources = scale * 3
    timeout = scale * 2
    scheduler_client = clients['scheduler']

    assert len(change.staged_log()) == total_resources
    ModelMeta.session_end()
    plan = change.send_to_orchestration()
    scheduler_client.next({}, plan.graph['uid'])

    def wait_function(timeout):
        try:
            for summary in wait_finish(plan.graph['uid'], timeout):
                assert summary[states.ERROR.name] == 0
                time.sleep(0.5)
        except ExecutionTimeout:
            pass
        return summary

    waiter = gevent.spawn(wait_function, timeout)
    waiter.join(timeout=timeout)
    res = waiter.get(block=True)
    assert res[states.SUCCESS.name] == total_resources
    assert len(data.CL()) == total_resources
    clear_cache()
    assert len(change.staged_log()) == 0
def test_concurrent_sequences_with_no_handler(scale, clients):
    total_resources = scale * 3
    timeout = scale * 2
    scheduler_client = clients['scheduler']

    assert len(change.staged_log()) == total_resources
    ModelMeta.session_end()
    plan = change.send_to_orchestration()
    scheduler_client.next({}, plan.graph['uid'])

    def wait_function(timeout):
        try:
            for summary in wait_finish(plan.graph['uid'], timeout):
                assert summary[states.ERROR.name] == 0
                time.sleep(0.5)
        except ExecutionTimeout:
            pass
        return summary
    waiter = gevent.spawn(wait_function, timeout)
    waiter.join(timeout=timeout)
    res = waiter.get(block=True)
    assert res[states.SUCCESS.name] == total_resources
    assert len(data.CL()) == total_resources
    clear_cache()
    assert len(change.staged_log()) == 0
Exemple #3
0
def wait_finish(uid, timeout):
    """Check if graph is finished

    Will return when no PENDING or INPROGRESS otherwise yields summary
    """
    start_time = time.time()

    while start_time + timeout >= time.time():
        dg = get_graph(uid)
        summary = Counter()
        summary.update({s.name: 0 for s in states})
        summary.update([task.status for task in dg.nodes()])
        yield summary
        if summary[states.PENDING.name] + summary[states.INPROGRESS.name] == 0:
            return
        else:
            # on db backends with snapshot isolation level and higher
            # updates wont be visible after start of transaction,
            # in order to report state correctly we will "refresh" transaction
            ModelMeta.session_end()
            ModelMeta.session_start()

    else:
        raise errors.ExecutionTimeout(
            'Run %s wasnt able to finish' % uid)
Exemple #4
0
 def _end_start_session(cls, uid, identity):
     """Because of isolated versions of data in concurrent sessions
     we need to ensure that session will be re-started at certain
     hooks during locking logic
     """
     ModelMeta.session_end()
     ModelMeta.session_start()
Exemple #5
0
 def _end_start_session(cls, uid, identity):
     """Because of isolated versions of data in concurrent sessions
     we need to ensure that session will be re-started at certain
     hooks during locking logic
     """
     ModelMeta.session_end()
     ModelMeta.session_start()
Exemple #6
0
def pytest_runtest_teardown(item, nextitem):
    ModelMeta.session_end(result=True)
    return nextitem
Exemple #7
0
def pytest_runtest_call(item):
    ModelMeta.session_end()
    ModelMeta.session_start()
Exemple #8
0
 def session_end(ctxt):
     log.debug('Session end ID %s', id(gevent.getcurrent()))
     ModelMeta.session_end()
Exemple #9
0
def pytest_runtest_call(item):
    ModelMeta.session_end()
    ModelMeta.session_start()
Exemple #10
0
def pytest_runtest_teardown(item, nextitem):
    ModelMeta.session_end(result=True)
    return nextitem
Exemple #11
0

@main.command()
@click.argument('env_id')
@click.argument('uids', nargs=-1)
@click.option('-f', '--full', is_flag=True)
def env(env_id, uids, full):
    """Prepares solar environment based on fuel environment.
    It should perform all required changes for solar to work
    """
    env = Environment(env_id)
    uids = list(uids) if uids else [
        str(n.data['id']) for n in env.get_all_nodes()]
    for nobj in source.nodes(uids):
        try:
            # FIXME
            resource.load('node%s' % nobj.data['id'])
        except:
            node(nobj)
            fuel_data(nobj)
    _prefetch(env, uids)
    create_master()
    allocate(
        source.graph(env_id),
        ['null', 'master'] + uids if full else uids)


if __name__ == '__main__':
    main()
    ModelMeta.session_end()
Exemple #12
0
 def session_end(ctxt):
     log.debug('Session end ID %s', id(gevent.getcurrent()))
     ModelMeta.session_end()
Exemple #13
0
    _prefetch(Environment(env_id), uids)


@main.command()
@click.argument('env_id')
@click.argument('uids', nargs=-1)
@click.option('-f', '--full', is_flag=True)
def env(env_id, uids, full):
    """Prepares solar environment based on fuel environment.
    It should perform all required changes for solar to work
    """
    env = Environment(env_id)
    uids = list(uids) if uids else [
        str(n.data['id']) for n in env.get_all_nodes()
    ]
    for nobj in source.nodes(uids):
        try:
            # FIXME
            resource.load('node%s' % nobj.data['id'])
        except:
            node(nobj)
            fuel_data(nobj)
    _prefetch(env, uids)
    create_master()
    allocate(source.graph(env_id), ['null', 'master'] + uids if full else uids)


if __name__ == '__main__':
    main()
    ModelMeta.session_end()