human
Complete this python program:
def _service_discovery_test(dcos_api_session, docker_network_bridge):
assistant
#Here is the Python code you requested.

    """Service discovery integration test
    This test verifies if service discovery works, by comparing marathon data
    with information from mesos-dns and from containers themselves.
    This is achieved by deploying an application to marathon with two instances
    , and ["hostname", "UNIQUE"] constraint set. This should result in containers
    being deployed to two different slaves.
    The application being deployed is a simple http server written in python.
    Please check test_server.py for more details.
    Next thing is comparing the service points provided by marathon with those
    reported by mesos-dns. The tricky part here is that may take some time for
    mesos-dns to catch up with changes in the dcos_api_session.
    And finally, one of service points is verified in as-seen-by-other-containers
    fashion.
    |          Slave 1       |   |         Slave 2        |
    |              |    | |   App instance A   +------>+   App instance B   | |
    |   TC Agent   +<---->+                    | |   | |                    | |
    |              |    | |   "test server"    +<------+    "reflector"     | |
    Code running on TC agent connects to one of the containers (let\s call it
    "test server") and makes a POST request with IP and PORT service point of
    the second container as parameters (let\s call it "reflector"). The test
    server in turn connects to other container and makes a "GET /reflect"
    request. The reflector responds with test server\s IP as seen by it and
    the session UUID as provided to it by Marathon. This data is then returned
    to TC agent in response to POST request issued earlier.
    The test succeeds if test UUIDs of the test server, reflector and the test
    itself match and the IP of the test server matches the service point of that
    container as reported by Marathon.
    """
    if docker_network_bridge:
        (app_definition, test_uuid) = test_helpers.marathon_test_app(container_type=marathon.Container.DOCKER, network=marathon.Network.BRIDGE, container_port=2020, host_port=9080)
    else:
        (app_definition, test_uuid) = test_helpers.marathon_test_app(container_type=marathon.Container.DOCKER)
    app_definition['instances'] = 2
    assert (len(dcos_api_session.slaves) >= 2), 'Test    requires    a    minimum    of    two    agents'
    app_definition['constraints'] = [['hostname', 'UNIQUE']]
    with dcos_api_session.marathon.deploy_and_cleanup(app_definition):
        service_points = dcos_api_session.marathon.get_app_service_endpoints(app_definition['id'])
        @retrying.retry(wait_fixed=1000, stop_max_delay=(DNS_ENTRY_UPDATE_TIMEOUT * 1000), retry_on_result=(lambda ret: (ret is None)), retry_on_exception=(lambda x: False))
        def _pool_for_mesos_dns():
            r = dcos_api_session.get('/mesos_dns/v1/services/_{}._tcp.marathon.mesos'.format(app_definition['id'].lstrip('/')))
            assert (r.status_code == 200)
            r_data = r.json()
            if ((r_data == [{'host': '', 'port': '', 'service': '', 'ip': ''}]) or (len(r_data) < len(service_points))):
                logging.info('Waiting    for    Mesos-DNS    to    update    entries')
                return None
            else:
                logging.info('Mesos-DNS    entries    have    been    updated!')
                return r_data
        try:
            r_data = _pool_for_mesos_dns()
        except retrying.RetryError:
            msg = 'Mesos    DNS    has    failed    to    update    entries    in    {}    seconds.'
            pytest.fail(msg.format(DNS_ENTRY_UPDATE_TIMEOUT))
        marathon_provided_servicepoints = sorted(((x.host, x.port) for x in service_points))
        mesosdns_provided_servicepoints = sorted(((x['ip'], int(x['port'])) for x in r_data))
        assert (marathon_provided_servicepoints == mesosdns_provided_servicepoints)
        payload = {'reflector_ip':...