コード例 #1
0
def hdfs_service_tls(service_account):
    try:
        sdk_install.install(PACKAGE_NAME,
                            service_name=SERVICE_NAME,
                            expected_running_tasks=DEFAULT_TASK_COUNT,
                            additional_options={
                                "service": {
                                    "service_account_secret": service_account,
                                    "service_account": service_account,
                                    "security": {
                                        "transport_encryption": {
                                            "enabled": True
                                        }
                                    }
                                }
                            })

        sdk_plan.wait_for_completed_deployment(SERVICE_NAME)

        # Wait for service health check to pass
        shakedown.service_healthy(SERVICE_NAME)
    except Exception as error:
        try:
            sdk_install.uninstall(PACKAGE_NAME, SERVICE_NAME)
        except:
            pass
        raise error

    yield

    sdk_install.uninstall(PACKAGE_NAME, SERVICE_NAME)
コード例 #2
0
def kafka_service_tls(service_account):
    sdk_install.uninstall(config.PACKAGE_NAME, config.SERVICE_NAME)
    config.install(config.PACKAGE_NAME,
                   config.SERVICE_NAME,
                   config.DEFAULT_BROKER_COUNT,
                   additional_options={
                       "service": {
                           "service_account": service_account,
                           "service_account_secret": service_account,
                           "security": {
                               "transport_encryption": {
                                   "enabled": True
                               }
                           }
                       }
                   })

    sdk_plan.wait_for_completed_deployment(config.SERVICE_NAME)

    # Wait for service health check to pass
    shakedown.service_healthy(config.SERVICE_NAME)

    yield service_account

    sdk_install.uninstall(config.PACKAGE_NAME, config.SERVICE_NAME)
コード例 #3
0
def elastic_service_tls(service_account):
    sdk_install.install(config.PACKAGE_NAME,
                        service_name=config.SERVICE_NAME,
                        expected_running_tasks=config.DEFAULT_TASK_COUNT,
                        additional_options={
                            "service": {
                                "service_account_secret": service_account,
                                "service_account": service_account,
                                "security": {
                                    "transport_encryption": {
                                        "enabled": True
                                    }
                                }
                            },
                            "elasticsearch": {
                                "xpack_enabled": True,
                            }
                        })

    sdk_plan.wait_for_completed_deployment(config.SERVICE_NAME)

    # Wait for service health check to pass
    shakedown.service_healthy(config.SERVICE_NAME)

    yield

    sdk_install.uninstall(config.PACKAGE_NAME, config.SERVICE_NAME)
コード例 #4
0
def cassandra_service_tls(service_account):
    sdk_install.uninstall(package_name=config.PACKAGE_NAME, service_name=config.SERVICE_NAME)
    sdk_install.install(
        config.PACKAGE_NAME,
        config.SERVICE_NAME,
        config.DEFAULT_TASK_COUNT,
        additional_options={
            "service": {
                "service_account": service_account["name"],
                "service_account_secret": service_account["secret"],
                "security": {
                    "transport_encryption": {
                        "enabled": True
                    }
                }
            }
        }
    )

    sdk_plan.wait_for_completed_deployment(config.SERVICE_NAME)

    # Wait for service health check to pass
    shakedown.service_healthy(config.SERVICE_NAME)

    yield

    sdk_install.uninstall(package_name=config.PACKAGE_NAME, service_name=config.SERVICE_NAME)
コード例 #5
0
def cassandra_service(service_account):
    """
    A pytest fixture that installs the cassandra service.
    On teardown, the service is uninstalled.
    """
    options = {
        "service": {
            "name": config.SERVICE_NAME,
            # Note that since we wish to toggle TLS which *REQUIRES* a service account,
            # we need to install Cassandra with a service account to start with.
            "service_account": service_account["name"],
            "service_account_secret": service_account["secret"],
        }
    }

    sdk_install.uninstall(config.PACKAGE_NAME, config.SERVICE_NAME)

    try:
        sdk_install.install(config.PACKAGE_NAME,
                            config.SERVICE_NAME,
                            config.DEFAULT_TASK_COUNT,
                            additional_options=options,
                            wait_for_deployment=True)

        # Wait for service health check to pass
        shakedown.service_healthy(config.SERVICE_NAME)

        yield {**options, **{"package_name": config.PACKAGE_NAME}}
    finally:
        sdk_install.uninstall(config.PACKAGE_NAME, config.SERVICE_NAME)
コード例 #6
0
def cassandra_service_tls(service_account):
    sdk_install.uninstall(package_name=PACKAGE_NAME, service_name=SERVICE_NAME)
    sdk_install.install(PACKAGE_NAME,
                        service_account,
                        DEFAULT_TASK_COUNT,
                        additional_options={
                            "service": {
                                "service_account_secret": service_account,
                                "service_account": service_account,
                                "security": {
                                    "transport_encryption": {
                                        "enabled": True
                                    }
                                }
                            }
                        })

    sdk_plan.wait_for_completed_deployment(SERVICE_NAME)

    # Wait for service health check to pass
    shakedown.service_healthy(SERVICE_NAME)

    yield

    sdk_install.uninstall(package_name=PACKAGE_NAME, service_name=SERVICE_NAME)
コード例 #7
0
def cassandra_service(service_account):
    """
    A pytest fixture that installs the cassandra service.
    On teardown, the service is uninstalled.
    """
    options = {
        "service": {
            "name": config.SERVICE_NAME,
            # Note that since we wish to toggle TLS which *REQUIRES* a service account,
            # we need to install Cassandra with a service account to start with.
            "service_account": service_account["name"],
            "service_account_secret": service_account["secret"],
        }
    }

    sdk_install.uninstall(config.PACKAGE_NAME, config.SERVICE_NAME)

    try:
        sdk_install.install(
            config.PACKAGE_NAME,
            config.SERVICE_NAME,
            config.DEFAULT_TASK_COUNT,
            additional_options=options,
            wait_for_deployment=True)

        # Wait for service health check to pass
        shakedown.service_healthy(config.SERVICE_NAME)

        yield {**options, **{"package_name": config.PACKAGE_NAME}}
    finally:
        sdk_install.uninstall(config.PACKAGE_NAME, config.SERVICE_NAME)
コード例 #8
0
def elastic_service_tls(service_account):
    sdk_install.install(
        PACKAGE_NAME,
        service_name=SERVICE_NAME,
        expected_running_tasks=NO_INGEST_TASK_COUNT,
        additional_options={
            "service": {
                "service_account_secret": service_account,
                "service_account": service_account,
                "tls": True,
            },
            "elasticsearch": {
                "xpack_enabled": True,
            }
        }
    )

    sdk_plan.wait_for_completed_deployment(SERVICE_NAME)

    # Wait for service health check to pass
    shakedown.service_healthy(SERVICE_NAME)

    yield

    sdk_install.uninstall(PACKAGE_NAME, SERVICE_NAME)
コード例 #9
0
def test_service_overlay_health():
    """Installs SDK based Kafka on with virtual networks set to True. Tests that the deployment completes
    and the service is healthy, then checks that all of the service tasks (brokers) are on the overlay network
    """
    shakedown.service_healthy(config.SERVICE_NAME)
    broker_tasks = ("kafka-0-broker", "kafka-1-broker", "kafka-2-broker")
    for task in broker_tasks:
        sdk_networks.check_task_network(task)
コード例 #10
0
ファイル: test_overlay.py プロジェクト: joerg84/dcos-commons
def test_service_overlay_health():
    shakedown.service_healthy(config.SERVICE_NAME)
    node_tasks = (
        "node-0-server",
        "node-1-server",
        "node-2-server",
    )
    for task in node_tasks:
        sdk_networks.check_task_network(task)
コード例 #11
0
def test_service_overlay_health():
    shakedown.service_healthy(config.SERVICE_NAME)
    node_tasks = (
        "node-0-server",
        "node-1-server",
        "node-2-server",
    )
    for task in node_tasks:
        sdk_networks.check_task_network(task)
コード例 #12
0
def test_service_overlay_health():
    shakedown.service_healthy(PACKAGE_NAME)
    node_tasks = (
        "node-0-server",
        "node-1-server",
        "node-2-server",
    )
    for task in node_tasks:
        networks.check_task_network(task)
コード例 #13
0
ファイル: test_tls.py プロジェクト: zencircle/dcos-commons
def configure_package(configure_security):
    try:
        sdk_install.uninstall(config.PACKAGE_NAME, config.SERVICE_NAME)

        # Create service account
        sdk_security.create_service_account(
            service_account_name=config.SERVICE_NAME,
            service_account_secret=config.SERVICE_NAME)
        # TODO(mh): Fine grained permissions needs to be addressed in DCOS-16475
        sdk_cmd.run_cli(
            "security org groups add_user superusers {name}".format(
                name=config.SERVICE_NAME))

        sdk_install.install(
            config.PACKAGE_NAME,
            config.SERVICE_NAME,
            6,
            additional_options={
                "service": {
                    "spec_file": "examples/tls.yml",
                    "service_account": config.SERVICE_NAME,
                    "service_account_secret": config.SERVICE_NAME,
                    # Legacy values
                    "principal": config.SERVICE_NAME,
                    "secret_name": config.SERVICE_NAME,
                },
                "tls": {
                    "discovery_task_prefix": DISCOVERY_TASK_PREFIX,
                },
            })

        sdk_plan.wait_for_completed_deployment(config.SERVICE_NAME)

        # Wait for service health check to pass
        shakedown.service_healthy(config.SERVICE_NAME)

        yield  # let the test session execute

    finally:
        sdk_install.uninstall(config.PACKAGE_NAME, config.SERVICE_NAME)
        sdk_security.delete_service_account(
            service_account_name=config.SERVICE_NAME,
            service_account_secret=config.SERVICE_NAME)

        # Make sure that all the TLS artifacts were removed from the secrets store.
        output = sdk_cmd.run_cli(
            'security secrets list {name}'.format(name=config.SERVICE_NAME))
        artifact_suffixes = [
            'certificate', 'private-key', 'root-ca-certificate', 'keystore',
            'truststore'
        ]

        for suffix in artifact_suffixes:
            assert suffix not in output
コード例 #14
0
ファイル: test_overlay.py プロジェクト: joerg84/dcos-commons
def test_service_overlay_health():
    """Installs SDK based Kafka on with virtual networks set to True. Tests that the deployment completes
    and the service is healthy, then checks that all of the service tasks (brokers) are on the overlay network
    """
    shakedown.service_healthy(config.SERVICE_NAME)
    broker_tasks = (
        "kafka-0-broker",
        "kafka-1-broker",
        "kafka-2-broker"
    )
    for task in broker_tasks:
        sdk_networks.check_task_network(task)
コード例 #15
0
 def success_predicate(tasks):
     running_tasks = [t for t in tasks if t['state'] == TASK_RUNNING_STATE]
     print('Waiting for {} healthy tasks, got {}/{}'.format(
         DEFAULT_NODE_COUNT, len(running_tasks), len(tasks)))
     return (len(running_tasks) == DEFAULT_NODE_COUNT
             and shakedown.service_healthy(PACKAGE_NAME),
             'Service did not become healthy')
コード例 #16
0
def test_install_marathon():
    """Install the Marathon package for DC/OS.
    """

    # Install
    shakedown.install_package_and_wait(PACKAGE_NAME)
    assert shakedown.package_installed(PACKAGE_NAME), 'Package failed to install'

    end_time = time.time() + WAIT_TIME_IN_SECS
    found = False
    while time.time() < end_time:
        found = shakedown.get_service(PACKAGE_NAME) is not None
        if found and shakedown.service_healthy(SERVICE_NAME):
            break
        time.sleep(1)

    assert found, 'Service did not register with DCOS'
    shakedown.deployment_wait()

    # Uninstall
    uninstall('marathon-user')
    shakedown.deployment_wait()

    # Reinstall
    shakedown.install_package_and_wait(PACKAGE_NAME)
    assert shakedown.package_installed(PACKAGE_NAME), 'Package failed to reinstall'
コード例 #17
0
def test_install_marathon():
    """Install the Marathon package for DC/OS.
    """

    # Install
    shakedown.install_package_and_wait(PACKAGE_NAME)
    assert shakedown.package_installed(PACKAGE_NAME), 'Package failed to install'

    end_time = time.time() + WAIT_TIME_IN_SECS
    found = False
    while time.time() < end_time:
        found = shakedown.get_service(PACKAGE_NAME) is not None
        if found and shakedown.service_healthy(SERVICE_NAME):
            break
        time.sleep(1)

    assert found, 'Service did not register with DCOS'
    shakedown.deployment_wait()

    # Uninstall
    uninstall('marathon-user')
    shakedown.deployment_wait()

    # Reinstall
    shakedown.install_package_and_wait(PACKAGE_NAME)
    assert shakedown.package_installed(PACKAGE_NAME), 'Package failed to reinstall'
    #
    try:
        shakedown.install_package(PACKAGE_NAME)
    except Exception as e:
        pass
    else:
        # Exception is not raised -> exit code was 0
        assert False, "Error: CLI returns 0 when asked to install Marathon"
コード例 #18
0
def test_install_marathon():
    """Install the Marathon package for DC/OS.
    """

    # Install
    shakedown.install_package_and_wait(PACKAGE_NAME)
    assert shakedown.package_installed(PACKAGE_NAME), 'Package failed to install'

    end_time = time.time() + WAIT_TIME_IN_SECS
    found = False
    while time.time() < end_time:
        found = shakedown.get_service(PACKAGE_NAME) is not None
        if found and shakedown.service_healthy(SERVICE_NAME):
            break
        time.sleep(1)

    assert found, 'Service did not register with DCOS'
    shakedown.deployment_wait()

    # Uninstall
    uninstall('marathon-user')
    shakedown.deployment_wait()

    # Reinstall
    shakedown.install_package_and_wait(PACKAGE_NAME)
    assert shakedown.package_installed(PACKAGE_NAME), 'Package failed to reinstall'
    #
    try:
        shakedown.install_package(PACKAGE_NAME)
    except Exception as e:
        pass
    else:
        # Exception is not raised -> exit code was 0
        assert False, "Error: CLI returns 0 when asked to install Marathon"
コード例 #19
0
def test_install_universe_package(package):
    """ Marathon is responsible for installing packages from the universe.
        This test confirms that several packages are installed into a healty state.
    """

    shakedown.install_package_and_wait(package)
    assert shakedown.package_installed(package), 'Package failed to install'

    shakedown.deployment_wait(timeout=timedelta(minutes=5).total_seconds())
    assert shakedown.service_healthy(package)
コード例 #20
0
def test_install_universe_package(package):
    """ Marathon is responsible for installing packages from the universe.
        This test confirms that several packages are installed into a healty state.
    """

    shakedown.install_package_and_wait(package)
    assert shakedown.package_installed(package), 'Package failed to install'

    shakedown.deployment_wait(timeout=timedelta(minutes=5).total_seconds())
    assert shakedown.service_healthy(package)
コード例 #21
0
def test_install_universe_package(package):
    """ Marathon is responsible for installing packages from the universe.
        This test confirms that several packages are installed into a healty state.
    """

    shakedown.install_package_and_wait(package)
    assert shakedown.package_installed(package), 'Package failed to install'

    common.deployment_wait(max_attempts=300)
    assert shakedown.service_healthy(package)
コード例 #22
0
ファイル: test_tls.py プロジェクト: joerg84/dcos-commons
def hello_world_service(service_account):
    sdk_install.uninstall(config.PACKAGE_NAME, config.SERVICE_NAME)
    sdk_install.install(
        config.PACKAGE_NAME,
        config.SERVICE_NAME,
        1,
        additional_options={
            "service": {
                "spec_file": "examples/tls.yml",
                "service_account": service_account,
                "service_account_secret": service_account,
                # Legacy values
                "principal": service_account,
                "secret_name": service_account,
                },
            "tls": {
                "discovery_task_prefix": DISCOVERY_TASK_PREFIX,
                },
            }
        )

    sdk_plan.wait_for_completed_deployment(config.SERVICE_NAME)

    # Wait for service health check to pass
    shakedown.service_healthy(config.SERVICE_NAME)

    # TODO(mh): Add proper wait for health check
    time.sleep(15)

    yield service_account

    sdk_install.uninstall(config.PACKAGE_NAME, config.SERVICE_NAME)

    # Make sure that all the TLS artifacts were removed from the secrets store.
    output = sdk_cmd.run_cli('security secrets list {name}'.format(name=config.SERVICE_NAME))
    artifact_suffixes = [
        'certificate', 'private-key', 'root-ca-certificate',
        'keystore', 'truststore'
        ]

    for suffix in artifact_suffixes:
        assert suffix not in output
コード例 #23
0
def hello_world_service(service_account):
    sdk_install.install(
        config.PACKAGE_NAME,
        1,
        service_name=service_account,
        additional_options={
            "service": {
                "spec_file": "examples/tls.yml",
                "service_account": service_account,
                "service_account_secret": service_account,
                # Legacy values
                "principal": service_account,
                "secret_name": service_account,
                },
            "tls": {
                "discovery_task_prefix": DISCOVERY_TASK_PREFIX,
                },
            }
        )

    sdk_plan.wait_for_completed_deployment(config.PACKAGE_NAME)

    # Wait for service health check to pass
    shakedown.service_healthy(config.PACKAGE_NAME)

    # TODO(mh): Add proper wait for health check
    time.sleep(15)

    yield service_account

    sdk_install.uninstall(config.PACKAGE_NAME)

    # Make sure that all the TLS artifacts were removed from the secrets store.
    output = sdk_cmd.run_cli('security secrets list {name}'.format(
        name=config.PACKAGE_NAME))
    artifact_suffixes = [
        'certificate', 'private-key', 'root-ca-certificate',
        'keystore', 'truststore'
        ]

    for suffix in artifact_suffixes:
        assert suffix not in output
コード例 #24
0
def cassandra_service_tls(service_account):
    sdk_install.install(PACKAGE_NAME,
                        DEFAULT_TASK_COUNT,
                        service_name=service_account,
                        additional_options={
                            "service": {
                                "service_account_secret": service_account,
                                "service_account": service_account,
                                "tls": True,
                                "tls_allow_plaintext": False,
                            }
                        })

    sdk_plan.wait_for_completed_deployment(PACKAGE_NAME)

    # Wait for service health check to pass
    shakedown.service_healthy(PACKAGE_NAME)

    yield

    sdk_install.uninstall(PACKAGE_NAME)
コード例 #25
0
ファイル: test_tls.py プロジェクト: shaurya10000/dcos-commons
def kafka_service_tls(service_account):
    sdk_install.install(
        config.PACKAGE_NAME,
        config.DEFAULT_BROKER_COUNT,
        service_name=service_account,
        additional_options={
            "service": {
                "service_account": service_account,
                "service_account_secret": service_account,
                # Legacy values
                "principal": service_account,
                "secret_name": service_account,
                "tls": True
            }
        })

    sdk_plan.wait_for_completed_deployment(config.PACKAGE_NAME)

    # Wait for service health check to pass
    shakedown.service_healthy(config.PACKAGE_NAME)

    yield service_account

    sdk_install.uninstall(config.PACKAGE_NAME)
コード例 #26
0
def test_service_health():
    assert shakedown.service_healthy(FOLDERED_SERVICE_NAME)
コード例 #27
0
ファイル: test_sanity.py プロジェクト: joerg84/dcos-commons
def test_service_health():
    assert shakedown.service_healthy(FOLDERED_SERVICE_NAME)
コード例 #28
0
def test_healthy(elastic_service_tls):
    assert shakedown.service_healthy(config.SERVICE_NAME)
コード例 #29
0
def check_dcos_service_health():
    return shakedown.service_healthy(PACKAGE_NAME)
コード例 #30
0
def test_service_health():
    assert shakedown.service_healthy(sdk_utils.get_foldered_name(config.SERVICE_NAME))
コード例 #31
0
def test_service_health():
    assert shakedown.service_healthy(sdk_utils.get_foldered_name(config.SERVICE_NAME))
コード例 #32
0
def test_service_health():
    assert shakedown.service_healthy(PACKAGE_NAME)
コード例 #33
0
ファイル: test_ingest.py プロジェクト: joerg84/dcos-commons
def test_service_health():
    assert shakedown.service_healthy(config.SERVICE_NAME)
コード例 #34
0
 def assert_service_registration(package, service):
     found = shakedown.get_service(package) is not None
     assert found and shakedown.service_healthy(
         service
     ), f"Service {package} did not register with DCOS"  # NOQA E999
コード例 #35
0
ファイル: config.py プロジェクト: albertostratio/dcos-commons
def check_dcos_service_health():
    return shakedown.service_healthy(PACKAGE_NAME)
コード例 #36
0
def test_service_health():
    assert shakedown.service_healthy(config.get_foldered_service_name())
コード例 #37
0
ファイル: test_sanity.py プロジェクト: thebijuus/dcos-commons
def test_service_health():
    assert shakedown.service_healthy(foldered_name)
コード例 #38
0
def test_healthy(elastic_service_tls):
    assert shakedown.service_healthy(config.SERVICE_NAME)
コード例 #39
0
def test_service_health():
    sdk_tasks.check_running(config.SERVICE_NAME, config.NO_INGEST_TASK_COUNT)
    config.wait_for_expected_nodes_to_exist(
        task_count=config.NO_INGEST_TASK_COUNT)
    assert shakedown.service_healthy(config.SERVICE_NAME)
コード例 #40
0
def test_service_health():
    assert shakedown.service_healthy(config.SERVICE_NAME)