Пример #1
0
 def test_create_hook(self):
     bus.base_path = os.path.realpath(os.path.dirname(__file__) + "/../../..")
     config = ConfigParser()
     config.read(bus.base_path + "/etc/config.ini")
     bus.config = config
     init_tests()
     resources_path = os.path.realpath(os.path.dirname(__file__) + "/../../" + "resources")
     bus.base_path = resources_path
     server_id = config.get(configtool.SECT_GENERAL, configtool.OPT_SERVER_ID)
     bus.define_events("init", "test")
     handler = hooks.HooksHandler()
     bus.fire('init')
     bus.fire("test", "test_2_done", aenv="test_3_done")
     #absolutely valid script created an empty file
     self.assertTrue(os.path.exists(resources_path + "/hooks/test_1_done"))
     #next script created a file named as 1st execution parameter
     self.assertTrue(os.path.exists(resources_path + "/hooks/test_2_done"))
     #3rd script touched file named $aenv
     self.assertTrue(os.path.exists(resources_path + "/hooks/test_3_done"))
     #test 4 touched file named server_id
     self.assertTrue(os.path.exists(resources_path + "/hooks/" + server_id))
     #test 5 doesn`t have an execution bit
     self.assertFalse(os.path.exists(resources_path + "/hooks/test_5_done"))
     #test 6 tried to execute script file with Exec format error
     self.assertFalse(os.path.exists(resources_path + "/hooks/test_6_done"))
     #test 7 consists an execution error
     self.assertTrue(os.path.exists(resources_path + "/hooks/test_7_done"))
     #test8 script has not a valid name , so supposed not to be executed
     self.assertFalse(os.path.exists(resources_path + "/hooks/test_8_done"))
Пример #2
0
    def list_role_params(self, role_name):
        return _Bunch(
                mysql_data_storage_engine = self.storage,
                mysql_master_ebs_volume_id = 'test-id',
                ebs_snap_id = 'test_snap_id'
                )

class _Platform:
    def get_instance_id(self):
        pass

    def get_block_device_mapping(self):
        return {'ephemeral0' : 'eph0'}

class _Message:
    def __init__(self):
        self.repl_user = None
        self.repl_password = None
        self.log_file = None
        self.log_pos  = None
        self.mysql_repl_user = None
        self.mysql_repl_password = None
        self.mysql_stat_password = None
        self.mysql_stat_user = None
        self.local_ip = LOCAL_IP
        self.mysql_replication_master = 1

if __name__ == "__main__":
    init_tests()
    unittest.main()
Пример #3
0
        self._logger.addHandler(self._handler)
 
        num_it = 3
        num_msg = 5
        # Do `num_it` iterations
        for i in range(num_it):
            # Do logging
            for msg in range(num_msg):
                self._logger.info("test_num_entries, iteration %d, entry %d", i, msg)
 
            message = self._wait_sender()
            # Assertions
            self.assertEqual(len(message.entries), num_msg)
 
 
    def _wait_sender(self):
        timeout = 1
        start = time.time()
        while self._msg_producer.last_message is None and time.time() - start < timeout:
            time.sleep(0.05)
        message = self._msg_producer.last_message
        self._msg_producer.last_message = None
        print message
        return message
 
 
if __name__ == "__main__":
    init_tests()
    unittest.main()