def partition_agent(hostname):
    """Partition a node from all network traffic except for SSH and loopback"""

    shakedown.copy_file_to_agent(
        hostname, "{}/net-services-agent.sh".format(scripts.scripts_dir()))
    logger.info("partitioning {}".format(hostname))
    shakedown.run_command_on_agent(hostname, 'sh net-services-agent.sh fail')
Exemplo n.º 2
0
def test_network_pinger(test_type, get_pinger_app, dns_format,
                        marathon_service_name):
    """This test runs a pinger app and a relay app. It retrieves the python app from the
       master via the new http service (which will be moving into shakedown). Then a curl call
       to the relay will invoke a call to the 2nd pinger app and return back pong to the relay
       then back to curl.

       It tests that 1 task can network communicate to another task on the given network
       It tests inbound and outbound connectivity

       test_type param is not used.  It is passed so that it is clear which parametrized test
       is running or may be failing.
    """
    pinger_app = get_pinger_app()
    relay_app = get_pinger_app()
    relay_app["id"] = relay_app["id"].replace("pinger", "relay")
    pinger_dns = dns_format.format(pinger_app["id"].lstrip("/"),
                                   marathon_service_name)
    relay_dns = dns_format.format(relay_app["id"].lstrip("/"),
                                  marathon_service_name)

    # test pinger app to master
    shakedown.copy_file_to_master(
        os.path.join(scripts.scripts_dir(), "pinger.py"))

    client = marathon.create_client()

    with shakedown.master_http_service():
        # need to add app with http service in place or it will fail to fetch
        client.add_app(pinger_app)
        client.add_app(relay_app)
        common.deployment_wait(service_id=pinger_app["id"])
        common.deployment_wait(service_id=relay_app["id"])
        shakedown.wait_for_dns(relay_dns)

    relay_url = 'http://{}:7777/relay-ping?url={}:7777'.format(
        relay_dns, pinger_dns)

    @retrying.retry(wait_fixed=1000,
                    stop_max_attempt_number=300,
                    retry_on_exception=common.ignore_exception)
    def http_output_check():
        status, output = shakedown.run_command_on_master(
            'curl {}'.format(relay_url))
        assert status, "curl {} failed on master with {}".format(
            relay_url, output)
        assert 'Pong {}'.format(pinger_app["id"]) in output
        assert 'Relay from {}'.format(relay_app["id"]) in output

    http_output_check()
Exemplo n.º 3
0
def test_network_pinger(test_type, get_pinger_app, dns_format, marathon_service_name):
    """This test runs a pinger app and a relay app. It retrieves the python app from the
       master via the new http service (which will be moving into shakedown). Then a curl call
       to the relay will invoke a call to the 2nd pinger app and return back pong to the relay
       then back to curl.

       It tests that 1 task can network communicate to another task on the given network
       It tests inbound and outbound connectivity

       test_type param is not used.  It is passed so that it is clear which parametrized test
       is running or may be failing.
    """
    pinger_app = get_pinger_app()
    relay_app = get_pinger_app()
    relay_app["id"] = relay_app["id"].replace("pinger", "relay")
    pinger_dns = dns_format.format(pinger_app["id"].lstrip("/"), marathon_service_name)
    relay_dns = dns_format.format(relay_app["id"].lstrip("/"), marathon_service_name)

    # test pinger app to master
    copy_file_to_master(os.path.join(scripts.scripts_dir(), "pinger.py"))

    client = marathon.create_client()

    with master_http_service():
        # need to add app with http service in place or it will fail to fetch
        client.add_app(pinger_app)
        client.add_app(relay_app)
        deployment_wait(service_id=pinger_app["id"])
        deployment_wait(service_id=relay_app["id"])
        wait_for_dns(relay_dns)

    relay_url = 'http://{}:7777/relay-ping?url={}:7777'.format(relay_dns, pinger_dns)

    @retrying.retry(wait_fixed=1000, stop_max_attempt_number=300, retry_on_exception=common.ignore_exception)
    def http_output_check():
        status, output = run_command_on_master('curl {}'.format(relay_url))
        assert status, "curl {} failed on master with {}".format(relay_url, output)
        assert 'Pong {}'.format(pinger_app["id"]) in output
        assert 'Relay from {}'.format(relay_app["id"]) in output

    http_output_check()
def partition_agent(hostname):
    """Partition a node from all network traffic except for SSH and loopback"""

    shakedown.dcos.file.copy_file_to_agent(hostname, "{}/net-services-agent.sh".format(scripts.scripts_dir()))
    logger.info("partitioning {}".format(hostname))
    shakedown.dcos.command.run_command_on_agent(hostname, 'sh net-services-agent.sh fail')