Ejemplo n.º 1
0
 def test_dry_delete(self, mock_adapter):
     mock_adapter.return_value.get_pools.side_effect = lambda x: ["foo"]
     from dcosdeploy.modules import edgelb
     manager = edgelb.EdgeLbPoolsManager()
     # Not existing pool
     pool = edgelb.EdgeLbPool("edgelb/api", "bar", dict(), None)
     self.assertFalse(manager.dry_delete(pool))
     # Existing pool
     pool = edgelb.EdgeLbPool("edgelb/api", "foo", dict(), None)
     self.assertTrue(manager.dry_delete(pool))
Ejemplo n.º 2
0
 def test_delete(self, mock_adapter):
     mock_adapter.return_value.delete_pool.side_effect = lambda api_sever, name: name == "foo"
     from dcosdeploy.modules import edgelb
     manager = edgelb.EdgeLbPoolsManager()
     # Existing pool
     pool = edgelb.EdgeLbPool("edgelb/api", "foo", dict(), None)
     self.assertTrue(manager.delete(pool))
     mock_adapter.return_value.delete_pool.assert_called_with("edgelb/api", "foo")
     # Not existing pool
     pool = edgelb.EdgeLbPool("edgelb/api", "bar", dict(), None)
     self.assertFalse(manager.delete(pool))
     mock_adapter.return_value.delete_pool.assert_called_with("edgelb/api", "bar")
Ejemplo n.º 3
0
 def test_deploy(self, mock_adapter):
     mock_adapter.return_value.get_pools.side_effect = lambda x: ["foo"]
     from dcosdeploy.modules import edgelb
     manager = edgelb.EdgeLbPoolsManager()
     # Test update
     pool = edgelb.EdgeLbPool("edgelb/api", "foo", oyaml.safe_load(POOL_DEF), "foobar")
     self.assertTrue(manager.deploy(pool))
     #mock_adapter.return_value.update_pool.assert_called_once()
     mock_adapter.return_value.update_pool_template.assert_called_with("edgelb/api", "foo", "foobar")
     # Test create
     pool = edgelb.EdgeLbPool("edgelb/api", "bar", oyaml.safe_load(POOL_DEF), None)
     self.assertTrue(manager.deploy(pool))
Ejemplo n.º 4
0
 def test_dry_run(self, mock_adapter):
     mock_adapter.return_value.get_pools.side_effect = lambda x: ["foo"]
     mock_adapter.return_value.get_pool.side_effect = lambda x, y: oyaml.safe_load(SERVER_POOL_DEF)
     from dcosdeploy.modules import edgelb
     manager = edgelb.EdgeLbPoolsManager()
     # not existing pool
     pool = edgelb.EdgeLbPool("edgelb/api", "bar", dict(), None)
     self.assertTrue(manager.dry_run(pool))
     # existing pool, no change
     pool = edgelb.EdgeLbPool("edgelb/api", "foo", oyaml.safe_load(POOL_DEF), None)
     self.assertFalse(manager.dry_run(pool))
     # existing pool, change
     pool = edgelb.EdgeLbPool("edgelb/api", "foo", oyaml.safe_load(POOL_DEF_CHANGED), None)
     self.assertTrue(manager.dry_run(pool))
Ejemplo n.º 5
0
 def test_dry_run_pingfailed(self, mock_adapter):
     mock_adapter.return_value.ping.side_effect = lambda x: False
     from dcosdeploy.modules import edgelb
     manager = edgelb.EdgeLbPoolsManager()
     pool = edgelb.EdgeLbPool("edgelb/api", "foo", dict(), None)
     self.assertTrue(manager.dry_run(pool))