Beispiel #1
0
 def test_populate_on_worker_without_import_services(self):
     self.patch(eventloop.services, "getServiceNamed")
     an_eventloop = eventloop.RegionEventLoop()
     # At first there are no services.
     self.assertEqual(set(),
                      {service.name
                       for service in an_eventloop.services})
     # populate() creates a service with each factory.
     an_eventloop.populate(master=False).wait(30)
     self.assertEqual(
         {
             name
             for name, item in an_eventloop.factories.items()
             if item["only_on_master"] is False and (
                 item.get('import_service', False) is False)
         }, {svc.name
             for svc in an_eventloop.services})
     # The services are not started.
     self.assertEqual(
         {
             name: False
             for name, item in an_eventloop.factories.items()
             if item["only_on_master"] is False and (
                 item.get('import_service', False) is False)
         }, {svc.name: svc.running
             for svc in an_eventloop.services})
Beispiel #2
0
 def test_populate_on_all_in_one(self):
     self.patch(eventloop.services, "getServiceNamed")
     an_eventloop = eventloop.RegionEventLoop()
     # At first there are no services.
     self.assertEqual(set(),
                      {service.name
                       for service in an_eventloop.services})
     # populate() creates a service with each factory.
     an_eventloop.populate(master=True,
                           all_in_one=True,
                           import_services=True).wait(30)
     self.assertEqual(
         {
             name
             for name, item in an_eventloop.factories.items()
             if item.get("not_all_in_one", False) is False
         }, {svc.name
             for svc in an_eventloop.services})
     # The services are not started.
     self.assertEqual(
         {
             name: False
             for name, item in an_eventloop.factories.items()
             if item.get("not_all_in_one", False) is False
         }, {svc.name: svc.running
             for svc in an_eventloop.services})
Beispiel #3
0
 def test_populate_not_on_master(self):
     self.patch(eventloop.services, "getServiceNamed")
     self.patch(eventloop, "is_master_process").return_value = False
     an_eventloop = eventloop.RegionEventLoop()
     # At first there are no services.
     self.assertEqual(set(),
                      {service.name
                       for service in an_eventloop.services})
     # populate() creates a service with each factory.
     an_eventloop.populate().wait(30)
     self.assertEqual(
         {
             name
             for name, item in an_eventloop.factories.items()
             if item["only_on_master"] is False
         }, {svc.name
             for svc in an_eventloop.services})
     # The services are not started.
     self.assertEqual(
         {
             name: False
             for name, item in an_eventloop.factories.items()
             if item["only_on_master"] is False
         }, {svc.name: svc.running
             for svc in an_eventloop.services})
Beispiel #4
0
    def test_populateService_prevent_worker_service_on_master(self):
        self.patch(eventloop.services, "getServiceNamed")
        an_eventloop = eventloop.RegionEventLoop()

        @asynchronous
        def tryPopulate(*args, **kwargs):
            self.assertRaises(ValueError, an_eventloop.populateService, *args,
                              **kwargs)

        tryPopulate('web', master=True).wait(30)