diff options
Diffstat (limited to 'tests')
6 files changed, 216 insertions, 31 deletions
diff --git a/tests/ci/yardstick-verify b/tests/ci/yardstick-verify index 16598df7b..ca8a0b27a 100755 --- a/tests/ci/yardstick-verify +++ b/tests/ci/yardstick-verify @@ -248,6 +248,38 @@ EOF } +check_openstack(){ + # check if some necessary variables is set + if [ -z "$OS_AUTH_URL" ]; then + echo "OS_AUTH_URL is unset or empty" + exit 1 + fi + + echo "OS_AUTH_URL is $OS_AUTH_URL" + echo + + # check OpenStack services + if [[ $OS_INSECURE ]] && [[ "$(echo $OS_INSECURE | tr '[:upper:]' '[:lower:]')" = "true" ]]; then + SECURE="--insecure" + else + SECURE="" + fi + echo "Checking OpenStack services:" + for cmd in "openstack ${SECURE} image list" "openstack ${SECURE} server list" "openstack ${SECURE} stack list"; do + echo " checking ${cmd} ..." + if ! $cmd >/dev/null; then + echo "error: command \"$cmd\" failed" + exit 1 + fi + done + + echo + echo "Checking for External network:" + for net in $(openstack network list --external -c Name -f value); do + echo " external network: $net" + done +} + main() { GITROOT=$(cd $(dirname $0) && git rev-parse --show-toplevel) @@ -283,41 +315,15 @@ main() done echo - # check if some necessary variables is set - if [ -z "$OS_AUTH_URL" ]; then - echo "OS_AUTH_URL is unset or empty" - exit 1 - fi + trap "error_exit" EXIT SIGTERM - echo "OS_AUTH_URL is $OS_AUTH_URL" - echo + if [[ "${DEPLOY_SCENARIO:0:2}" == "os" ]];then + check_openstack - # check OpenStack services - if [[ $OS_INSECURE ]] && [[ "$(echo $OS_INSECURE | tr '[:upper:]' '[:lower:]')" = "true" ]]; then - SECURE="--insecure" - else - SECURE="" + source $YARDSTICK_REPO_DIR/tests/ci/clean_images.sh + source $YARDSTICK_REPO_DIR/tests/ci/load_images.sh fi - echo "Checking OpenStack services:" - for cmd in "openstack ${SECURE} image list" "openstack ${SECURE} server list" "openstack ${SECURE} stack list"; do - echo " checking ${cmd} ..." - if ! $cmd >/dev/null; then - echo "error: command \"$cmd\" failed" - exit 1 - fi - done - - echo - echo "Checking for External network:" - for net in $(openstack network list --external -c Name -f value); do - echo " external network: $net" - done - - source $YARDSTICK_REPO_DIR/tests/ci/clean_images.sh - - trap "error_exit" EXIT SIGTERM - source $YARDSTICK_REPO_DIR/tests/ci/load_images.sh install_storperf run_test remove_storperf 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() |