Beispiel #1
0
    def test_info_with_binding(self, LoadBalancer):
        self.storage.store_binding("inst", "app.host.com")
        self.storage.replace_binding_path("inst", "/arrakis", None,
                                          "location /x {\n}")
        lb = LoadBalancer.find.return_value
        lb.address = "192.168.1.1"
        lb.hosts = [mock.Mock(), mock.Mock()]
        manager = Manager(self.config)
        info = manager.info("inst")
        LoadBalancer.find.assert_called_with("inst")
        self.assertItemsEqual(info, [
            {
                "label": "Address",
                "value": "192.168.1.1"
            },
            {
                "label": "Instances",
                "value": "2"
            },
            {
                "label":
                "Routes",
                "value":
                """path = /
destination = app.host.com
path = /arrakis
content = location /x {
}"""
            },
        ])
        self.assertEqual(manager.status("inst"), "192.168.1.1")
Beispiel #2
0
 def test_info_with_plan(self, LoadBalancer):
     lb = LoadBalancer.find.return_value
     lb.address = "192.168.1.1"
     self.storage.store_instance_metadata("x", plan_name="small")
     self.addCleanup(self.storage.remove_instance_metadata, "x")
     manager = Manager(self.config)
     info = manager.info("x")
     LoadBalancer.find.assert_called_with("x")
     self.assertItemsEqual(info, [
         {
             "label": "Address",
             "value": "192.168.1.1"
         },
         {
             "label": "Instances",
             "value": "0"
         },
         {
             "label": "Routes",
             "value": ""
         },
         {
             "label": "Plan",
             "value": "small"
         },
     ])
     self.assertEqual(manager.status("x"), "192.168.1.1")
Beispiel #3
0
 def test_info(self, LoadBalancer):
     lb = LoadBalancer.find.return_value
     lb.address = "192.168.1.1"
     manager = Manager(self.config)
     info = manager.info("x")
     LoadBalancer.find.assert_called_with("x")
     self.assertItemsEqual(info, [
         {"label": "Address", "value": "192.168.1.1"},
         {"label": "Instances", "value": "0"},
         {"label": "Routes", "value": ""},
     ])
     self.assertEqual(manager.status("x"), "192.168.1.1")
Beispiel #4
0
 def test_info(self, LoadBalancer):
     lb = LoadBalancer.find.return_value
     lb.address = "192.168.1.1"
     manager = Manager(self.config)
     info = manager.info("x")
     LoadBalancer.find.assert_called_with("x")
     self.assertItemsEqual(info, [
         {"label": "Address", "value": "192.168.1.1"},
         {"label": "Instances", "value": "0"},
         {"label": "Routes", "value": ""},
     ])
     self.assertEqual(manager.status("x"), "192.168.1.1")
Beispiel #5
0
 def test_info_status_failure(self, tasks):
     self.storage.store_task("x")
     self.storage.update_task("x", "something-id")
     async_init = tasks.NewInstanceTask.return_value.AsyncResult
     async_init.return_value.status = "FAILURE"
     manager = Manager(self.config)
     info = manager.info("x")
     self.assertItemsEqual(info, [
         {"label": "Address", "value": "failure"},
         {"label": "Instances", "value": "0"},
         {"label": "Routes", "value": ""},
     ])
     async_init.assert_called_with("something-id")
     self.assertEqual(manager.status("x"), "failure")
Beispiel #6
0
 def test_info_status_pending(self, tasks):
     self.storage.store_task('x')
     self.storage.update_task('x', 'something-id')
     async_init = tasks.NewInstanceTask.return_value.AsyncResult
     async_init.return_value.status = 'PENDING'
     manager = Manager(self.config)
     info = manager.info('x')
     self.assertItemsEqual(info, [
         {"label": "Address", "value": "pending"},
         {"label": "Instances", "value": "0"},
         {"label": "Routes", "value": ""},
     ])
     async_init.assert_called_with('something-id')
     self.assertEqual(manager.status('x'), 'pending')
Beispiel #7
0
 def test_info_status_failure(self, tasks):
     self.storage.store_task("x")
     self.storage.update_task("x", "something-id")
     async_init = tasks.NewInstanceTask.return_value.AsyncResult
     async_init.return_value.status = "FAILURE"
     manager = Manager(self.config)
     info = manager.info("x")
     self.assertItemsEqual(info, [
         {"label": "Address", "value": "failure"},
         {"label": "Instances", "value": "0"},
         {"label": "Routes", "value": ""},
     ])
     async_init.assert_called_with("something-id")
     self.assertEqual(manager.status("x"), "failure")
Beispiel #8
0
 def test_info_with_plan(self, LoadBalancer):
     lb = LoadBalancer.find.return_value
     lb.address = "192.168.1.1"
     self.storage.store_instance_metadata("x", plan_name="small")
     self.addCleanup(self.storage.remove_instance_metadata, "x")
     manager = Manager(self.config)
     info = manager.info("x")
     LoadBalancer.find.assert_called_with("x")
     self.assertItemsEqual(info, [
         {"label": "Address", "value": "192.168.1.1"},
         {"label": "Instances", "value": "0"},
         {"label": "Routes", "value": ""},
         {"label": "Plan", "value": "small"},
     ])
     self.assertEqual(manager.status("x"), "192.168.1.1")
Beispiel #9
0
    def test_info_with_binding(self, LoadBalancer):
        self.storage.store_binding("inst", "app.host.com")
        self.storage.replace_binding_path("inst", "/arrakis", None, "location /x {\n}")
        lb = LoadBalancer.find.return_value
        lb.address = "192.168.1.1"
        lb.hosts = [mock.Mock(), mock.Mock()]
        manager = Manager(self.config)
        info = manager.info("inst")
        LoadBalancer.find.assert_called_with("inst")
        self.assertItemsEqual(info, [
            {"label": "Address", "value": "192.168.1.1"},
            {"label": "Instances", "value": "2"},
            {"label": "Routes", "value": """path = /
destination = app.host.com
path = /arrakis
content = location /x {
}"""},
        ])
        self.assertEqual(manager.status("inst"), "192.168.1.1")