Exemple #1
0
    def test__checks_connectivity_of_rack_controllers(self):
        getAllClients = self.patch(middleware_module, 'getAllClients')

        request = factory.make_fake_request(factory.make_string(), 'GET')
        middleware = ExternalComponentsMiddleware()
        middleware.process_request(request)

        self.assertThat(getAllClients, MockCalledOnceWith())
Exemple #2
0
    def test__registers_error_if_all_rack_controllers_are_disconnected(self):
        factory.make_RackController()

        getAllClients = self.patch(middleware_module, 'getAllClients')
        getAllClients.return_value = []

        request = factory.make_fake_request(factory.make_string(), 'GET')
        middleware = ExternalComponentsMiddleware()
        middleware.process_request(request)

        error = get_persistent_error(COMPONENT.RACK_CONTROLLERS)
        self.assertEqual(
            "One rack controller is not yet connected to the region. Visit "
            "the <a href=\"%s#/nodes?tab=controllers\">"
            "rack controllers page</a> for more "
            "information." % (reverse('index')), error)
Exemple #3
0
    def test__removes_error_once_all_clusters_are_connected(self):
        rack_controllers = [
            factory.make_RackController(),
            factory.make_RackController(),
        ]

        getAllClients = self.patch(middleware_module, 'getAllClients')
        getAllClients.return_value = [
            Mock(ident=rack.system_id) for rack in rack_controllers
        ]

        register_persistent_error(COMPONENT.RACK_CONTROLLERS,
                                  "Who flung that batter pudding?")

        request = factory.make_fake_request(factory.make_string(), 'GET')
        middleware = ExternalComponentsMiddleware()
        middleware.process_request(request)

        error = get_persistent_error(COMPONENT.RACK_CONTROLLERS)
        self.assertIsNone(error)