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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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
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)
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')
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'
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"
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"
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' 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)
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
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
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)
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)
def test_service_health(): assert shakedown.service_healthy(FOLDERED_SERVICE_NAME)
def test_service_health(): assert shakedown.service_healthy(FOLDERED_SERVICE_NAME)
def test_healthy(elastic_service_tls): assert shakedown.service_healthy(config.SERVICE_NAME)
def check_dcos_service_health(): return shakedown.service_healthy(PACKAGE_NAME)
def test_service_health(): assert shakedown.service_healthy(sdk_utils.get_foldered_name(config.SERVICE_NAME))
def test_service_health(): assert shakedown.service_healthy(sdk_utils.get_foldered_name(config.SERVICE_NAME))
def test_service_health(): assert shakedown.service_healthy(PACKAGE_NAME)
def test_service_health(): assert shakedown.service_healthy(config.SERVICE_NAME)
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
def check_dcos_service_health(): return shakedown.service_healthy(PACKAGE_NAME)
def test_service_health(): assert shakedown.service_healthy(config.get_foldered_service_name())
def test_service_health(): assert shakedown.service_healthy(foldered_name)
def test_healthy(elastic_service_tls): assert shakedown.service_healthy(config.SERVICE_NAME)
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)
def test_service_health(): assert shakedown.service_healthy(config.SERVICE_NAME)