diff options
30 files changed, 721 insertions, 31 deletions
diff --git a/docs/userguide/opnfv_yardstick_tc046.rst b/docs/userguide/opnfv_yardstick_tc046.rst index 612676434..cce6c6884 100644 --- a/docs/userguide/opnfv_yardstick_tc046.rst +++ b/docs/userguide/opnfv_yardstick_tc046.rst @@ -2,7 +2,7 @@ .. License. .. http://creativecommons.org/licenses/by/4.0 .. (c) OPNFV, Yin Kanglin and others. -.. 14_ykl@tongji.edu.cn +.. 14_ykl@tongji.edu.cn ************************************* Yardstick Test Case Description TC046 diff --git a/samples/netperf_node.yaml b/samples/netperf_node.yaml new file mode 100755 index 000000000..d59bbf235 --- /dev/null +++ b/samples/netperf_node.yaml @@ -0,0 +1,51 @@ +--- +# Sample benchmark task config file +# measure network latency and throughput using netperf +# There are two sample scenarios: bulk test and request/response test +# In bulk test, UDP_STREAM and TCP_STREAM can be used +# send_msg_size and recv_msg_size are options of bulk test +# In req/rsp test, TCP_RR TCP_CRR UDP_RR can be used +# req_rsp_size is option of req/rsp test + +schema: "yardstick:task:0.1" + +scenarios: +- + type: NetperfNode + options: + testname: 'UDP_STREAM' + send_msg_size: 1024 + duration: 20 + + host: node1.LF + target: node2.LF + + runner: + type: Iteration + iterations: 1 + interval: 1 + sla: + mean_latency: 100 + action: monitor +#- +# type: NetperfNode +# options: +# testname: 'TCP_RR' +# req_rsp_size: '32,1024' +# +# host: node1.LF +# target: node2.LF +# +# runner: +# type: Duration +# duration: 20 +# interval: 1 +# sla: +# mean_latency: 300 +# action: monitor + +context: + type: Node + name: LF + file: etc/yardstick/nodes/compass_sclab_physical/pod.yaml + diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc027.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc027.yaml index dc86c5efa..ccdcaebc8 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc027.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc027.yaml @@ -28,6 +28,7 @@ scenarios: precondition: installer_type: compass deploy_scenarios: os-nosdn + pod_name: huawei-pod1 context: type: Node diff --git a/tests/opnfv/test_suites/opnfv_os-nosdn-kvm-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-nosdn-kvm-ha_daily.yaml new file mode 100644 index 000000000..50167b8bf --- /dev/null +++ b/tests/opnfv/test_suites/opnfv_os-nosdn-kvm-ha_daily.yaml @@ -0,0 +1,22 @@ +--- +# Huawei US bare daily task suite + +schema: "yardstick:suite:0.1" + +name: "os-nosdn-kvm-ha" +test_cases_dir: "tests/opnfv/test_cases/" +test_cases: +- + file_name: opnfv_yardstick_tc002.yaml +- + file_name: opnfv_yardstick_tc005.yaml +- + file_name: opnfv_yardstick_tc010.yaml +- + file_name: opnfv_yardstick_tc011.yaml +- + file_name: opnfv_yardstick_tc012.yaml +- + file_name: opnfv_yardstick_tc014.yaml +- + file_name: opnfv_yardstick_tc037.yaml diff --git a/tests/opnfv/test_suites/opnfv_os-nosdn-kvm_ovs-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-nosdn-kvm_ovs-ha_daily.yaml new file mode 100644 index 000000000..81427ad47 --- /dev/null +++ b/tests/opnfv/test_suites/opnfv_os-nosdn-kvm_ovs-ha_daily.yaml @@ -0,0 +1,22 @@ +--- +# Huawei US bare daily task suite + +schema: "yardstick:suite:0.1" + +name: "os-nosdn-kvm_ovs-ha" +test_cases_dir: "tests/opnfv/test_cases/" +test_cases: +- + file_name: opnfv_yardstick_tc002.yaml +- + file_name: opnfv_yardstick_tc005.yaml +- + file_name: opnfv_yardstick_tc010.yaml +- + file_name: opnfv_yardstick_tc011.yaml +- + file_name: opnfv_yardstick_tc012.yaml +- + file_name: opnfv_yardstick_tc014.yaml +- + file_name: opnfv_yardstick_tc037.yaml diff --git a/tests/opnfv/test_suites/opnfv_os-nosdn-nofeature-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-nosdn-nofeature-ha_daily.yaml new file mode 100644 index 000000000..d5f7bf824 --- /dev/null +++ b/tests/opnfv/test_suites/opnfv_os-nosdn-nofeature-ha_daily.yaml @@ -0,0 +1,22 @@ +--- +# Huawei US bare daily task suite + +schema: "yardstick:suite:0.1" + +name: "os-nosdn-nofeature-ha" +test_cases_dir: "tests/opnfv/test_cases/" +test_cases: +- + file_name: opnfv_yardstick_tc002.yaml +- + file_name: opnfv_yardstick_tc005.yaml +- + file_name: opnfv_yardstick_tc010.yaml +- + file_name: opnfv_yardstick_tc011.yaml +- + file_name: opnfv_yardstick_tc012.yaml +- + file_name: opnfv_yardstick_tc014.yaml +- + file_name: opnfv_yardstick_tc037.yaml diff --git a/tests/opnfv/test_suites/opnfv_os-nosdn-ovs-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-nosdn-ovs-ha_daily.yaml new file mode 100644 index 000000000..2eafd279b --- /dev/null +++ b/tests/opnfv/test_suites/opnfv_os-nosdn-ovs-ha_daily.yaml @@ -0,0 +1,22 @@ +--- +# Huawei US bare daily task suite + +schema: "yardstick:suite:0.1" + +name: "os-nosdn-ovs-ha" +test_cases_dir: "tests/opnfv/test_cases/" +test_cases: +- + file_name: opnfv_yardstick_tc002.yaml +- + file_name: opnfv_yardstick_tc005.yaml +- + file_name: opnfv_yardstick_tc010.yaml +- + file_name: opnfv_yardstick_tc011.yaml +- + file_name: opnfv_yardstick_tc012.yaml +- + file_name: opnfv_yardstick_tc014.yaml +- + file_name: opnfv_yardstick_tc037.yaml diff --git a/tests/opnfv/test_suites/opnfv_os-ocl-nofeature-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-ocl-nofeature-ha_daily.yaml new file mode 100644 index 000000000..21d2ebf24 --- /dev/null +++ b/tests/opnfv/test_suites/opnfv_os-ocl-nofeature-ha_daily.yaml @@ -0,0 +1,22 @@ +--- +# Huawei US bare daily task suite + +schema: "yardstick:suite:0.1" + +name: "os-ocl-nofeature-ha" +test_cases_dir: "tests/opnfv/test_cases/" +test_cases: +- + file_name: opnfv_yardstick_tc002.yaml +- + file_name: opnfv_yardstick_tc005.yaml +- + file_name: opnfv_yardstick_tc010.yaml +- + file_name: opnfv_yardstick_tc011.yaml +- + file_name: opnfv_yardstick_tc012.yaml +- + file_name: opnfv_yardstick_tc014.yaml +- + file_name: opnfv_yardstick_tc037.yaml diff --git a/tests/opnfv/test_suites/opnfv_os-odl_l2-bgpvpn-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-odl_l2-bgpvpn-ha_daily.yaml new file mode 100644 index 000000000..80389062a --- /dev/null +++ b/tests/opnfv/test_suites/opnfv_os-odl_l2-bgpvpn-ha_daily.yaml @@ -0,0 +1,22 @@ +--- +# Huawei US bare daily task suite + +schema: "yardstick:suite:0.1" + +name: "os-odl_l2-bgpvpn-ha" +test_cases_dir: "tests/opnfv/test_cases/" +test_cases: +- + file_name: opnfv_yardstick_tc002.yaml +- + file_name: opnfv_yardstick_tc005.yaml +- + file_name: opnfv_yardstick_tc010.yaml +- + file_name: opnfv_yardstick_tc011.yaml +- + file_name: opnfv_yardstick_tc012.yaml +- + file_name: opnfv_yardstick_tc014.yaml +- + file_name: opnfv_yardstick_tc037.yaml diff --git a/tests/opnfv/test_suites/opnfv_os-odl_l2-nofeature-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-odl_l2-nofeature-ha_daily.yaml new file mode 100644 index 000000000..c80b394b4 --- /dev/null +++ b/tests/opnfv/test_suites/opnfv_os-odl_l2-nofeature-ha_daily.yaml @@ -0,0 +1,22 @@ +--- +# Huawei US bare daily task suite + +schema: "yardstick:suite:0.1" + +name: "os-odl_l2-nofeature-ha" +test_cases_dir: "tests/opnfv/test_cases/" +test_cases: +- + file_name: opnfv_yardstick_tc002.yaml +- + file_name: opnfv_yardstick_tc005.yaml +- + file_name: opnfv_yardstick_tc010.yaml +- + file_name: opnfv_yardstick_tc011.yaml +- + file_name: opnfv_yardstick_tc012.yaml +- + file_name: opnfv_yardstick_tc014.yaml +- + file_name: opnfv_yardstick_tc037.yaml diff --git a/tests/opnfv/test_suites/opnfv_os-odl_l2-sfc-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-odl_l2-sfc-ha_daily.yaml new file mode 100644 index 000000000..9799a2dff --- /dev/null +++ b/tests/opnfv/test_suites/opnfv_os-odl_l2-sfc-ha_daily.yaml @@ -0,0 +1,22 @@ +--- +# Huawei US bare daily task suite + +schema: "yardstick:suite:0.1" + +name: "os-odl_l2-sfc-ha" +test_cases_dir: "tests/opnfv/test_cases/" +test_cases: +- + file_name: opnfv_yardstick_tc002.yaml +- + file_name: opnfv_yardstick_tc005.yaml +- + file_name: opnfv_yardstick_tc010.yaml +- + file_name: opnfv_yardstick_tc011.yaml +- + file_name: opnfv_yardstick_tc012.yaml +- + file_name: opnfv_yardstick_tc014.yaml +- + file_name: opnfv_yardstick_tc037.yaml diff --git a/tests/opnfv/test_suites/opnfv_os-odl_l3-nofeature-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-odl_l3-nofeature-ha_daily.yaml new file mode 100644 index 000000000..112b70c03 --- /dev/null +++ b/tests/opnfv/test_suites/opnfv_os-odl_l3-nofeature-ha_daily.yaml @@ -0,0 +1,22 @@ +--- +# Huawei US bare daily task suite + +schema: "yardstick:suite:0.1" + +name: "os-odl_l3-nofeature-ha" +test_cases_dir: "tests/opnfv/test_cases/" +test_cases: +- + file_name: opnfv_yardstick_tc002.yaml +- + file_name: opnfv_yardstick_tc005.yaml +- + file_name: opnfv_yardstick_tc010.yaml +- + file_name: opnfv_yardstick_tc011.yaml +- + file_name: opnfv_yardstick_tc012.yaml +- + file_name: opnfv_yardstick_tc014.yaml +- + file_name: opnfv_yardstick_tc037.yaml diff --git a/tests/opnfv/test_suites/opnfv_os-onos-nofeature-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-onos-nofeature-ha_daily.yaml new file mode 100644 index 000000000..e2d348c65 --- /dev/null +++ b/tests/opnfv/test_suites/opnfv_os-onos-nofeature-ha_daily.yaml @@ -0,0 +1,22 @@ +--- +# Huawei US bare daily task suite + +schema: "yardstick:suite:0.1" + +name: "os-onos-nofeature-ha" +test_cases_dir: "tests/opnfv/test_cases/" +test_cases: +- + file_name: opnfv_yardstick_tc002.yaml +- + file_name: opnfv_yardstick_tc005.yaml +- + file_name: opnfv_yardstick_tc010.yaml +- + file_name: opnfv_yardstick_tc011.yaml +- + file_name: opnfv_yardstick_tc012.yaml +- + file_name: opnfv_yardstick_tc014.yaml +- + file_name: opnfv_yardstick_tc037.yaml diff --git a/tests/opnfv/test_suites/opnfv_os-onos-sfc-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-onos-sfc-ha_daily.yaml new file mode 100644 index 000000000..9ea5f1314 --- /dev/null +++ b/tests/opnfv/test_suites/opnfv_os-onos-sfc-ha_daily.yaml @@ -0,0 +1,22 @@ +--- +# Huawei US bare daily task suite + +schema: "yardstick:suite:0.1" + +name: "os-onos-sfc-ha" +test_cases_dir: "tests/opnfv/test_cases/" +test_cases: +- + file_name: opnfv_yardstick_tc002.yaml +- + file_name: opnfv_yardstick_tc005.yaml +- + file_name: opnfv_yardstick_tc010.yaml +- + file_name: opnfv_yardstick_tc011.yaml +- + file_name: opnfv_yardstick_tc012.yaml +- + file_name: opnfv_yardstick_tc014.yaml +- + file_name: opnfv_yardstick_tc037.yaml diff --git a/tests/unit/benchmark/scenarios/availability/test_attacker_general.py b/tests/unit/benchmark/scenarios/availability/test_attacker_general.py index d6488a9a7..643c1e7ac 100644 --- a/tests/unit/benchmark/scenarios/availability/test_attacker_general.py +++ b/tests/unit/benchmark/scenarios/availability/test_attacker_general.py @@ -32,7 +32,7 @@ class GeneralAttackerServiceTestCase(unittest.TestCase): 'fault_type': 'general-attacker', 'action_parameter':{'process_name':'nova_api'}, 'rollback_parameter':{'process_name':'nova_api'}, - 'key':'stop_service', + 'key':'stop-service', 'host': 'node1', } diff --git a/tests/unit/benchmark/scenarios/availability/test_basemonitor.py b/tests/unit/benchmark/scenarios/availability/test_basemonitor.py index 140841075..a20cf8187 100644 --- a/tests/unit/benchmark/scenarios/availability/test_basemonitor.py +++ b/tests/unit/benchmark/scenarios/availability/test_basemonitor.py @@ -23,7 +23,7 @@ class MonitorMgrTestCase(unittest.TestCase): def setUp(self): config = { 'monitor_type': 'openstack-api', - 'key' : 'service_status' + 'key' : 'service-status' } self.monitor_configs = [] @@ -40,7 +40,7 @@ class MonitorMgrTestCase(unittest.TestCase): def test_MonitorMgr_getitem(self, mock_monitor): monitorMgr = basemonitor.MonitorMgr() monitorMgr.init_monitors(self.monitor_configs, None) - monitorIns = monitorMgr['service_status'] + monitorIns = monitorMgr['service-status'] class BaseMonitorTestCase(unittest.TestCase): diff --git a/tests/unit/benchmark/scenarios/availability/test_baseoperation.py b/tests/unit/benchmark/scenarios/availability/test_baseoperation.py index 8c341913f..d85f1e19f 100644 --- a/tests/unit/benchmark/scenarios/availability/test_baseoperation.py +++ b/tests/unit/benchmark/scenarios/availability/test_baseoperation.py @@ -22,7 +22,7 @@ class OperationMgrTestCase(unittest.TestCase): def setUp(self): config = { 'operation_type': 'general-operation', - 'key' : 'service_status' + 'key' : 'service-status' } self.operation_configs = [] @@ -31,7 +31,7 @@ class OperationMgrTestCase(unittest.TestCase): def test_all_successful(self, mock_operation): mgr_ins = baseoperation.OperationMgr() mgr_ins.init_operations(self.operation_configs, None) - operation_ins = mgr_ins["service_status"] + operation_ins = mgr_ins["service-status"] mgr_ins.rollback() def test_getitem_fail(self, mock_operation): @@ -59,7 +59,7 @@ class BaseOperationTestCase(unittest.TestCase): def setUp(self): self.config = { 'operation_type': 'general-operation', - 'key' : 'service_status' + 'key' : 'service-status' } def test_all_successful(self): diff --git a/tests/unit/benchmark/scenarios/availability/test_director.py b/tests/unit/benchmark/scenarios/availability/test_director.py index 887ddd631..06116725d 100644 --- a/tests/unit/benchmark/scenarios/availability/test_director.py +++ b/tests/unit/benchmark/scenarios/availability/test_director.py @@ -33,16 +33,16 @@ class DirectorTestCase(unittest.TestCase): 'key': "kill-process"}], 'monitors': [{ 'monitor_type': "general-monitor", - 'key': "service_status"}], + 'key': "service-status"}], 'operations': [{ 'operation_type': 'general-operation', - 'key' : 'service_status'}], + 'key' : 'service-status'}], 'resultCheckers': [{ 'checker_type': 'general-result-checker', 'key' : 'process-checker',}], 'steps':[ { - 'actionKey': "service_status", + 'actionKey': "service-status", 'actionType': "operation", 'index': 1}, { @@ -54,7 +54,7 @@ class DirectorTestCase(unittest.TestCase): 'actionType': "resultchecker", 'index': 3}, { - 'actionKey': "service_status", + 'actionKey': "service-status", 'actionType': "monitor", 'index': 4}, ] @@ -69,12 +69,12 @@ class DirectorTestCase(unittest.TestCase): def test_director_all_successful(self, mock_checer, mock_opertion, mock_attacker, mock_monitor): ins = Director(self.scenario_cfg, self.ctx) - opertion_action = ins.createActionPlayer("operation", "service_status") + opertion_action = ins.createActionPlayer("operation", "service-status") attacker_action = ins.createActionPlayer("attacker", "kill-process") checker_action = ins.createActionPlayer("resultchecker", "process-checker") - monitor_action = ins.createActionPlayer("monitor", "service_status") + monitor_action = ins.createActionPlayer("monitor", "service-status") - opertion_rollback = ins.createActionRollbacker("operation", "service_status") + opertion_rollback = ins.createActionRollbacker("operation", "service-status") attacker_rollback = ins.createActionRollbacker("attacker", "kill-process") ins.executionSteps.append(opertion_rollback) ins.executionSteps.append(attacker_rollback) diff --git a/tests/unit/benchmark/scenarios/availability/test_monitor_general.py b/tests/unit/benchmark/scenarios/availability/test_monitor_general.py index 85487a574..b48434c99 100644 --- a/tests/unit/benchmark/scenarios/availability/test_monitor_general.py +++ b/tests/unit/benchmark/scenarios/availability/test_monitor_general.py @@ -31,18 +31,18 @@ class GeneralMonitorServiceTestCase(unittest.TestCase): self.context = {"node1": host} self.monitor_cfg = { 'monitor_type': 'general-monitor', - 'key': 'service_status', + 'key': 'service-status', 'host': 'node1', 'monitor_time': 3, 'parameter': {'serviceName': 'haproxy'}, - 'sla': {'max_recover_time': 1} + 'sla': {'max_outage_time': 1} } self.monitor_cfg_noparam = { 'monitor_type': 'general-monitor', - 'key': 'service_status', + 'key': 'service-status', 'host': 'node1', 'monitor_time': 3, - 'sla': {'max_recover_time': 1} + 'sla': {'max_outage_time': 1} } def test__monitor_general_all_successful(self, mock_open, mock_ssh): diff --git a/tests/unit/benchmark/scenarios/availability/test_scenario_general.py b/tests/unit/benchmark/scenarios/availability/test_scenario_general.py index c17edea45..bab9d62f1 100644 --- a/tests/unit/benchmark/scenarios/availability/test_scenario_general.py +++ b/tests/unit/benchmark/scenarios/availability/test_scenario_general.py @@ -29,14 +29,14 @@ class ScenarioGeneralTestCase(unittest.TestCase): 'key': "kill-process"}], 'monitors': [{ 'monitor_type': "general-monitor", - 'key': "service_status"}], + 'key': "service-status"}], 'steps':[ { 'actionKey': "kill-process", 'actionType': "attacker", 'index': 1}, { - 'actionKey': "service_status", + 'actionKey': "service-status", 'actionType': "monitor", 'index': 2}] } @@ -62,4 +62,4 @@ class ScenarioGeneralTestCase(unittest.TestCase): mock_obj.verify.return_value = False ins.director = mock_obj ins.run(None) - ins.teardown()
\ No newline at end of file + ins.teardown() diff --git a/tests/unit/benchmark/scenarios/networking/test_netperf_node.py b/tests/unit/benchmark/scenarios/networking/test_netperf_node.py new file mode 100755 index 000000000..1c39b292b --- /dev/null +++ b/tests/unit/benchmark/scenarios/networking/test_netperf_node.py @@ -0,0 +1,127 @@ +#!/usr/bin/env python + +############################################################################## +# Copyright (c) 2015 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 +############################################################################## + +# Unittest for +# yardstick.benchmark.scenarios.networking.netperf_node.NetperfNode + +import mock +import unittest +import os +import json + +from yardstick.benchmark.scenarios.networking import netperf_node + + +@mock.patch('yardstick.benchmark.scenarios.networking.netperf_node.ssh') +class NetperfNodeTestCase(unittest.TestCase): + + def setUp(self): + self.ctx = { + 'host': { + 'ip': '192.168.10.10', + 'user': 'root', + 'password': 'root' + }, + 'target': { + 'ip': '192.168.10.11', + 'user': 'root', + 'password': 'root' + } + } + + def test_netperf_node_successful_setup(self, mock_ssh): + + p = netperf_node.NetperfNode({}, self.ctx) + mock_ssh.SSH().execute.return_value = (0, '', '') + + p.setup() + self.assertIsNotNone(p.server) + self.assertIsNotNone(p.client) + self.assertEqual(p.setup_done, True) + + def test_netperf_node_successful_no_sla(self, mock_ssh): + + options = {} + args = {'options': options} + result = {} + + p = netperf_node.NetperfNode(args, self.ctx) + mock_ssh.SSH().execute.return_value = (0, '', '') + p.host = mock_ssh.SSH() + + sample_output = self._read_sample_output() + mock_ssh.SSH().execute.return_value = (0, sample_output, '') + expected_result = json.loads(sample_output) + p.run(result) + self.assertEqual(result, expected_result) + + def test_netperf_node_successful_sla(self, mock_ssh): + + options = {} + args = { + 'options': options, + 'sla': {'mean_latency': 100} + } + result = {} + + p = netperf_node.NetperfNode(args, self.ctx) + mock_ssh.SSH().execute.return_value = (0, '', '') + p.host = mock_ssh.SSH() + + sample_output = self._read_sample_output() + mock_ssh.SSH().execute.return_value = (0, sample_output, '') + expected_result = json.loads(sample_output) + p.run(result) + self.assertEqual(result, expected_result) + + def test_netperf_node_unsuccessful_sla(self, mock_ssh): + + options = {} + args = { + 'options': options, + 'sla': {'mean_latency': 5} + } + result = {} + + p = netperf_node.NetperfNode(args, self.ctx) + mock_ssh.SSH().execute.return_value = (0, '', '') + p.host = mock_ssh.SSH() + + sample_output = self._read_sample_output() + mock_ssh.SSH().execute.return_value = (0, sample_output, '') + self.assertRaises(AssertionError, p.run, result) + + def test_netperf_node_unsuccessful_script_error(self, mock_ssh): + + options = {} + args = {'options': options} + result = {} + + p = netperf_node.NetperfNode(args, self.ctx) + mock_ssh.SSH().execute.return_value = (0, '', '') + p.host = mock_ssh.SSH() + + mock_ssh.SSH().execute.return_value = (1, '', 'FOOBAR') + self.assertRaises(RuntimeError, p.run, result) + + def _read_sample_output(self): + curr_path = os.path.dirname(os.path.abspath(__file__)) + output = os.path.join(curr_path, 'netperf_sample_output.json') + with open(output) as f: + sample_output = f.read() + return sample_output + + +def main(): + unittest.main() + +if __name__ == '__main__': + main() diff --git a/tests/unit/cmd/commands/test_task.py b/tests/unit/cmd/commands/test_task.py index 5b404c48d..ccb0f2aec 100644 --- a/tests/unit/cmd/commands/test_task.py +++ b/tests/unit/cmd/commands/test_task.py @@ -62,11 +62,12 @@ class TaskCommandsTestCase(unittest.TestCase): cfg = \ {'precondition': {'installer_type': 'compass', - 'deploy_scenarios': 'os-nosdn' + 'deploy_scenarios': 'os-nosdn', + 'pod_name': 'huawei-pod1' } } t = task.TaskParser('/opt') - mock_os.environ.get.side_effect = ['compass', 'os-nosdn'] + mock_os.environ.get.side_effect = ['compass', 'os-nosdn', 'huawei-pod1'] result = t._check_precondition(cfg) self.assertTrue(result) diff --git a/yardstick/benchmark/scenarios/availability/attacker_conf.yaml b/yardstick/benchmark/scenarios/availability/attacker_conf.yaml index 16b3d735c..e5d1b9f0b 100644 --- a/yardstick/benchmark/scenarios/availability/attacker_conf.yaml +++ b/yardstick/benchmark/scenarios/availability/attacker_conf.yaml @@ -12,6 +12,6 @@ bare-metal-down: check_script: ha_tools/check_host_ping.bash recovery_script: ha_tools/ipmi_power.bash -stop_service: +stop-service: inject_script: ha_tools/stop_service.bash recovery_script: ha_tools/start_service.bash diff --git a/yardstick/benchmark/scenarios/availability/monitor/monitor_general.py b/yardstick/benchmark/scenarios/availability/monitor/monitor_general.py index 515514c29..e7e4d5bce 100644 --- a/yardstick/benchmark/scenarios/availability/monitor/monitor_general.py +++ b/yardstick/benchmark/scenarios/availability/monitor/monitor_general.py @@ -59,7 +59,7 @@ class GeneralMonitor(basemonitor.BaseMonitor): def verify_SLA(self): LOG.debug("the _result:%s" % self._result) outage_time = self._result.get('outage_time', None) - max_outage_time = self._config["sla"]["max_recover_time"] + max_outage_time = self._config["sla"]["max_outage_time"] if outage_time is None: LOG.error("There is no outage_time in monitor result.") return False diff --git a/yardstick/benchmark/scenarios/availability/monitor_conf.yaml b/yardstick/benchmark/scenarios/availability/monitor_conf.yaml index 9efceed88..d7bbdfe60 100644 --- a/yardstick/benchmark/scenarios/availability/monitor_conf.yaml +++ b/yardstick/benchmark/scenarios/availability/monitor_conf.yaml @@ -3,9 +3,9 @@ # schema: "yardstick:task:0.1" -process_status: +process-status: monitor_script: ha_tools/check_process_python.bash -nova_image_list: +nova-image-list: monitor_script: ha_tools/nova_image_list.bash -service_status: +service-status: monitor_script: ha_tools/check_service.bash diff --git a/yardstick/benchmark/scenarios/availability/operation_conf.yaml b/yardstick/benchmark/scenarios/availability/operation_conf.yaml index 78c996d05..1e6746302 100644 --- a/yardstick/benchmark/scenarios/availability/operation_conf.yaml +++ b/yardstick/benchmark/scenarios/availability/operation_conf.yaml @@ -7,10 +7,10 @@ nova-create-instance: action_script: ha_tools/nova/create_instance_from_image.bash rollback_script: ha_tools/nova/delete_instance.bash -swift_upload_file: +swift-upload-file: action_script: ha_tools/swift/upload.bash rollback_script: ha_tools/swift/delete.bash -swift_download_file: +swift-download-file: action_script: ha_tools/swift/download.bash - rollback_script: ha_tools/file/remove_file.bash
\ No newline at end of file + rollback_script: ha_tools/file/remove_file.bash diff --git a/yardstick/benchmark/scenarios/networking/netperf_install.bash b/yardstick/benchmark/scenarios/networking/netperf_install.bash new file mode 100755 index 000000000..eaa9f530a --- /dev/null +++ b/yardstick/benchmark/scenarios/networking/netperf_install.bash @@ -0,0 +1,32 @@ +#!/bin/bash + +############################################################################## +# Copyright (c) 2016 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 +############################################################################## + +set -e + +echo "===Install netperf before test begin!!!===" +cp /etc/apt/sources.list /etc/apt/sources.list_bkp +cp /etc/resolv.conf /etc/resolv.conf_bkp +echo "nameserver 8.8.4.4" >> /etc/resolv.conf + +cat <<EOF >/etc/apt/sources.list +deb http://archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse +deb http://archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse +deb http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse +deb http://archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiverse +deb http://archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse +EOF + +sudo apt-get update +sudo apt-get install -y netperf + +service netperf start + +echo "===Install netperf before test end!!!===" diff --git a/yardstick/benchmark/scenarios/networking/netperf_node.py b/yardstick/benchmark/scenarios/networking/netperf_node.py new file mode 100755 index 000000000..87aa8d78d --- /dev/null +++ b/yardstick/benchmark/scenarios/networking/netperf_node.py @@ -0,0 +1,203 @@ +############################################################################## +# Copyright (c) 2016 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 +############################################################################## +# bulk data test and req/rsp test are supported +import pkg_resources +import logging +import json + +import yardstick.ssh as ssh +from yardstick.benchmark.scenarios import base + +LOG = logging.getLogger(__name__) + + +class NetperfNode(base.Scenario): + """Execute netperf between two nodes + + Parameters + testname - to specify the test you wish to perform. + the valid testnames are TCP_STREAM, TCP_RR, UDP_STREAM, UDP_RR + type: string + unit: na + default: TCP_STREAM + send_msg_size - value set the local send size to value bytes. + type: int + unit: bytes + default: na + recv_msg_size - setting the receive size for the remote system. + type: int + unit: bytes + default: na + req_rsp_size - set the request and/or response sizes based on sizespec. + type: string + unit: na + default: na + duration - duration of the test + type: int + unit: seconds + default: 20 + + read link below for more netperf args description: + http://www.netperf.org/netperf/training/Netperf.html + """ + __scenario_type__ = "NetperfNode" + TARGET_SCRIPT = 'netperf_benchmark.bash' + INSTALL_SCRIPT = 'netperf_install.bash' + REMOVE_SCRIPT = 'netperf_remove.bash' + + def __init__(self, scenario_cfg, context_cfg): + self.scenario_cfg = scenario_cfg + self.context_cfg = context_cfg + self.setup_done = False + + def setup(self): + '''scenario setup''' + self.target_script = pkg_resources.resource_filename( + 'yardstick.benchmark.scenarios.networking', + NetperfNode.TARGET_SCRIPT) + host = self.context_cfg['host'] + host_user = host.get('user', 'ubuntu') + host_ip = host.get('ip', None) + target = self.context_cfg['target'] + target_user = target.get('user', 'ubuntu') + target_ip = target.get('ip', None) + self.target_ip = target.get('ip', None) + host_password = host.get('password', None) + target_password = target.get('password', None) + + LOG.info("host_pw:%s, target_pw:%s", host_password, target_password) + # netserver start automatically during the vm boot + LOG.info("user:%s, target:%s", target_user, target_ip) + self.server = ssh.SSH(target_user, target_ip, + password=target_password) + self.server.wait(timeout=600) + + LOG.info("user:%s, host:%s", host_user, host_ip) + self.client = ssh.SSH(host_user, host_ip, + password=host_password) + self.client.wait(timeout=600) + + # copy script to host + self.client.run("cat > ~/netperf.sh", + stdin=open(self.target_script, "rb")) + + # copy script to host and client + self.install_script = pkg_resources.resource_filename( + 'yardstick.benchmark.scenarios.networking', + NetperfNode.INSTALL_SCRIPT) + self.remove_script = pkg_resources.resource_filename( + 'yardstick.benchmark.scenarios.networking', + NetperfNode.REMOVE_SCRIPT) + + self.server.run("cat > ~/netperf_install.sh", + stdin=open(self.install_script, "rb")) + self.client.run("cat > ~/netperf_install.sh", + stdin=open(self.install_script, "rb")) + self.server.run("cat > ~/netperf_remove.sh", + stdin=open(self.remove_script, "rb")) + self.client.run("cat > ~/netperf_remove.sh", + stdin=open(self.remove_script, "rb")) + self.server.execute("sudo bash netperf_install.sh") + self.client.execute("sudo bash netperf_install.sh") + + self.setup_done = True + + def run(self, result): + """execute the benchmark""" + + if not self.setup_done: + self.setup() + + # get global options + ipaddr = self.context_cfg['target'].get("ipaddr", '127.0.0.1') + ipaddr = self.target_ip + options = self.scenario_cfg['options'] + testname = options.get("testname", 'TCP_STREAM') + duration_time = self.scenario_cfg["runner"].get("duration", None) \ + if "runner" in self.scenario_cfg else None + arithmetic_time = options.get("duration", None) + if duration_time: + testlen = duration_time + elif arithmetic_time: + testlen = arithmetic_time + else: + testlen = 20 + + cmd_args = "-H %s -l %s -t %s" % (ipaddr, testlen, testname) + + # get test specific options + default_args = "-O 'THROUGHPUT,THROUGHPUT_UNITS,MEAN_LATENCY'" + cmd_args += " -- %s" % default_args + option_pair_list = [("send_msg_size", "-m"), + ("recv_msg_size", "-M"), + ("req_rsp_size", "-r")] + for option_pair in option_pair_list: + if option_pair[0] in options: + cmd_args += " %s %s" % (option_pair[1], + options[option_pair[0]]) + + cmd = "sudo bash netperf.sh %s" % (cmd_args) + LOG.debug("Executing command: %s", cmd) + status, stdout, stderr = self.client.execute(cmd) + + if status: + raise RuntimeError(stderr) + + result.update(json.loads(stdout)) + + if result['mean_latency'] == '': + raise RuntimeError(stdout) + + # sla check + mean_latency = float(result['mean_latency']) + if "sla" in self.scenario_cfg: + sla_max_mean_latency = int( + self.scenario_cfg["sla"]["mean_latency"]) + + assert mean_latency <= sla_max_mean_latency, \ + "mean_latency %f > sla_max_mean_latency(%f); " % \ + (mean_latency, sla_max_mean_latency) + + def teardown(self): + '''remove netperf from nodes after test''' + self.server.execute("sudo bash netperf_remove.sh") + self.client.execute("sudo bash netperf_remove.sh") + + +def _test(): # pragma: no cover + '''internal test function''' + ctx = { + "host": { + "ip": "192.168.10.10", + "user": "root", + "password": "root" + }, + "target": { + "ip": "192.168.10.11", + "user": "root", + "password": "root" + } + } + + logger = logging.getLogger("yardstick") + logger.setLevel(logging.DEBUG) + + options = { + "testname": 'TCP_STREAM' + } + + args = {"options": options} + result = {} + + netperf = NetperfNode(args, ctx) + netperf.run(result) + print result + +if __name__ == '__main__': + _test() diff --git a/yardstick/benchmark/scenarios/networking/netperf_remove.bash b/yardstick/benchmark/scenarios/networking/netperf_remove.bash new file mode 100755 index 000000000..bb2299a2b --- /dev/null +++ b/yardstick/benchmark/scenarios/networking/netperf_remove.bash @@ -0,0 +1,21 @@ +#!/bin/bash + +############################################################################## +# Copyright (c) 2016 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 +############################################################################## + +set -e +echo "===Remove netperf after install begin!===" +cp /etc/apt/sources.list_bkp /etc/apt/sources.list +cp /etc/resolv.conf_bkp /etc/resolv.conf + +service netperf stop + +sudo apt-get purge -y netperf + +echo "===Remove netperf after install end!!!===" diff --git a/yardstick/cmd/commands/task.py b/yardstick/cmd/commands/task.py index 2bc5abe29..587f62412 100644 --- a/yardstick/cmd/commands/task.py +++ b/yardstick/cmd/commands/task.py @@ -282,8 +282,17 @@ class TaskParser(object): precondition = cfg["precondition"] installer_type = precondition.get("installer_type", None) deploy_scenarios = precondition.get("deploy_scenarios", None) + tc_fit_pods = precondition.get("pod_name", None) installer_type_env = os.environ.get('INSTALL_TYPE', None) deploy_scenario_env = os.environ.get('DEPLOY_SCENARIO', None) + pod_name_env = os.environ.get('NODE_NAME', None) + + LOG.info("installer_type: %s, installer_type_env: %s", + installer_type, installer_type_env) + LOG.info("deploy_scenarios: %s, deploy_scenario_env: %s", + deploy_scenarios, deploy_scenario_env) + LOG.info("tc_fit_pods: %s, pod_name_env: %s", + tc_fit_pods, pod_name_env) if installer_type and installer_type_env: if installer_type_env not in installer_type: return False @@ -293,6 +302,9 @@ class TaskParser(object): if deploy_scenario_env.startswith(deploy_scenario): return True return False + if tc_fit_pods and pod_name_env: + if pod_name_env not in tc_fit_pods: + return False return True |