Beispiel #1
0
    def test_trigger(self):
        """Test the trigger interface from the service perspective.
        """
        promoted = [None]

        def _another_my_event(param, ignored):
            """Decorator or Inner function.
            """
            promoted[0] = param

        _events.Handler().register(_NEW_SERVER_PROMOTED, _another_my_event)
        packet = self.proxy.event.trigger(
            "_NEW_SERVER_PROMOTED",
            ["lock_a", "lock_b"],
            ["my.example.com", ""],
        )
        result = _xmlrpc._decode(packet)
        self.assertTrue(len(result.results) > 0)
        self.assertEqual(result.results[0].rowcount, 2)
        jobs = [str(row[0]) for row in result.results[0]]
        try:
            self.proxy.event.wait_for_procedures(jobs)
            self.assertEqual(promoted[0], "my.example.com")
        except Exception as error:
            if str(error).find("was not found") == -1:
                raise
        _events.Handler().unregister(_NEW_SERVER_PROMOTED, _another_my_event)
Beispiel #2
0
def _shutdown():
    """Shutdown Fabric server.
    """
    _failure_detector.FailureDetector.unregister_groups()
    _services.ServiceManager().shutdown()
    _events.Handler().shutdown()
    _events.Handler().wait()
    _LOGGER.info("Fabric node stopped.",
                 extra={
                     'subject': 'Node',
                     'category': MySQLHandler.NODE,
                     'type': MySQLHandler.STOP
                 })
Beispiel #3
0
def _start(options, config):
    """Start Fabric server.
    """

    # Remove temporary defaults file, which migh have left behind
    # by former runs of Fabric.
    _backup.cleanup_temp_defaults_files()

    #Configure TTL
    _setup_ttl(config)

    # Configure modules that are not dynamic loaded.
    _server.configure(config)
    _error_log.configure(config)
    _failure_detector.configure(config)

    # Load information on all providers.
    providers.find_providers()

    # Load all services into the service manager
    _services.ServiceManager().load_services(options, config)

    # Initilize the state store.
    _persistence.init_thread()

    # Check the maximum number of threads.
    _utils.check_number_threads()

    # Configure Fabric Node.
    fabric = FabricNode()
    reported = _utils.get_time()
    _LOGGER.info("Fabric node version (%s) started. ",
                 fabric.version,
                 extra={
                     'subject': str(fabric.uuid),
                     'category': MySQLHandler.NODE,
                     'type': MySQLHandler.START,
                     'reported': reported
                 })
    fabric.startup = reported

    # Start the executor, failure detector and then service manager. In this
    # scenario, the recovery is sequentially executed after starting the
    # executor and before starting the service manager.
    _events.Handler().start()
    _recovery.recovery()
    _failure_detector.FailureDetector.register_groups()
    _services.ServiceManager().start()
Beispiel #4
0
class TestDecorator(unittest.TestCase):
    """Test the decorators related to events.
    """
    handler = _events.Handler()

    def setUp(self):
        """Configure the existing environment
        """
        pass

    def tearDown(self):
        """Clean up the existing environment
        """
        tests.utils.cleanup_environment()

    def test_decorator(self):
        """Test decorator related to events.
        """
        global _PROMOTED, _DEMOTED
        _PROMOTED = None

        # Test decorator
        _PROMOTED = None
        jobs = self.handler.trigger(False, _NEW_SERVER_PROMOTED, set(["lock"]),
                                    "Testing", "")
        for job in jobs:
            job.wait()
        self.assertEqual(_PROMOTED, "Testing")

        # Test undo action for decorator
        _DEMOTED = None
        jobs = self.handler.trigger(False, _NEW_SERVER_DEMOTED, set(["lock"]),
                                    "Executing", "")
        for job in jobs:
            job.wait()
        self.assertEqual(_DEMOTED, "Undone")
Beispiel #5
0
 def setUp(self):
     """Configure the existing environment
     """
     self.handler = _events.Handler()