aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/benchmark/scenarios/availability
diff options
context:
space:
mode:
authorRoss Brattain <ross.b.brattain@intel.com>2017-03-01 17:28:46 -0800
committerJing Lu <lvjing5@huawei.com>2017-05-04 12:54:00 +0000
commit150481286dcf3c3c1fedd8213070cff48e5ad61d (patch)
treea8fc477a69e0a747612de328faaed57f55231973 /tests/unit/benchmark/scenarios/availability
parent478a499e8cb048abf434559c8d47259ec238ed24 (diff)
standardize ssh auth
we need to be following defautl paramiko rules, first use pkey, then key_filenames (autodetecting ~/.ssh/ keys), then password We have too much boilerplate redudant code everywhere, we need to standardize on a factory function that takes a node dict. Using Python3 ChainMap we can layer overrides and defaults. VNF descriptors have to default key_filename, password to Python None. The only way to do this is to omit key values if the variable is not defined, this way the dict will not have the value and it will default to Python None Add python2 chainmap backport Updated unittest mocking to use ssh.SSH.from_node Change-Id: I80b0cb606e593b33e317c9e5e8ed0b74da591514 Signed-off-by: Ross Brattain <ross.b.brattain@intel.com> (cherry picked from commit 99abbb424007da2e01762f3c040a39c0157cbe1f)
Diffstat (limited to 'tests/unit/benchmark/scenarios/availability')
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_attacker_baremetal.py6
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_attacker_general.py4
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_attacker_process.py4
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_monitor_command.py2
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_monitor_general.py6
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_monitor_process.py4
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_operation_general.py6
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_result_checker_general.py16
8 files changed, 24 insertions, 24 deletions
diff --git a/tests/unit/benchmark/scenarios/availability/test_attacker_baremetal.py b/tests/unit/benchmark/scenarios/availability/test_attacker_baremetal.py
index 9e2e8b172..28b27c78a 100644
--- a/tests/unit/benchmark/scenarios/availability/test_attacker_baremetal.py
+++ b/tests/unit/benchmark/scenarios/availability/test_attacker_baremetal.py
@@ -63,7 +63,7 @@ class AttackerBaremetalTestCase(unittest.TestCase):
ins = attacker_baremetal.BaremetalAttacker(self.attacker_cfg,
self.context)
- mock_ssh.SSH().execute.return_value = (0, "running", '')
+ mock_ssh.SSH.from_node().execute.return_value = (0, "running", '')
ins.setup()
ins.inject_fault()
ins.recover()
@@ -71,7 +71,7 @@ class AttackerBaremetalTestCase(unittest.TestCase):
def test__attacker_baremetal_check_failuer(self, mock_ssh):
ins = attacker_baremetal.BaremetalAttacker(self.attacker_cfg,
self.context)
- mock_ssh.SSH().execute.return_value = (0, "error check", '')
+ mock_ssh.SSH.from_node().execute.return_value = (0, "error check", '')
ins.setup()
def test__attacker_baremetal_recover_successful(self, mock_ssh):
@@ -81,6 +81,6 @@ class AttackerBaremetalTestCase(unittest.TestCase):
ins = attacker_baremetal.BaremetalAttacker(self.attacker_cfg,
self.context)
- mock_ssh.SSH().execute.return_value = (0, "running", '')
+ mock_ssh.SSH.from_node().execute.return_value = (0, "running", '')
ins.setup()
ins.recover()
diff --git a/tests/unit/benchmark/scenarios/availability/test_attacker_general.py b/tests/unit/benchmark/scenarios/availability/test_attacker_general.py
index 322b58391..612b5a662 100644
--- a/tests/unit/benchmark/scenarios/availability/test_attacker_general.py
+++ b/tests/unit/benchmark/scenarios/availability/test_attacker_general.py
@@ -44,7 +44,7 @@ class GeneralAttackerServiceTestCase(unittest.TestCase):
cls = baseattacker.BaseAttacker.get_attacker_cls(self.attacker_cfg)
ins = cls(self.attacker_cfg, self.context)
- mock_ssh.SSH().execute.return_value = (0, "running", '')
+ mock_ssh.SSH.from_node().execute.return_value = (0, "running", '')
ins.setup()
ins.inject_fault()
ins.recover()
@@ -54,5 +54,5 @@ class GeneralAttackerServiceTestCase(unittest.TestCase):
cls = baseattacker.BaseAttacker.get_attacker_cls(self.attacker_cfg)
ins = cls(self.attacker_cfg, self.context)
- mock_ssh.SSH().execute.return_value = (0, "error check", '')
+ mock_ssh.SSH.from_node().execute.return_value = (0, "error check", '')
ins.setup()
diff --git a/tests/unit/benchmark/scenarios/availability/test_attacker_process.py b/tests/unit/benchmark/scenarios/availability/test_attacker_process.py
index d7771bd33..eec512a58 100644
--- a/tests/unit/benchmark/scenarios/availability/test_attacker_process.py
+++ b/tests/unit/benchmark/scenarios/availability/test_attacker_process.py
@@ -41,7 +41,7 @@ class AttackerServiceTestCase(unittest.TestCase):
cls = baseattacker.BaseAttacker.get_attacker_cls(self.attacker_cfg)
ins = cls(self.attacker_cfg, self.context)
- mock_ssh.SSH().execute.return_value = (0, "running", '')
+ mock_ssh.SSH.from_node().execute.return_value = (0, "running", '')
ins.setup()
ins.inject_fault()
ins.recover()
@@ -51,5 +51,5 @@ class AttackerServiceTestCase(unittest.TestCase):
cls = baseattacker.BaseAttacker.get_attacker_cls(self.attacker_cfg)
ins = cls(self.attacker_cfg, self.context)
- mock_ssh.SSH().execute.return_value = (0, "error check", '')
+ mock_ssh.SSH.from_node().execute.return_value = (0, "error check", '')
ins.setup()
diff --git a/tests/unit/benchmark/scenarios/availability/test_monitor_command.py b/tests/unit/benchmark/scenarios/availability/test_monitor_command.py
index a84bfd2c5..c179bbfaf 100644
--- a/tests/unit/benchmark/scenarios/availability/test_monitor_command.py
+++ b/tests/unit/benchmark/scenarios/availability/test_monitor_command.py
@@ -87,5 +87,5 @@ class MonitorOpenstackCmdTestCase(unittest.TestCase):
instance = monitor_command.MonitorOpenstackCmd(
self.config, self.context)
instance.setup()
- mock_ssh.SSH().execute.return_value = (0, "0", '')
+ mock_ssh.SSH.from_node().execute.return_value = (0, "0", '')
ret = instance.monitor_func()
diff --git a/tests/unit/benchmark/scenarios/availability/test_monitor_general.py b/tests/unit/benchmark/scenarios/availability/test_monitor_general.py
index 369f6f4f7..169b630bf 100644
--- a/tests/unit/benchmark/scenarios/availability/test_monitor_general.py
+++ b/tests/unit/benchmark/scenarios/availability/test_monitor_general.py
@@ -53,7 +53,7 @@ class GeneralMonitorServiceTestCase(unittest.TestCase):
ins = monitor_general.GeneralMonitor(self.monitor_cfg, self.context)
ins.setup()
- mock_ssh.SSH().execute.return_value = (0, "running", '')
+ mock_ssh.SSH.from_node().execute.return_value = (0, "running", '')
ins.monitor_func()
ins._result = {'outage_time': 0}
ins.verify_SLA()
@@ -64,7 +64,7 @@ class GeneralMonitorServiceTestCase(unittest.TestCase):
self.monitor_cfg_noparam, self.context)
ins.setup()
- mock_ssh.SSH().execute.return_value = (0, "running", '')
+ mock_ssh.SSH.from_node().execute.return_value = (0, "running", '')
ins.monitor_func()
ins._result = {'outage_time': 0}
ins.verify_SLA()
@@ -74,7 +74,7 @@ class GeneralMonitorServiceTestCase(unittest.TestCase):
self.monitor_cfg_noparam, self.context)
ins.setup()
- mock_ssh.SSH().execute.return_value = (1, "error", 'error')
+ mock_ssh.SSH.from_node().execute.return_value = (1, "error", 'error')
ins.monitor_func()
ins._result = {'outage_time': 2}
ins.verify_SLA()
diff --git a/tests/unit/benchmark/scenarios/availability/test_monitor_process.py b/tests/unit/benchmark/scenarios/availability/test_monitor_process.py
index 8270405cd..8c267e413 100644
--- a/tests/unit/benchmark/scenarios/availability/test_monitor_process.py
+++ b/tests/unit/benchmark/scenarios/availability/test_monitor_process.py
@@ -42,7 +42,7 @@ class MonitorProcessTestCase(unittest.TestCase):
ins = monitor_process.MonitorProcess(self.monitor_cfg, self.context)
- mock_ssh.SSH().execute.return_value = (0, "1", '')
+ mock_ssh.SSH.from_node().execute.return_value = (0, "1", '')
ins.setup()
ins.monitor_func()
ins._result = {"outage_time": 0}
@@ -52,7 +52,7 @@ class MonitorProcessTestCase(unittest.TestCase):
ins = monitor_process.MonitorProcess(self.monitor_cfg, self.context)
- mock_ssh.SSH().execute.return_value = (0, "0", '')
+ mock_ssh.SSH.from_node().execute.return_value = (0, "0", '')
ins.setup()
ins.monitor_func()
ins._result = {"outage_time": 10}
diff --git a/tests/unit/benchmark/scenarios/availability/test_operation_general.py b/tests/unit/benchmark/scenarios/availability/test_operation_general.py
index 2c6dc1617..fb8ccb122 100644
--- a/tests/unit/benchmark/scenarios/availability/test_operation_general.py
+++ b/tests/unit/benchmark/scenarios/availability/test_operation_general.py
@@ -50,7 +50,7 @@ class GeneralOperaionTestCase(unittest.TestCase):
def test__operation_successful(self, mock_open, mock_ssh):
ins = operation_general.GeneralOperaion(self.operation_cfg,
self.context)
- mock_ssh.SSH().execute.return_value = (0, "success", '')
+ mock_ssh.SSH.from_node().execute.return_value = (0, "success", '')
ins.setup()
ins.run()
ins.rollback()
@@ -58,7 +58,7 @@ class GeneralOperaionTestCase(unittest.TestCase):
def test__operation_successful_noparam(self, mock_open, mock_ssh):
ins = operation_general.GeneralOperaion(self.operation_cfg_noparam,
self.context)
- mock_ssh.SSH().execute.return_value = (0, "success", '')
+ mock_ssh.SSH.from_node().execute.return_value = (0, "success", '')
ins.setup()
ins.run()
ins.rollback()
@@ -66,7 +66,7 @@ class GeneralOperaionTestCase(unittest.TestCase):
def test__operation_fail(self, mock_open, mock_ssh):
ins = operation_general.GeneralOperaion(self.operation_cfg,
self.context)
- mock_ssh.SSH().execute.return_value = (1, "failed", '')
+ mock_ssh.SSH.from_node().execute.return_value = (1, "failed", '')
ins.setup()
ins.run()
ins.rollback()
diff --git a/tests/unit/benchmark/scenarios/availability/test_result_checker_general.py b/tests/unit/benchmark/scenarios/availability/test_result_checker_general.py
index c5451fabd..d036bb0da 100644
--- a/tests/unit/benchmark/scenarios/availability/test_result_checker_general.py
+++ b/tests/unit/benchmark/scenarios/availability/test_result_checker_general.py
@@ -47,7 +47,7 @@ class GeneralResultCheckerTestCase(unittest.TestCase):
def test__result_checker_eq(self, mock_open, mock_ssh):
ins = result_checker_general.GeneralResultChecker(self.checker_cfg,
self.context)
- mock_ssh.SSH().execute.return_value = (0, "1", '')
+ mock_ssh.SSH.from_node().execute.return_value = (0, "1", '')
ins.setup()
self.assertTrue(ins.verify())
@@ -56,7 +56,7 @@ class GeneralResultCheckerTestCase(unittest.TestCase):
config['condition'] = 'gt'
ins = result_checker_general.GeneralResultChecker(config,
self.context)
- mock_ssh.SSH().execute.return_value = (0, "2", '')
+ mock_ssh.SSH.from_node().execute.return_value = (0, "2", '')
ins.setup()
self.assertTrue(ins.verify())
@@ -65,7 +65,7 @@ class GeneralResultCheckerTestCase(unittest.TestCase):
config['condition'] = 'gt_eq'
ins = result_checker_general.GeneralResultChecker(config,
self.context)
- mock_ssh.SSH().execute.return_value = (0, "1", '')
+ mock_ssh.SSH.from_node().execute.return_value = (0, "1", '')
ins.setup()
self.assertTrue(ins.verify())
@@ -74,7 +74,7 @@ class GeneralResultCheckerTestCase(unittest.TestCase):
config['condition'] = 'lt'
ins = result_checker_general.GeneralResultChecker(config,
self.context)
- mock_ssh.SSH().execute.return_value = (0, "0", '')
+ mock_ssh.SSH.from_node().execute.return_value = (0, "0", '')
ins.setup()
self.assertTrue(ins.verify())
@@ -83,7 +83,7 @@ class GeneralResultCheckerTestCase(unittest.TestCase):
config['condition'] = 'lt_eq'
ins = result_checker_general.GeneralResultChecker(config,
self.context)
- mock_ssh.SSH().execute.return_value = (0, "1", '')
+ mock_ssh.SSH.from_node().execute.return_value = (0, "1", '')
ins.setup()
self.assertTrue(ins.verify())
@@ -93,7 +93,7 @@ class GeneralResultCheckerTestCase(unittest.TestCase):
config['expectedValue'] = "value"
ins = result_checker_general.GeneralResultChecker(config,
self.context)
- mock_ssh.SSH().execute.return_value = (0, "value return", '')
+ mock_ssh.SSH.from_node().execute.return_value = (0, "value return", '')
ins.setup()
self.assertTrue(ins.verify())
@@ -102,7 +102,7 @@ class GeneralResultCheckerTestCase(unittest.TestCase):
config['condition'] = 'wrong'
ins = result_checker_general.GeneralResultChecker(config,
self.context)
- mock_ssh.SSH().execute.return_value = (0, "1", '')
+ mock_ssh.SSH.from_node().execute.return_value = (0, "1", '')
ins.setup()
self.assertFalse(ins.verify())
@@ -111,6 +111,6 @@ class GeneralResultCheckerTestCase(unittest.TestCase):
config.pop('parameter')
ins = result_checker_general.GeneralResultChecker(config,
self.context)
- mock_ssh.SSH().execute.return_value = (1, "fail", '')
+ mock_ssh.SSH.from_node().execute.return_value = (1, "fail", '')
ins.setup()
ins.verify()