Example #1
0
def wait_for_service_endpoint(service_name, timeout_sec=120, path=""):
    """
    Checks the service url. Waits for exhibitor to start up (up to 20 minutes) and then checks the url on all masters.

    if available it returns true,
    on expiration throws an exception
    """
    def verify_ssl():
        cafile = get_ca_file()
        if cafile.is_file():
            return str(cafile)
        else:
            return False

    def master_service_status_code(url):
        logger.info('Querying %s', url)
        auth = DCOSAcsAuth(authentication.dcos_acs_token())

        response = requests.get(url=url,
                                timeout=5,
                                auth=auth,
                                verify=verify_ssl())

        return response.status_code

    schema = 'https' if ee_version() == 'strict' or ee_version(
    ) == 'permissive' else 'http'
    logger.info(
        'Waiting for service /service/{}/{} to become available on all masters'
        .format(service_name, path))

    for ip in dcos_masters_public_ips():
        url = "{}://{}/service/{}/{}".format(schema, ip, service_name, path)
        assert_that(lambda: master_service_status_code(url),
                    eventually(equal_to(200), max_attempts=timeout_sec / 5))
Example #2
0
    def check_service_availability_on_master(master_ip, service):

        schema = 'https' if ee_version() == 'strict' or ee_version(
        ) == 'permissive' else 'http'

        url = "{}://{}/service/{}/{}".format(schema, master_ip, service, path)

        auth = DCOSAcsAuth(shakedown.dcos_acs_token())
        try:
            response = requests.get(url=url,
                                    timeout=5,
                                    auth=auth,
                                    verify=verify_ssl())
        except ReadTimeout as e:
            raise DCOSException("service " + service_name +
                                " is unavailable at " + master_ip)

        if response.status_code == 200:
            return True
        else:
            print(response)
            raise DCOSException("service " + service_name +
                                " is unavailable at " + master_ip)
Example #3
0
def cluster_info(mom_name='marathon-user'):
    logger.info("DC/OS: %s, in %s mode", dcos_version(), ee_version())
    agents = get_private_agents()
    logger.info("Agents: %d", len(agents))
    client = marathon.create_client()
    about = client.get_about()
    logger.info("Marathon version: %s", about.get("version"))

    if service_available_predicate(mom_name):
        with marathon_on_marathon(mom_name) as client:
            try:
                about = client.get_about()
                logger.info("Marathon MoM version: {}".format(about.get("version")))
            except Exception:
                logger.info("Marathon MoM not present")
    else:
        logger.info("Marathon MoM not present")
Example #4
0
def cluster_info(mom_name='marathon-user'):
    logger.info("DC/OS: %s, in %s mode", dcos_version(), ee_version())
    agents = get_private_agents()
    logger.info("Agents: %d", len(agents))
    client = marathon.create_client()
    about = client.get_about()
    logger.info("Marathon version: %s", about.get("version"))

    if service_available_predicate(mom_name):
        with marathon_on_marathon(mom_name) as client:
            try:
                about = client.get_about()
                logger.info("Marathon MoM version: {}".format(
                    about.get("version")))
            except Exception:
                logger.info("Marathon MoM not present")
    else:
        logger.info("Marathon MoM not present")
def test_private_repository_docker_app():
    username = os.environ['DOCKER_HUB_USERNAME']
    password = os.environ['DOCKER_HUB_PASSWORD']
    agents = get_private_agents()

    common.create_docker_credentials_file(username, password)
    common.copy_docker_credentials_file(agents)

    app_def = apps.private_docker_app()
    app_id = app_def["id"]

    if ee_version() == 'strict':
        app_def['user'] = '******'
        common.add_dcos_marathon_user_acls()

    client = marathon.create_client()
    client.add_app(app_def)
    deployment_wait(service_id=app_id)

    common.assert_app_tasks_running(client, app_def)
Example #6
0
def test_private_repository_docker_app():
    username = os.environ['DOCKER_HUB_USERNAME']
    password = os.environ['DOCKER_HUB_PASSWORD']
    agents = get_private_agents()

    common.create_docker_credentials_file(username, password)
    common.copy_docker_credentials_file(agents)

    app_def = apps.private_docker_app()
    app_id = app_def["id"]

    if ee_version() == 'strict':
        app_def['user'] = '******'
        common.add_dcos_marathon_user_acls()

    client = marathon.create_client()
    client.add_app(app_def)
    deployment_wait(service_id=app_id)

    common.assert_app_tasks_running(client, app_def)
Example #7
0
def install_enterprise_cli():
    """Install enterprise cli on an DC/OS EE cluster before all tests start.
    """
    if ee_version() is not None:
        common.install_enterprise_cli_package()
def install_enterprise_cli():
    """Install enterprise cli on an DC/OS EE cluster before all tests start.
    """
    if ee_version() is not None:
        common.install_enterprise_cli_package()