Exemplo n.º 1
0
def _get_selenium():
    # load desired_capabilities
    capabilities = {}
    for key, value in cfg.selenium.capabilities.items():
        if key == 'zalenium':  # update zalenium capabilities
            for z_key, z_value in value.items():
                capabilities['zal:' + z_key] = z_value
        else:  # update selenium capabilities
            capabilities[key] = value
    logger.debug('Selenium configuration:\n{}'.format(
        json.dumps(cfg.selenium.toDict(), indent=2)))
    # load driver
    driver = None
    # try to get the driver more times (workaround for zalenium issue in OS)
    maximum_try = 5
    for x in range(1, maximum_try):
        try:
            logger.info(
                'Trying to create a web driver. Attempt: {} of {}'.format(
                    x, maximum_try))
            driver = _get_driver(capabilities)
            break
        except WebDriverException as ex:
            logger.warn('Failed to create driver. Exception:{}'.format(ex))
            sleep(5)
            continue
    return driver
Exemplo n.º 2
0
def kiali_client():
    logger.debug('Creating kiali rest client')
    logger.debug('Kiali hostname: {}'.format(cfg.kiali.hostname))
    _client = KialiExtendedClient(hostname=cfg.kiali.hostname,
                                  username=cfg.kiali.username,
                                  password=cfg.kiali.password,
                                  auth_type=cfg.kiali.auth_type,
                                  token=cfg.kiali.token,
                                  swagger_address=cfg.kiali.swagger_address)
    # update kiali version details
    _response = _client.get_response('getStatus')
    _status = _response['status']
    cfg.kiali.version.core = _status['Kiali version']
    cfg.kiali.version.console = _status['Kiali version']

    # There is an issue to show video recordings when we use special chars in build details
    # https://github.com/zalando/zalenium/issues/572
    # cfg.selenium.capabilities.zalenium.build = 'console:{}, core:{}:{}'.format(
    #    cfg.kiali.version.console,
    #    cfg.kiali.version.core,
    #    _status['Kiali core commit hash'])
    cfg.selenium.capabilities.zalenium.build = '{}'.format(
        cfg.kiali.version.core)
    logger.info('Kiali versions:\n{}'.format(json.dumps(_response, indent=2)))
    return _client
Exemplo n.º 3
0
def openshift_client():
    if cfg.kiali.skip_oc:
        logger.debug('Skipping Openshift rest client because of cfg.kiali.skip_oc')
        # TODO Temporary solution as OC client does not support OCP4
        return kiali_client()
    else:
        logger.debug('Creating Openshift rest client')
        _client = OpenshiftExtendedClient()
        logger.info('Openshift versions:\n{}'.format(json.dumps(_client.version, indent=2)))
        return _client
Exemplo n.º 4
0
def openshift_client():
    logger.debug('Creating opeshift rest client')
    _client = OpenshiftExtendedClient()
    logger.info('Openshift versions:\n{}'.format(
        json.dumps(_client.version, indent=2)))
    return _client