def test_verify_add_all_hosts(engine_api): hosts_service = engine_api.system_service().hosts_service() total_hosts = len( hosts_service.list(search='datacenter={}'.format(DC_NAME))) assertions.assert_true_within( lambda: host_status_utils._all_hosts_up(hosts_service, total_hosts), timeout=constants.ADD_HOST_TIMEOUT)
def _wait_for_engine_health(ansible_host): logging.info('Waiting for the engine to start...') assertions.assert_true_within( lambda: any(host_data['engine-status']['health'] == 'good' for host_data in he_utils.he_status(ansible_host)['hosts']. values()), constants.ENGINE_VM_RESTART_TIMEOUT, ) logging.info('Engine is running.')
def assert_finished_within(func, engine, timeout, allowed_exceptions=None, *args, **kwargs): if 'query' in kwargs: if 'correlation_id' not in kwargs['query']: kwargs['query']['correlation_id'] = uuid.uuid4() else: kwargs['query'] = {'correlation_id': uuid.uuid4()} func(*args, **kwargs) assertions.assert_true_within( lambda: all_jobs_finished(engine, kwargs['query']['correlation_id']), timeout)
def wait_for_event(engine, event_id, timeout=assertions.LONG_TIMEOUT): ''' event_id could either be an int - a single event ID or a list - multiple event IDs that all will be checked ''' events = engine.events_service() last_event = int(events.list(max=2)[0].id) try: yield finally: if isinstance(event_id, int): event_id = [event_id] for e_id in event_id: assertions.assert_true_within( lambda: any(e.code == e_id for e in events.list(from_=last_event)), timeout )