def test_if_search_is_working(dcos_api_session):
 (app_definition, test_uuid) = get_test_app()
 with dcos_api_session.marathon.deploy_and_cleanup(app_definition) as service_points:
  r = requests.get('http://{}:{}/dns_search'.format(service_points[0].host, service_points[0].port))
  if (r.status_code != 200):
   msg = "Test server replied with non-200 reply: '{0} {1}. "
   msg += 'Detailed explanation of the problem: {2}'
   pytest.fail(msg.format(r.status_code, r.reason, r.text))
  r_data = r.json()
  assert (r_data['test_uuid'] == test_uuid)
  expected_error = {'error': '[Errno -2] Name or service not known'}
  if dcos_config['dns_search']:
   assert (r_data['search_hit_leader'] in dcos_api_session.masters)
   assert (r_data['always_hit_leader'] in dcos_api_session.masters)
   assert (r_data['always_miss'] == expected_error)
  else:
   assert (r_data['search_hit_leader'] == expected_error)
   assert (r_data['always_hit_leader'] in dcos_api_session.masters)
   assert (r_data['always_miss'] == expected_error)

def test_if_search_is_working ( dcos_api_session ) : ( app_definition , test_uuid ) = get_test_app ( ) with dcos_api_session . marathon . deploy_and_cleanup ( app_definition ) as service_points : r = requests . get ( 'http://{}:{}/dns_search' . format ( service_points [ 0 ] . host , service_points [ 0 ] . port ) ) if ( r . status_code != 200 ) : msg = "Test server replied with non-200 reply: '{0} {1}. " msg += 'Detailed explanation of the problem: {2}' pytest . fail ( msg . format ( r . status_code , r . reason , r . text ) ) r_data = r . json ( ) assert ( r_data [ 'test_uuid' ] == test_uuid ) expected_error = { 'error' : '[Errno -2] Name or service not known' } if dcos_config [ 'dns_search' ] : assert ( r_data [ 'search_hit_leader' ] in dcos_api_session . masters ) assert ( r_data [ 'always_hit_leader' ] in dcos_api_session . masters ) assert ( r_data [ 'always_miss' ] == expected_error ) else : assert ( r_data [ 'search_hit_leader' ] == expected_error ) assert ( r_data [ 'always_hit_leader' ] in dcos_api_session . masters ) assert ( r_data [ 'always_miss' ] == expected_error )
test if custom set search is working .