summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xdocker/exec_tests.sh6
-rwxr-xr-xtests/ci/yardstick-verify68
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_delete_network.py36
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_delete_port.py34
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_delete_router.py36
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_delete_router_gateway.py36
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_delete_router_interface.py37
-rw-r--r--yardstick/benchmark/contexts/heat.py20
-rw-r--r--yardstick/benchmark/core/task.py15
-rw-r--r--yardstick/benchmark/scenarios/lib/create_server.py2
-rw-r--r--yardstick/benchmark/scenarios/lib/delete_network.py55
-rw-r--r--yardstick/benchmark/scenarios/lib/delete_port.py54
-rw-r--r--yardstick/benchmark/scenarios/lib/delete_router.py55
-rw-r--r--yardstick/benchmark/scenarios/lib/delete_router_gateway.py55
-rw-r--r--yardstick/benchmark/scenarios/lib/delete_router_interface.py57
-rw-r--r--yardstick/common/openstack_utils.py40
-rwxr-xr-xyardstick/network_services/nfvi/collectd.sh36
17 files changed, 568 insertions, 74 deletions
diff --git a/docker/exec_tests.sh b/docker/exec_tests.sh
index 46e5a05bd..93e017f49 100755
--- a/docker/exec_tests.sh
+++ b/docker/exec_tests.sh
@@ -96,8 +96,10 @@ fi
cd ${YARDSTICK_REPO_DIR}
git_checkout ${YARDSTICK_BRANCH}
-# setup the environment
-source ${YARDSTICK_REPO_DIR}/tests/ci/prepare_env.sh
+if [[ "${DEPLOY_SCENARIO:0:2}" == "os" ]];then
+ # setup the environment
+ source ${YARDSTICK_REPO_DIR}/tests/ci/prepare_env.sh
+fi
# execute tests
${YARDSTICK_REPO_DIR}/tests/ci/yardstick-verify $@
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()
diff --git a/yardstick/benchmark/contexts/heat.py b/yardstick/benchmark/contexts/heat.py
index e52c1076c..deed4af93 100644
--- a/yardstick/benchmark/contexts/heat.py
+++ b/yardstick/benchmark/contexts/heat.py
@@ -14,6 +14,7 @@ import collections
import logging
import os
import uuid
+import errno
from collections import OrderedDict
import ipaddress
@@ -26,7 +27,8 @@ from yardstick.benchmark.contexts.model import Server
from yardstick.benchmark.contexts.model import update_scheduler_hints
from yardstick.common.openstack_utils import get_neutron_client
from yardstick.orchestrator.heat import HeatTemplate, get_short_key_uuid
-from yardstick.common.constants import YARDSTICK_ROOT_PATH
+from yardstick.common import constants as consts
+from yardstick.common.utils import source_env
from yardstick.ssh import SSH
LOG = logging.getLogger(__name__)
@@ -71,7 +73,7 @@ class HeatContext(Context):
self.key_uuid = uuid.uuid4()
self.heat_timeout = None
self.key_filename = ''.join(
- [YARDSTICK_ROOT_PATH, 'yardstick/resources/files/yardstick_key-',
+ [consts.YARDSTICK_ROOT_PATH, 'yardstick/resources/files/yardstick_key-',
get_short_key_uuid(self.key_uuid)])
super(HeatContext, self).__init__()
@@ -88,6 +90,7 @@ class HeatContext(Context):
return sorted_networks
def init(self, attrs):
+ self.check_environment()
"""initializes itself from the supplied arguments"""
self.name = attrs["name"]
@@ -131,6 +134,19 @@ class HeatContext(Context):
self.attrs = attrs
SSH.gen_keys(self.key_filename)
+ def check_environment(self):
+ try:
+ os.environ['OS_AUTH_URL']
+ except KeyError:
+ try:
+ source_env(consts.OPENRC)
+ except IOError as e:
+ if e.errno != errno.EEXIST:
+ LOG.error('OPENRC file not found')
+ raise
+ else:
+ LOG.error('OS_AUTH_URL not found')
+
@property
def image(self):
"""returns application's default image name"""
diff --git a/yardstick/benchmark/core/task.py b/yardstick/benchmark/core/task.py
index 2c67e736c..a49a2cb71 100644
--- a/yardstick/benchmark/core/task.py
+++ b/yardstick/benchmark/core/task.py
@@ -21,7 +21,6 @@ import ipaddress
import time
import logging
import uuid
-import errno
import collections
from six.moves import filter
@@ -32,7 +31,6 @@ from yardstick.benchmark.runners import base as base_runner
from yardstick.common.yaml_loader import yaml_load
from yardstick.dispatcher.base import Base as DispatcherBase
from yardstick.common.task_template import TaskTemplate
-from yardstick.common.utils import source_env
from yardstick.common import utils
from yardstick.common import constants
from yardstick.common.html_template import report_template
@@ -70,8 +68,6 @@ class Task(object): # pragma: no cover
self._set_log()
- check_environment()
-
try:
output_config = utils.parse_ini_file(config_file)
except Exception:
@@ -675,17 +671,6 @@ def parse_task_args(src_name, args):
return kw
-def check_environment():
- auth_url = os.environ.get('OS_AUTH_URL', None)
- if not auth_url:
- try:
- source_env(constants.OPENRC)
- except IOError as e:
- if e.errno != errno.EEXIST:
- raise
- LOG.debug('OPENRC file not found')
-
-
def change_server_name(scenario, suffix):
try:
host = scenario['host']
diff --git a/yardstick/benchmark/scenarios/lib/create_server.py b/yardstick/benchmark/scenarios/lib/create_server.py
index 273b0045a..31ba18ed4 100644
--- a/yardstick/benchmark/scenarios/lib/create_server.py
+++ b/yardstick/benchmark/scenarios/lib/create_server.py
@@ -21,7 +21,7 @@ LOG = logging.getLogger(__name__)
class CreateServer(base.Scenario):
"""Create an OpenStack server"""
- __scenario_type__ = "CreateSever"
+ __scenario_type__ = "CreateServer"
def __init__(self, scenario_cfg, context_cfg):
self.scenario_cfg = scenario_cfg
diff --git a/yardstick/benchmark/scenarios/lib/delete_network.py b/yardstick/benchmark/scenarios/lib/delete_network.py
new file mode 100644
index 000000000..e8796bf82
--- /dev/null
+++ b/yardstick/benchmark/scenarios/lib/delete_network.py
@@ -0,0 +1,55 @@
+##############################################################################
+# 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
+##############################################################################
+
+from __future__ import print_function
+from __future__ import absolute_import
+
+import logging
+
+from yardstick.benchmark.scenarios import base
+import yardstick.common.openstack_utils as op_utils
+
+LOG = logging.getLogger(__name__)
+
+
+class DeleteNetwork(base.Scenario):
+ """Delete an OpenStack network"""
+
+ __scenario_type__ = "DeleteNetwork"
+
+ def __init__(self, scenario_cfg, context_cfg):
+ self.scenario_cfg = scenario_cfg
+ self.context_cfg = context_cfg
+ self.options = self.scenario_cfg['options']
+
+ self.network_id = self.options.get("network_id", None)
+
+ self.neutron_client = op_utils.get_neutron_client()
+
+ self.setup_done = False
+
+ def setup(self):
+ """scenario setup"""
+
+ self.setup_done = True
+
+ def run(self, result):
+ """execute the test"""
+
+ if not self.setup_done:
+ self.setup()
+
+ status = op_utils.delete_neutron_net(self.neutron_client,
+ network_id=self.network_id)
+ if status:
+ result.update({"delete_network": 1})
+ LOG.info("Delete network successful!")
+ else:
+ result.update({"delete_network": 0})
+ LOG.error("Delete network failed!")
diff --git a/yardstick/benchmark/scenarios/lib/delete_port.py b/yardstick/benchmark/scenarios/lib/delete_port.py
new file mode 100644
index 000000000..436902998
--- /dev/null
+++ b/yardstick/benchmark/scenarios/lib/delete_port.py
@@ -0,0 +1,54 @@
+##############################################################################
+# 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
+##############################################################################
+
+from __future__ import print_function
+from __future__ import absolute_import
+
+import logging
+
+from yardstick.benchmark.scenarios import base
+import yardstick.common.openstack_utils as op_utils
+
+LOG = logging.getLogger(__name__)
+
+
+class DeletePort(base.Scenario):
+ """Delete an OpenStack subnetwork"""
+
+ __scenario_type__ = "DeletePort"
+
+ def __init__(self, scenario_cfg, context_cfg):
+ self.scenario_cfg = scenario_cfg
+ self.context_cfg = context_cfg
+ self.options = self.scenario_cfg['options']
+
+ self.port_id = self.options.get("port_id", None)
+
+ self.neutron_client = op_utils.get_neutron_client()
+
+ self.setup_done = False
+
+ def setup(self):
+ """scenario setup"""
+
+ self.setup_done = True
+
+ def run(self, result):
+ """execute the test"""
+
+ if not self.setup_done:
+ self.setup()
+
+ status = self.neutron_client.delete_port(self.port_id)
+ if status:
+ result.update({"delete_port": 1})
+ LOG.info("Delete Port successful!")
+ else:
+ result.update({"delete_port": 0})
+ LOG.error("Delete Port failed!")
diff --git a/yardstick/benchmark/scenarios/lib/delete_router.py b/yardstick/benchmark/scenarios/lib/delete_router.py
new file mode 100644
index 000000000..358fd40cf
--- /dev/null
+++ b/yardstick/benchmark/scenarios/lib/delete_router.py
@@ -0,0 +1,55 @@
+##############################################################################
+# 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
+##############################################################################
+
+from __future__ import print_function
+from __future__ import absolute_import
+
+import logging
+
+from yardstick.benchmark.scenarios import base
+import yardstick.common.openstack_utils as op_utils
+
+LOG = logging.getLogger(__name__)
+
+
+class DeleteRouter(base.Scenario):
+ """Delete an OpenStack router"""
+
+ __scenario_type__ = "DeleteRouter"
+
+ def __init__(self, scenario_cfg, context_cfg):
+ self.scenario_cfg = scenario_cfg
+ self.context_cfg = context_cfg
+ self.options = self.scenario_cfg['options']
+
+ self.router_id = self.options.get("router_id", None)
+
+ self.neutron_client = op_utils.get_neutron_client()
+
+ self.setup_done = False
+
+ def setup(self):
+ """scenario setup"""
+
+ self.setup_done = True
+
+ def run(self, result):
+ """execute the test"""
+
+ if not self.setup_done:
+ self.setup()
+
+ status = op_utils.delete_neutron_router(self.neutron_client,
+ router_id=self.router_id)
+ if status:
+ result.update({"delete_router": 1})
+ LOG.info("Delete router successful!")
+ else:
+ result.update({"delete_router": 0})
+ LOG.error("Delete router failed!")
diff --git a/yardstick/benchmark/scenarios/lib/delete_router_gateway.py b/yardstick/benchmark/scenarios/lib/delete_router_gateway.py
new file mode 100644
index 000000000..af4f33f94
--- /dev/null
+++ b/yardstick/benchmark/scenarios/lib/delete_router_gateway.py
@@ -0,0 +1,55 @@
+##############################################################################
+# 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
+##############################################################################
+
+from __future__ import print_function
+from __future__ import absolute_import
+
+import logging
+
+from yardstick.benchmark.scenarios import base
+import yardstick.common.openstack_utils as op_utils
+
+LOG = logging.getLogger(__name__)
+
+
+class DeleteRouterGateway(base.Scenario):
+ """Unset an OpenStack router gateway"""
+
+ __scenario_type__ = "DeleteRouterGateway"
+
+ def __init__(self, scenario_cfg, context_cfg):
+ self.scenario_cfg = scenario_cfg
+ self.context_cfg = context_cfg
+ self.options = self.scenario_cfg['options']
+
+ self.router_id = self.options.get("router_id", None)
+
+ self.neutron_client = op_utils.get_neutron_client()
+
+ self.setup_done = False
+
+ def setup(self):
+ """scenario setup"""
+
+ self.setup_done = True
+
+ def run(self, result):
+ """execute the test"""
+
+ if not self.setup_done:
+ self.setup()
+
+ status = op_utils.remove_gateway_router(self.neutron_client,
+ router_id=self.router_id)
+ if status:
+ result.update({"delete_router_gateway": 1})
+ LOG.info("Delete router gateway successful!")
+ else:
+ result.update({"delete_router_gateway": 0})
+ LOG.error("Delete router gateway failed!")
diff --git a/yardstick/benchmark/scenarios/lib/delete_router_interface.py b/yardstick/benchmark/scenarios/lib/delete_router_interface.py
new file mode 100644
index 000000000..117c80811
--- /dev/null
+++ b/yardstick/benchmark/scenarios/lib/delete_router_interface.py
@@ -0,0 +1,57 @@
+##############################################################################
+# 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
+##############################################################################
+
+from __future__ import print_function
+from __future__ import absolute_import
+
+import logging
+
+from yardstick.benchmark.scenarios import base
+import yardstick.common.openstack_utils as op_utils
+
+LOG = logging.getLogger(__name__)
+
+
+class DeleteRouterInterface(base.Scenario):
+ """Unset an OpenStack router interface"""
+
+ __scenario_type__ = "DeleteRouterInterface"
+
+ def __init__(self, scenario_cfg, context_cfg):
+ self.scenario_cfg = scenario_cfg
+ self.context_cfg = context_cfg
+ self.options = self.scenario_cfg['options']
+
+ self.subnet_id = self.options.get("subnet_id", None)
+ self.router_id = self.options.get("router_id", None)
+
+ self.neutron_client = op_utils.get_neutron_client()
+
+ self.setup_done = False
+
+ def setup(self):
+ """scenario setup"""
+
+ self.setup_done = True
+
+ def run(self, result):
+ """execute the test"""
+
+ if not self.setup_done:
+ self.setup()
+
+ status = op_utils.remove_interface_router(self.neutron_client,
+ router_id=self.router_id,
+ subnet_id=self.subnet_id)
+ if status:
+ result.update({"delete_router_interface": 1})
+ LOG.info("Delete router interface successful!")
+ else:
+ result.update({"delete_router_interface": 0})
+ LOG.error("Delete router interface failed!")
diff --git a/yardstick/common/openstack_utils.py b/yardstick/common/openstack_utils.py
index c862a6ba2..d1223edd2 100644
--- a/yardstick/common/openstack_utils.py
+++ b/yardstick/common/openstack_utils.py
@@ -457,6 +457,15 @@ def create_neutron_net(neutron_client, json_body): # pragma: no cover
return None
+def delete_neutron_net(neutron_client, network_id): # pragma: no cover
+ try:
+ neutron_client.delete_network(network_id)
+ return True
+ except Exception:
+ log.error("Error [delete_neutron_net(neutron_client, '%s')]" % network_id)
+ return False
+
+
def create_neutron_subnet(neutron_client, json_body): # pragma: no cover
try:
subnet = neutron_client.create_subnet(body=json_body)
@@ -477,6 +486,37 @@ def create_neutron_router(neutron_client, json_body): # pragma: no cover
return None
+def delete_neutron_router(neutron_client, router_id): # pragma: no cover
+ try:
+ neutron_client.delete_router(router=router_id)
+ return True
+ except Exception:
+ log.error("Error [delete_neutron_router(neutron_client, '%s')]" % router_id)
+ return False
+
+
+def remove_gateway_router(neutron_client, router_id): # pragma: no cover
+ try:
+ neutron_client.remove_gateway_router(router_id)
+ return True
+ except Exception:
+ log.error("Error [remove_gateway_router(neutron_client, '%s')]" % router_id)
+ return False
+
+
+def remove_interface_router(neutron_client, router_id, subnet_id,
+ **json_body): # pragma: no cover
+ json_body.update({"subnet_id": subnet_id})
+ try:
+ neutron_client.remove_interface_router(router=router_id,
+ body=json_body)
+ return True
+ except Exception:
+ log.error("Error [remove_interface_router(neutron_client, '%s', "
+ "'%s')]" % (router_id, subnet_id))
+ return False
+
+
def create_floating_ip(neutron_client, extnet_id): # pragma: no cover
props = {'floating_network_id': extnet_id}
try:
diff --git a/yardstick/network_services/nfvi/collectd.sh b/yardstick/network_services/nfvi/collectd.sh
index 8162ec539..7666404e4 100755
--- a/yardstick/network_services/nfvi/collectd.sh
+++ b/yardstick/network_services/nfvi/collectd.sh
@@ -13,7 +13,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-
INSTALL_NSB_BIN="/opt/nsb_bin"
cd $INSTALL_NSB_BIN
@@ -23,19 +22,17 @@ if [ "$(whoami)" != "root" ]; then
fi
echo "setup proxy..."
-http_proxy=$1
-https_proxy=$2
-if [[ "$http_proxy" != "" ]]; then
- export http_proxy=$http_proxy
- export https_proxy=$http_proxy
+if [[ -n $1 ]]; then
+ export http_proxy=$1
+ export https_proxy=$2
fi
-if [[ "$https_proxy" != "" ]]; then
- export https_proxy=$https_proxy
+if [[ -n $2 ]]; then
+ export https_proxy=$2
fi
echo "Install required libraries to run collectd..."
-pkg=(git flex bison build-essential pkg-config automake autotools-dev libltdl-dev librabbitmq-dev rabbitmq-server cmake)
+pkg=(git flex bison build-essential pkg-config automake autotools-dev libltdl-dev librabbitmq-dev rabbitmq-server cmake libvirt-dev)
for i in "${pkg[@]}"; do
dpkg-query -W --showformat='${Status}\n' "${i}"|grep "install ok installed"
if [ "$?" -eq "1" ]; then
@@ -44,9 +41,7 @@ dpkg-query -W --showformat='${Status}\n' "${i}"|grep "install ok installed"
done
echo "Done"
-ldconfig -p | grep libpqos >/dev/null
-if [ $? -eq 0 ]
-then
+if ldconfig -p | grep -q libpqos ; then
echo "Intel RDT library already installed. Done"
else
pushd .
@@ -54,32 +49,27 @@ else
echo "Get intel_rdt repo and install..."
rm -rf intel-cmt-cat >/dev/null
git clone https://github.com/01org/intel-cmt-cat.git
- pushd intel-cmt-cat
- make install PREFIX=/usr
- popd
+
+ (cd intel-cmt-cat; make install PREFIX=/usr)
popd
echo "Done."
fi
-ls /usr/lib/libdpdk.so >/dev/null
-if [ $? -eq 0 ]
-then
+if [[ -r /usr/lib/libdpdk.so ]]; then
echo "DPDK already installed. Done"
else
pushd .
echo "Get dpdk and install..."
mkdir -p $INSTALL_NSB_BIN
- rm -rf "$INSTALL_NSB_BIN"/dpdk >/dev/null
- git clone http://dpdk.org/git/dpdk
- pushd dpdk
+ pushd dpdk-16.07
mkdir -p /mnt/huge
mount -t hugetlbfs nodev /mnt/huge
sed -i 's/CONFIG_RTE_BUILD_SHARED_LIB=n/CONFIG_RTE_BUILD_SHARED_LIB=y/g' config/common_base
sed -i 's/CONFIG_RTE_EAL_PMD_PATH=""/CONFIG_RTE_EAL_PMD_PATH="\/usr\/lib\/dpdk-pmd\/"/g' config/common_base
- echo "Build dpdk v16.04"
+ echo "Build dpdk v16.07"
make config T=x86_64-native-linuxapp-gcc
make
sudo make install prefix=/usr
@@ -125,7 +115,7 @@ else
git clone https://github.com/collectd/collectd.git
pushd collectd
git stash
- git checkout -n nfvi 47c86ace348a1d7a5352a83d10935209f89aa4f5
+ git checkout -b nfvi 47c86ace348a1d7a5352a83d10935209f89aa4f5
./build.sh
./configure --with-libpqos=/usr/ --with-libdpdk=/usr --with-libyajl=/usr/local --enable-debug --enable-dpdkstat --enable-virt --enable-ovs_stats
make install > /dev/null