From d254d748b607c43167876f28c74b9ea839090df2 Mon Sep 17 00:00:00 2001
From: JingLu5 <lvjing5@huawei.com>
Date: Thu, 24 Aug 2017 01:02:21 +0000
Subject: Add common openstack opertation scenarios: router & port

JIRA: YARDSTICK-781

This patch adds some common openstack opertation scenarios

Change-Id: Id436a201aa04f8f6b98576e8fbf599ca3654827c
Signed-off-by: JingLu5 <lvjing5@huawei.com>
---
 .../benchmark/scenarios/lib/test_delete_network.py | 36 +++++++++++++++++++++
 .../benchmark/scenarios/lib/test_delete_port.py    | 34 ++++++++++++++++++++
 .../benchmark/scenarios/lib/test_delete_router.py  | 36 +++++++++++++++++++++
 .../scenarios/lib/test_delete_router_gateway.py    | 36 +++++++++++++++++++++
 .../scenarios/lib/test_delete_router_interface.py  | 37 ++++++++++++++++++++++
 5 files changed, 179 insertions(+)
 create mode 100644 tests/unit/benchmark/scenarios/lib/test_delete_network.py
 create mode 100644 tests/unit/benchmark/scenarios/lib/test_delete_port.py
 create mode 100644 tests/unit/benchmark/scenarios/lib/test_delete_router.py
 create mode 100644 tests/unit/benchmark/scenarios/lib/test_delete_router_gateway.py
 create mode 100644 tests/unit/benchmark/scenarios/lib/test_delete_router_interface.py

(limited to 'tests')

diff --git a/tests/unit/benchmark/scenarios/lib/test_delete_network.py b/tests/unit/benchmark/scenarios/lib/test_delete_network.py
new file mode 100644
index 000000000..9ccaa8232
--- /dev/null
+++ b/tests/unit/benchmark/scenarios/lib/test_delete_network.py
@@ -0,0 +1,36 @@
+##############################################################################
+# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+import unittest
+import mock
+import paramiko
+
+from yardstick.benchmark.scenarios.lib.delete_network import DeleteNetwork
+
+
+class DeleteNetworkTestCase(unittest.TestCase):
+
+    @mock.patch('yardstick.common.openstack_utils.get_neutron_client')
+    @mock.patch('yardstick.common.openstack_utils.delete_neutron_net')
+    def test_delete_network(self, mock_get_neutron_client, mock_delete_neutron_net):
+        options = {
+            'network_id': '123-123-123'
+        }
+        args = {"options": options}
+        obj = DeleteNetwork(args, {})
+        obj.run({})
+        self.assertTrue(mock_get_neutron_client.called)
+        self.assertTrue(mock_delete_neutron_net.called)
+
+
+def main():
+    unittest.main()
+
+
+if __name__ == '__main__':
+    main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_delete_port.py b/tests/unit/benchmark/scenarios/lib/test_delete_port.py
new file mode 100644
index 000000000..77b9c7009
--- /dev/null
+++ b/tests/unit/benchmark/scenarios/lib/test_delete_port.py
@@ -0,0 +1,34 @@
+##############################################################################
+# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+import unittest
+import mock
+import paramiko
+
+from yardstick.benchmark.scenarios.lib.delete_port import DeletePort
+
+
+class DeletePortTestCase(unittest.TestCase):
+
+    @mock.patch('yardstick.common.openstack_utils.get_neutron_client')
+    def test_delete_port(self, mock_get_neutron_client):
+        options = {
+            'port_id': '123-123-123'
+        }
+        args = {"options": options}
+        obj = DeletePort(args, {})
+        obj.run({})
+        self.assertTrue(mock_get_neutron_client.called)
+
+
+def main():
+    unittest.main()
+
+
+if __name__ == '__main__':
+    main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_delete_router.py b/tests/unit/benchmark/scenarios/lib/test_delete_router.py
new file mode 100644
index 000000000..ab1ad5d35
--- /dev/null
+++ b/tests/unit/benchmark/scenarios/lib/test_delete_router.py
@@ -0,0 +1,36 @@
+##############################################################################
+# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+import unittest
+import mock
+import paramiko
+
+from yardstick.benchmark.scenarios.lib.delete_router import DeleteRouter
+
+
+class DeleteRouterTestCase(unittest.TestCase):
+
+    @mock.patch('yardstick.common.openstack_utils.get_neutron_client')
+    @mock.patch('yardstick.common.openstack_utils.delete_neutron_router')
+    def test_delete_router(self, mock_get_neutron_client, mock_delete_neutron_router):
+        options = {
+            'router_id': '123-123-123'
+        }
+        args = {"options": options}
+        obj = DeleteRouter(args, {})
+        obj.run({})
+        self.assertTrue(mock_get_neutron_client.called)
+        self.assertTrue(mock_delete_neutron_router.called)
+
+
+def main():
+    unittest.main()
+
+
+if __name__ == '__main__':
+    main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_delete_router_gateway.py b/tests/unit/benchmark/scenarios/lib/test_delete_router_gateway.py
new file mode 100644
index 000000000..1150dccda
--- /dev/null
+++ b/tests/unit/benchmark/scenarios/lib/test_delete_router_gateway.py
@@ -0,0 +1,36 @@
+##############################################################################
+# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+import unittest
+import mock
+import paramiko
+
+from yardstick.benchmark.scenarios.lib.delete_router_gateway import DeleteRouterGateway
+
+
+class DeleteRouterGatewayTestCase(unittest.TestCase):
+
+    @mock.patch('yardstick.common.openstack_utils.get_neutron_client')
+    @mock.patch('yardstick.common.openstack_utils.remove_gateway_router')
+    def test_delete_router_gateway(self, mock_get_neutron_client, mock_remove_gateway_router):
+        options = {
+            'router_id': '123-123-123'
+        }
+        args = {"options": options}
+        obj = DeleteRouterGateway(args, {})
+        obj.run({})
+        self.assertTrue(mock_get_neutron_client.called)
+        self.assertTrue(mock_remove_gateway_router.called)
+
+
+def main():
+    unittest.main()
+
+
+if __name__ == '__main__':
+    main()
diff --git a/tests/unit/benchmark/scenarios/lib/test_delete_router_interface.py b/tests/unit/benchmark/scenarios/lib/test_delete_router_interface.py
new file mode 100644
index 000000000..2cc9c9f37
--- /dev/null
+++ b/tests/unit/benchmark/scenarios/lib/test_delete_router_interface.py
@@ -0,0 +1,37 @@
+##############################################################################
+# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+import unittest
+import mock
+import paramiko
+
+from yardstick.benchmark.scenarios.lib.delete_router_interface import DeleteRouterInterface
+
+
+class DeleteRouterInterfaceTestCase(unittest.TestCase):
+
+    @mock.patch('yardstick.common.openstack_utils.get_neutron_client')
+    @mock.patch('yardstick.common.openstack_utils.remove_interface_router')
+    def test_delete_router_interface(self, mock_get_neutron_client, mock_remove_interface_router):
+        options = {
+            'router_id': '123-123-123',
+            'subnet_id': '321-321-321'
+        }
+        args = {"options": options}
+        obj = DeleteRouterInterface(args, {})
+        obj.run({})
+        self.assertTrue(mock_get_neutron_client.called)
+        self.assertTrue(mock_remove_interface_router.called)
+
+
+def main():
+    unittest.main()
+
+
+if __name__ == '__main__':
+    main()
-- 
cgit