Beispiel #1
0
 def test_delete_route_no_binding(self, LoadBalancer):
     lb = LoadBalancer.find.return_value
     lb.hosts = [mock.Mock(), mock.Mock()]
     manager = Manager(self.config)
     with self.assertRaises(storage.InstanceNotFoundError):
         manager.delete_route("inst", "/zahadum")
     LoadBalancer.find.assert_called_with("inst")
Beispiel #2
0
 def test_delete_route_no_binding(self, LoadBalancer):
     lb = LoadBalancer.find.return_value
     lb.hosts = [mock.Mock(), mock.Mock()]
     manager = Manager(self.config)
     with self.assertRaises(storage.InstanceNotFoundError):
         manager.delete_route("inst", "/zahadum")
     LoadBalancer.find.assert_called_with("inst")
Beispiel #3
0
 def test_delete_route_no_binding(self, LoadBalancer, nginx):
     lb = LoadBalancer.find.return_value
     lb.hosts = [mock.Mock(), mock.Mock()]
     manager = Manager(self.config)
     with self.assertRaises(storage.InstanceNotFoundError):
         manager.delete_route('inst', '/zahadum')
     LoadBalancer.find.assert_called_with('inst')
     self.assertEqual(len(nginx.NginxDAV.return_value.mock_calls), 0)
Beispiel #4
0
    def test_delete_route_error_no_route(self, LoadBalancer):
        self.storage.store_binding("inst", "app.host.com")
        lb = LoadBalancer.find.return_value
        lb.hosts = [mock.Mock(), mock.Mock()]

        manager = Manager(self.config)
        with self.assertRaises(storage.InstanceNotFoundError):
            manager.delete_route("inst", "/somewhere")
        LoadBalancer.find.assert_called_with("inst")
Beispiel #5
0
    def test_delete_route_error_no_route(self, LoadBalancer):
        self.storage.store_binding("inst", "app.host.com")
        lb = LoadBalancer.find.return_value
        lb.hosts = [mock.Mock(), mock.Mock()]

        manager = Manager(self.config)
        with self.assertRaises(storage.InstanceNotFoundError):
            manager.delete_route("inst", "/somewhere")
        LoadBalancer.find.assert_called_with("inst")
Beispiel #6
0
    def test_delete_route(self, LoadBalancer):
        self.storage.store_binding("inst", "app.host.com")
        self.storage.replace_binding_path("inst", "/arrakis", "dune.com")
        lb = LoadBalancer.find.return_value
        lb.hosts = [mock.Mock(), mock.Mock()]

        manager = Manager(self.config)
        manager.consul_manager = mock.Mock()
        manager.delete_route("inst", "/arrakis")

        LoadBalancer.find.assert_called_with("inst")
        binding_data = self.storage.find_binding("inst")
        self.assertDictEqual(binding_data, {
            "_id": "inst",
            "app_host": "app.host.com",
            "paths": [{"path": "/", "destination": "app.host.com"}]
        })
        manager.consul_manager.remove_location.assert_called_with("inst", "/arrakis")
Beispiel #7
0
    def test_delete_route(self, LoadBalancer, nginx):
        self.storage.store_binding('inst', 'app.host.com')
        self.storage.replace_binding_path('inst', '/arrakis', 'dune.com')
        lb = LoadBalancer.find.return_value
        lb.hosts = [mock.Mock(), mock.Mock()]

        manager = Manager(self.config)
        manager.delete_route('inst', '/arrakis')

        LoadBalancer.find.assert_called_with('inst')
        binding_data = self.storage.find_binding('inst')
        self.assertDictEqual(binding_data, {
            '_id': 'inst',
            'app_host': 'app.host.com',
            'paths': [{'path': '/', 'destination': 'app.host.com'}]
        })
        nginx_manager = nginx.NginxDAV.return_value
        nginx_manager.delete_binding.assert_any_call(lb.hosts[0].dns_name, '/arrakis')
        nginx_manager.delete_binding.assert_any_call(lb.hosts[1].dns_name, '/arrakis')
Beispiel #8
0
    def test_delete_route(self, LoadBalancer, nginx):
        self.storage.store_binding("inst", "app.host.com")
        self.storage.replace_binding_path("inst", "/arrakis", "dune.com")
        lb = LoadBalancer.find.return_value
        lb.hosts = [mock.Mock(), mock.Mock()]

        manager = Manager(self.config)
        manager.delete_route("inst", "/arrakis")

        LoadBalancer.find.assert_called_with("inst")
        binding_data = self.storage.find_binding("inst")
        self.assertDictEqual(binding_data, {
            "_id": "inst",
            "app_host": "app.host.com",
            "paths": [{"path": "/", "destination": "app.host.com"}]
        })
        nginx_manager = nginx.NginxDAV.return_value
        nginx_manager.delete_binding.assert_any_call(lb.hosts[0].dns_name, "/arrakis")
        nginx_manager.delete_binding.assert_any_call(lb.hosts[1].dns_name, "/arrakis")
Beispiel #9
0
    def test_delete_route(self, LoadBalancer):
        self.storage.store_binding("inst", "app.host.com")
        self.storage.replace_binding_path("inst", "/arrakis", "dune.com")
        lb = LoadBalancer.find.return_value
        lb.hosts = [mock.Mock(), mock.Mock()]

        manager = Manager(self.config)
        manager.consul_manager = mock.Mock()
        manager.delete_route("inst", "/arrakis")

        LoadBalancer.find.assert_called_with("inst")
        binding_data = self.storage.find_binding("inst")
        self.assertDictEqual(
            binding_data, {
                "_id": "inst",
                "app_host": "app.host.com",
                "paths": [{
                    "path": "/",
                    "destination": "app.host.com"
                }]
            })
        manager.consul_manager.remove_location.assert_called_with(
            "inst", "/arrakis")
Beispiel #10
0
 def test_delete_route_error_task_running(self):
     self.storage.store_task("inst")
     manager = Manager(self.config)
     with self.assertRaises(rpaas.tasks.NotReadyError):
         manager.delete_route("inst", "/arrakis")
Beispiel #11
0
 def test_delete_route_error_task_running(self):
     self.storage.store_task("inst")
     manager = Manager(self.config)
     with self.assertRaises(rpaas.tasks.NotReadyError):
         manager.delete_route("inst", "/arrakis")
Beispiel #12
0
 def test_delete_route_error_task_running(self):
     self.storage.store_task('inst')
     manager = Manager(self.config)
     with self.assertRaises(rpaas.manager.NotReadyError):
         manager.delete_route('inst', '/arrakis')