aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc027.yaml1
-rw-r--r--tests/opnfv/test_suites/opnfv_os-nosdn-kvm-ha_daily.yaml22
-rw-r--r--tests/opnfv/test_suites/opnfv_os-nosdn-kvm_ovs-ha_daily.yaml22
-rw-r--r--tests/opnfv/test_suites/opnfv_os-nosdn-nofeature-ha_daily.yaml22
-rw-r--r--tests/opnfv/test_suites/opnfv_os-nosdn-ovs-ha_daily.yaml22
-rw-r--r--tests/opnfv/test_suites/opnfv_os-ocl-nofeature-ha_daily.yaml22
-rw-r--r--tests/opnfv/test_suites/opnfv_os-odl_l2-bgpvpn-ha_daily.yaml22
-rw-r--r--tests/opnfv/test_suites/opnfv_os-odl_l2-nofeature-ha_daily.yaml22
-rw-r--r--tests/opnfv/test_suites/opnfv_os-odl_l2-sfc-ha_daily.yaml22
-rw-r--r--tests/opnfv/test_suites/opnfv_os-odl_l3-nofeature-ha_daily.yaml22
-rw-r--r--tests/opnfv/test_suites/opnfv_os-onos-nofeature-ha_daily.yaml22
-rw-r--r--tests/opnfv/test_suites/opnfv_os-onos-sfc-ha_daily.yaml22
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_attacker_general.py2
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_basemonitor.py4
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_baseoperation.py6
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_director.py14
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_monitor_general.py8
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_scenario_general.py6
-rwxr-xr-xtests/unit/benchmark/scenarios/networking/test_netperf_node.py127
-rw-r--r--tests/unit/cmd/commands/test_task.py5
20 files changed, 393 insertions, 22 deletions
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)