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)
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
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
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
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)
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
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
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
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
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
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
def test_service_health():
    assert shakedown.service_healthy(foldered_name)
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)