def test_register_interface_module(self):
        """
        Registering and deregistering API interfaces
        
        Verifies:
            * only specified API interfaces are added and removed
            * existing attributes and functions are added to the new API
        """
        manager = ModuleManager()
        api0 = TestAPI()
        api1 = TestAPI()
        module = Bar()

        interfaces = ((module, module.foo), (module, module.bar), (module, "xoo"), (module, "zoo"))
        interface_names = ("foo", "bar", "xoo", "zoo")

        for interface in interfaces:
            manager.register_interface(*interface)

        manager.register_interface_module(api0)
        manager.register_interface_module(api1)

        self.assert_(api0 in manager._interface_modules)
        for name in interface_names:
            self.assert_(name in api0._registered_interfaces)
            self.assert_(name in api1._registered_interfaces)
Example #2
0
    def __init__(self):
        logger.info('=========================================================')
        logger.info('=================== starting master =====================')
        logger.info('=========================================================')

        """
        List of modules to load.  They will be loaded sequentially
        """
        self.modules = [
            AutoDiscoveryModule,
            NodeConnectionManager,
            TaskManager,
            TaskSyncServer,
            TaskScheduler,
	    StatisticsModule,
            TwistedWebInterface,
            NodeManager,
            MasterLogAggregator
        ]

        if hasattr(pydra_settings, 'cloud_provisioning_support') and pydra_settings.cloud_provisioning_support:
            self.modules += [CloudProvisioningModule]

        ModuleManager.__init__(self)

        self.emit_signal('MANAGER_INIT')
    def test_register_service(self):
        """
        Registering and deregistering twisted services
        
        Verifies:
            * only specified service is added and removed
        """
        manager = ModuleManager()
        module = Bar()

        manager.register_service(module.foo)
        self.assert_(module.foo in manager._services)

        manager.register_service(module.bar)
        self.assert_(module.foo in manager._services)
        self.assert_(module.bar in manager._services)

        services = manager.get_services()
        self.assert_("foo return" in services)
        self.assert_("bar return" in services)

        manager.deregister_service(module.bar)
        self.assert_(module.foo in manager._services)
        self.assertFalse(module.bar in manager._services)

        manager.deregister_service(module.foo)
        self.assertFalse(module.foo in manager._services)
 def test_register(self):
     """
     Tests registering the module with a manager
     """
     manager = ModuleManager()
     module = MasterLogAggregator()
     manager.register(module)
     self.assert_(module in manager._modules)
 def test_register(self):
     """
     Tests registering the module with a manager
     """
     manager = ModuleManager()
     api = TestAPI()
     manager.register(api)
     manager.register(self.module)
     self.assert_(self.module in manager._modules)
 def test_register(self):
     """
     Tests registering the module with a manager
     """
     manager = ModuleManager()
     module = NodeZeroConfService()
     api = TestAPI()
     manager.register(api)
     manager.register(module)
     self.assert_(module in manager._modules)
 def test_register(self):
     """
     Tests registering the module with a manager
     """
     manager = ModuleManager()
     module = WorkerTaskControls()
     api = TestAPI()
     manager.register(api)
     manager.register(module)
     self.assert_(module in manager._modules)
 def test_register(self):
     """
     Tests registering the module with a manager
     """
     manager = ModuleManager()
     module = master_connection_manager.MasterConnectionManager()
     api = TestAPI()
     manager.register(api)
     manager.register(module)
     self.assert_(module in manager._modules)
    def test_register_module(self):
        """
        Registering and deregistering modules
        
        Verifies:
            * only specified modules are added and removed
            * listeners, remotes, interfaces, interface_modules, services are
              registered and deregistered
        """
        manager = ModuleManager()
        module = Bar()
        api = TestAPI()

        # verify everything is registered
        manager.register(module)
        manager.register(api)
        self.assert_(module in manager._modules)
        self.assert_("REMOTE0" in manager._remotes, manager._remotes)
        self.assert_("foo" in manager._remotes["REMOTE0"])
        self.assert_("SIGNAL0" in manager._listeners)
        self.assert_(module.foo in manager._listeners["SIGNAL0"])
        self.assert_((module, module.foo) in manager._interfaces)
        self.assert_(module.foo in manager._services)
        self.assert_(api in manager._interface_modules)

        # verify everything is deregistered
        manager.deregister(module)
        manager.deregister(api)
        self.assertFalse(module in manager._modules)
        self.assertFalse("REMOTE0" in manager._remotes, manager._remotes)
        self.assertFalse("SIGNAL0" in manager._listeners)
        self.assertFalse((module, module.foo) in manager._interfaces)
        self.assertFalse(module.foo in manager._services)
        self.assertFalse(api in manager._interface_modules)
Example #10
0
    def __init__(self, port, worker_key):

        self.master_port = port
        self.worker_key = worker_key
        logger = init_logging(pydra_settings.LOG_FILENAME_NODE, '[%s]' % worker_key)

        self.modules = [
            TaskManager(None, True),
            WorkerConnectionManager,
            WorkerTaskControls,
        ]

        ModuleManager.__init__(self)

        self.emit_signal('MANAGER_INIT')
        logger.info('Started Worker: %s' % worker_key)
Example #11
0
    def __init__(self):

        logger.info('=========================================================')
        logger.info('=================== Node - Starting =====================')
        logger.info('=========================================================')

        self.modules = [
            TaskManager(None, True),
            NodeInformation,
            WorkerManager,
            WorkerConnectionManager,
            MasterConnectionManager,
            TaskSyncClient,
            NodeZeroConfService,
            NodeLogAggregator,
        ]

        ModuleManager.__init__(self)

        self.emit_signal('MANAGER_INIT')
        logger.info('Node - Started')
Example #12
0
 def test_shared_attributes(self):
     """
     tests shared attributes:
     
     Verifies:
         * setting and getting attribute from different modules
     """
     manager = ModuleManager()
     module0 = TestModule()
     module1 = TestModule2()
     
     manager.register(module0)
     manager.register(module1)
     
     module0.foo = 123
     self.assertEqual(module0.foo, 123)
     self.assertEqual(module1.foo, 123)
     
     module1.foo = 456
     self.assertEqual(module0.foo, 456)
     self.assertEqual(module1.foo, 456)
Example #13
0
    def __init__(self):
        logger.info('=========================================================')
        logger.info('=================== starting master =====================')
        logger.info('=========================================================')

        """
        List of modules to load.  They will be loaded sequentially
        """
        self.modules = [
            AutoDiscoveryModule,
            NodeConnectionManager,
            TaskManager,
            TaskSyncServer,
            TaskScheduler,
            TwistedWebInterface,
            NodeManager,
            MasterLogAggregator
        ]

        ModuleManager.__init__(self)

        self.emit_signal('MANAGER_INIT')
    def test_emit(self):
        """
        Tests signals
        
        Verifies:
            * emitting registered signal calls mapped functions
            * emitting unregistered signal doesn't raise an exception
        """
        manager = ModuleManager()
        module0 = Foo()
        module1 = Xoo()
        manager.register_listener("FOO", module0.foo)
        manager.register_listener("FOO", module1.foo)
        manager.register_listener("BAR", module0.bar)

        args = (1, 2, 3)
        kwargs = {"a": 1, "b": 2}
        manager.emit_signal("FOO")
        manager.emit_signal("BAR", *args, **kwargs)

        module0.foo.assertCalled(self)
        module1.foo.assertCalled(self)
        module0.bar.assertCalled(self, *args, **kwargs)
    def test_register_interface(self):
        """
        Registering and deregistering attributes and functions exposed to the
        API
        
        Verifies:
            * only specified functions and attributes are added and removed
            * functions are added to all registered interfaces
            * name can be given as a param
            * functions can be replaced
        """
        manager = ModuleManager()
        api0 = TestAPI()
        api1 = TestAPI()
        module = Bar()

        manager.register_interface_module(api0)
        manager.register_interface_module(api1)

        interfaces = (
            (module, module.foo),
            (module, module.bar),
            (module, "xoo"),
            (module, "zoo"),
            (module, (module.foo, {"name": "foo2"})),
        )

        interface_names = ("foo", "bar", "xoo", "zoo")

        for interface in interfaces:
            manager.register_interface(*interface)

        for interface in interfaces:
            self.assert_(interface in manager._interfaces)

        for name in interface_names:
            self.assert_(name in api0._registered_interfaces)
            self.assert_(name in api1._registered_interfaces)

        for interface in interfaces:
            manager.deregister_interface(*interface)

        for interface in interfaces:
            self.assertFalse(interface in manager._interfaces)

        self.assertFalse(api0._interfaces)
        self.assertFalse(api1._interfaces)
    def test_register_remote(self):
        """
        Registering and deregistering remotely exposed attributes and functions
        
        Verifies:
            * only specified remote is added and removed
            * attributes are wrapped
            * functions are mappable
            * methods can have secure param
            * remote is removed if no more mapped functions exist
        """
        manager = ModuleManager()
        module = Bar()
        manager.register_remote(module, "REMOTE0", module.foo)
        manager.register_remote(module, "REMOTE0", (module.bar, True))
        manager.register_remote(module, "REMOTE1", "xoo")
        manager.register_remote(module, "REMOTE1", ("zoo", True))

        self.assert_("REMOTE0" in manager._remotes)
        self.assert_("REMOTE1" in manager._remotes)

        remotes0 = manager._remotes["REMOTE0"]
        remotes1 = manager._remotes["REMOTE1"]
        self.assert_("foo" in remotes0)
        self.assert_("bar" in remotes0)
        self.assert_("xoo" in remotes1)
        self.assert_("zoo" in remotes1)

        manager.deregister_remote(module, "REMOTE0", module.foo)
        manager.deregister_remote(module, "REMOTE0", (module.bar, True))
        manager.deregister_remote(module, "REMOTE1", "xoo")
        manager.deregister_remote(module, "REMOTE1", ("zoo", True))

        self.assertFalse("REMOTE0" in manager._remotes)
        self.assertFalse("REMOTE1" in manager._remotes)
        self.assertFalse(manager._remotes)
    def test_register_listener(self):
        """
        Registering and deregistering signal listeners
        
        Verifies:
            * only specified functions are added
            * removing the last function for a signal removes the signal
        """
        manager = ModuleManager()
        module = Foo()
        manager.register_listener("SIGNAL", module.foo)
        manager.register_listener("SIGNAL", module.bar)
        manager.register_listener("SIGNAL2", module.xoo)
        self.assert_("SIGNAL" in manager._listeners)
        self.assert_(module.foo in manager._listeners["SIGNAL"])
        self.assert_(module.bar in manager._listeners["SIGNAL"])
        self.assert_("SIGNAL2" in manager._listeners)
        self.assert_(module.xoo in manager._listeners["SIGNAL2"])

        manager.deregister_listener("SIGNAL", module.foo)
        self.assert_("SIGNAL" in manager._listeners)
        self.assert_(module.bar in manager._listeners["SIGNAL"])
        self.assert_("SIGNAL2" in manager._listeners)
        self.assert_(module.xoo in manager._listeners["SIGNAL2"])

        manager.deregister_listener("SIGNAL", module.bar)
        manager.deregister_listener("SIGNAL2", module.xoo)
        self.assertFalse("SIGNAL" in manager._listeners, "signal should be removed when no listeners")
        self.assertFalse("SIGNAL2" in manager._listeners, "signal should be removed when no listeners")