コード例 #1
0
 def check_dns():
     dnsname = '{}.{}.mesos'.format(app_def["id"].lstrip('/'),
                                    marathon_service_name)
     cmd = 'ping -c 1 {}'.format(dnsname)
     shakedown.wait_for_dns(dnsname)
     status, output = shakedown.run_command_on_master(cmd)
     assert status, "ping failed for app using DNS lookup: {}".format(
         dnsname)
コード例 #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()
コード例 #3
0
def test_network_pinger(test_type, get_pinger_app, dns_format):
    """ 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.
    """
    marathon_service_name = get_marathon_service_name()
    client = marathon.create_client()
    pinger_app = get_pinger_app(
        'pinger'
    )  #add_container_network(common.pinger_localhost_app(), 'dcos')
    relay_app = get_pinger_app(
        'relay'
    )  #add_container_network(common.pinger_localhost_app('relay'), 'dcos')
    pinger_dns = dns_format.format('pinger', marathon_service_name)
    relay_dns = dns_format.format('relay', marathon_service_name)

    # test pinger app to master
    shakedown.copy_file_to_master(fixture_dir() + "/pinger.py")

    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)
        shakedown.deployment_wait()
        shakedown.wait_for_dns(relay_dns)

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

    @retrying.retry
    def http_output_check(stop_max_attempt_number=30):
        status, output = shakedown.run_command_on_master(
            'curl {}'.format(relay_url))
        assert status
        assert 'Pong /pinger' in output
        assert 'Relay from /relay' in output

    http_output_check()
コード例 #4
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.
    """
    client = marathon.create_client()
    pinger_app = get_pinger_app('pinger')
    relay_app = get_pinger_app('relay')
    pinger_dns = dns_format.format('pinger', marathon_service_name)
    relay_dns = dns_format.format('relay', marathon_service_name)

    # test pinger app to master
    shakedown.copy_file_to_master(fixture_dir() + "/pinger.py")

    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)
        shakedown.deployment_wait()
        shakedown.wait_for_dns(relay_dns)

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

    @retrying.retry
    def http_output_check(stop_max_attempt_number=30):
        status, output = shakedown.run_command_on_master('curl {}'.format(relay_url))
        assert status
        assert 'Pong /pinger' in output
        assert 'Relay from /relay' in output

    http_output_check()
コード例 #5
0
 def check_dns():
     cmd = 'ping -c 1 {}.{}.mesos'.format(app_id, marathon_service_name)
     shakedown.wait_for_dns('{}.{}.mesos'.format(app_id, marathon_service_name))
     status, output = shakedown.run_command_on_master(cmd)
     assert status
コード例 #6
0
 def check_dns():
     dnsname = '{}.{}.mesos'.format(app_def["id"].lstrip('/'), marathon_service_name)
     cmd = 'ping -c 1 {}'.format(dnsname)
     shakedown.wait_for_dns(dnsname)
     status, output = shakedown.run_command_on_master(cmd)
     assert status, "ping failed for app using DNS lookup: {}".format(dnsname)