<s> import os <EOL> from nose . plugins . attrib import attr <EOL> from tests . no_hadoop_bare_image_provider import NoHadoopBareImageProvider <EOL> from tests . product . base_product_case import BaseProductTestCase , docker_only <EOL> from tests . product . constants import LOCAL_RESOURCES_DIR <EOL> topology_with_slave1_coord = """<STR_LIT>""" <EOL> normal_topology = """<STR_LIT>""" <EOL> local_topology = """<STR_LIT>""" <EOL> class TestTopologyShow ( BaseProductTestCase ) : <EOL> def setUp ( self ) : <EOL> super ( TestTopologyShow , self ) . setUp ( ) <EOL> self . setup_cluster ( NoHadoopBareImageProvider ( ) , self . PA_ONLY_CLUSTER ) <EOL> @ attr ( '<STR_LIT>' ) <EOL> def test_topology_show ( self ) : <EOL> self . upload_topology ( ) <EOL> actual = self . run_prestoadmin ( '<STR_LIT>' ) <EOL> expected = normal_topology <EOL> self . assertEqual ( expected , actual ) <EOL> @ docker_only <EOL> def test_topology_show_coord_down ( self ) : <EOL> topology = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] } <EOL> self . upload_topology ( topology = topology ) <EOL> self . cluster . stop_host ( <EOL> self . cluster . slaves [ <NUM_LIT:0> ] ) <EOL> actual = self . run_prestoadmin ( '<STR_LIT>' ) <EOL> expected = topology_with_slave1_coord <EOL> self . assertEqual ( expected , actual ) <EOL> @ docker_only <EOL> def test_topology_show_worker_down ( self ) : <EOL> self . upload_topology ( ) <EOL> self . cluster . stop_host ( <EOL> self . cluster . slaves [ <NUM_LIT:0> ] ) <EOL> actual = self . run_prestoadmin ( '<STR_LIT>' ) <EOL> expected = normal_topology <EOL> self . assertEqual ( expected , actual ) <EOL> def test_topology_show_empty_config ( self ) : <EOL> self . dump_and_cp_topology ( topology = { } ) <EOL> actual = self . run_prestoadmin ( '<STR_LIT>' ) <EOL> self . assertEqual ( local_topology , actual ) <EOL> def test_topology_show_bad_json ( self ) : <EOL> self . cluster . copy_to_host ( <EOL> os . path . join ( LOCAL_RESOURCES_DIR , '<STR_LIT>' ) , <EOL> self . cluster . master <EOL> ) <EOL> self . cluster . exec_cmd_on_host ( <EOL> self . cluster . master , <EOL> '<STR_LIT>' % <EOL> os . path . join ( self . cluster . mount_dir , '<STR_LIT>' ) <EOL> ) <EOL> self . assertRaisesRegexp ( OSError , <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' , <EOL> self . run_prestoadmin , <EOL> '<STR_LIT>' ) </s>
