Example #1
0
def configure_package(configure_security):
    try:
        # setup custom seccomp profile
        all_agent_ips = set(
            [agent["hostname"] for agent in sdk_agents.get_agents()])
        for ip in all_agent_ips:
            print("Copying custom seccomp profile to agent %s" % ip)
            sdk_cmd.agent_scp(
                ip,
                json.dumps(custom_profile),
                SECCOMP_DIR,
            )

        sdk_install.uninstall(config.PACKAGE_NAME, config.SERVICE_NAME)
        options = {
            "service": {
                "yaml": "seccomp"
            },
            "hello": {
                "seccomp-profile-name": "default.json"
            }
        }

        sdk_install.install(config.PACKAGE_NAME,
                            config.SERVICE_NAME,
                            expected_running_tasks=1,
                            additional_options=options)

        yield  # let the test session execute
    finally:
        sdk_install.uninstall(config.PACKAGE_NAME, config.SERVICE_NAME)
Example #2
0
def check_endpoint_on_overlay(
    package_name: str, service_name: str, endpoint_to_get: str, expected_task_count: int
) -> None:
    endpoint = get_endpoint(package_name, service_name, endpoint_to_get)

    assert "address" in endpoint, "Missing 'address': {}".format(endpoint)
    endpoint_address = endpoint["address"]
    assert len(endpoint_address) == expected_task_count

    assert "dns" in endpoint, "Missing 'dns': {}".format(endpoint)
    endpoint_dns = endpoint["dns"]
    assert len(endpoint_dns) == expected_task_count

    # Addresses should have ip:port format:
    ip_addresses = set([e.split(":")[0] for e in endpoint_address])

    all_agent_ips = set([agent["hostname"] for agent in sdk_agents.get_agents()])
    assert (
        len(ip_addresses.intersection(all_agent_ips)) == 0
    ), "Overlay IPs should not match any agent IPs"

    for dns in endpoint_dns:
        assert (
            "autoip.dcos.thisdcos.directory" in dns
        ), "Expected 'autoip.dcos.thisdcos.directory' in DNS entry"
Example #3
0
def check_endpoint_on_overlay(package_name: str, service_name: str, endpoint_to_get: str, expected_task_count: int) -> None:
    endpoint = get_endpoint(package_name, service_name, endpoint_to_get)

    assert "address" in endpoint, "Missing 'address': {}".format(endpoint)
    endpoint_address = endpoint["address"]
    assert len(endpoint_address) == expected_task_count

    assert "dns" in endpoint, "Missing 'dns': {}".format(endpoint)
    endpoint_dns = endpoint["dns"]
    assert len(endpoint_dns) == expected_task_count

    # Addresses should have ip:port format:
    ip_addresses = set([e.split(":")[0] for e in endpoint_address])

    all_agent_ips = set([agent["hostname"] for agent in sdk_agents.get_agents()])
    assert len(ip_addresses.intersection(all_agent_ips)) == 0, "Overlay IPs should not match any agent IPs"

    for dns in endpoint_dns:
        assert "autoip.dcos.thisdcos.directory" in dns, "Expected 'autoip.dcos.thisdcos.directory' in DNS entry"
def check_endpoints_on_overlay(endpoints):
    def check_ip_addresses_on_overlay():
        # the overlay IP address should not contain any agent IPs
        return len(set(ip_addresses).intersection(set(all_agent_ips))) == 0

    assert "address" in endpoints, "endpoints: {} missing 'address' key".format(
        endpoints)
    assert "dns" in endpoints, "endpoints: {} missing 'dns' key".format(
        endpoints)

    # endpoints should have the format <ip_address>:port
    ip_addresses = [e.split(":")[0] for e in endpoints["address"]]
    all_agent_ips = [agent["hostname"] for agent in sdk_agents.get_agents()]
    assert (
        check_ip_addresses_on_overlay()
    ), "IP addresses for this service should not contain agent IPs, IPs were {}".format(
        ip_addresses)

    for dns in endpoints["dns"]:
        assert (
            "autoip.dcos.thisdcos.directory" in dns
        ), "DNS {} is incorrect should have autoip.dcos.thisdcos.directory".format(
            dns)
Example #5
0
def configure_package(configure_security):
    try:
        # setup custom seccomp profile
        all_agent_ips = set([agent["hostname"] for agent in sdk_agents.get_agents()])
        for ip in all_agent_ips:
            print("Copying custom seccomp profile to agent %s" % ip)
            sdk_cmd.agent_scp(ip, json.dumps(custom_profile), SECCOMP_DIR, )

        sdk_install.uninstall(config.PACKAGE_NAME, config.SERVICE_NAME)
        options = {
            "service": {
                "yaml": "seccomp"
            },
            "hello": {
                "seccomp-profile-name": "default.json"
            }
        }

        sdk_install.install(config.PACKAGE_NAME, config.SERVICE_NAME, expected_running_tasks=1 , additional_options=options)

        yield  # let the test session execute
    finally:
        sdk_install.uninstall(config.PACKAGE_NAME, config.SERVICE_NAME)
Example #6
0
def _get_agentid_to_hostname() -> dict:
    return {agent["id"]: agent["hostname"] for agent in sdk_agents.get_agents()}
Example #7
0
def _get_agentid_to_hostname() -> dict:
    return {
        agent["id"]: agent["hostname"]
        for agent in sdk_agents.get_agents()
    }
Example #8
0
def install_krb_workstation():
    for agent in sdk_agents.get_agents():
        sdk_cmd.agent_ssh(agent["hostname"],
                          "sudo yum install krb5-workstation -y")
    yield