summaryrefslogtreecommitdiffstats
path: root/tests/unit/benchmark/scenarios/storage
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/storage
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/storage')
-rw-r--r--tests/unit/benchmark/scenarios/storage/test_fio.py34
-rw-r--r--tests/unit/benchmark/scenarios/storage/test_storagecapacity.py10
2 files changed, 22 insertions, 22 deletions
diff --git a/tests/unit/benchmark/scenarios/storage/test_fio.py b/tests/unit/benchmark/scenarios/storage/test_fio.py
index 603ff389e..55e443885 100644
--- a/tests/unit/benchmark/scenarios/storage/test_fio.py
+++ b/tests/unit/benchmark/scenarios/storage/test_fio.py
@@ -51,7 +51,7 @@ class FioTestCase(unittest.TestCase):
p = fio.Fio(args, self.ctx)
p.setup()
- mock_ssh.SSH().execute.return_value = (0, '', '')
+ mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
self.assertIsNotNone(p.client)
self.assertEqual(p.setup_done, True)
@@ -67,10 +67,10 @@ class FioTestCase(unittest.TestCase):
p = fio.Fio(args, self.ctx)
result = {}
- p.client = mock_ssh.SSH()
+ p.client = mock_ssh.SSH.from_node()
sample_output = self._read_sample_output(self.sample_output['rw'])
- mock_ssh.SSH().execute.return_value = (0, sample_output, '')
+ mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
p.run(result)
@@ -92,10 +92,10 @@ class FioTestCase(unittest.TestCase):
p = fio.Fio(args, self.ctx)
result = {}
- p.client = mock_ssh.SSH()
+ p.client = mock_ssh.SSH.from_node()
sample_output = self._read_sample_output(self.sample_output['read'])
- mock_ssh.SSH().execute.return_value = (0, sample_output, '')
+ mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
p.run(result)
@@ -116,10 +116,10 @@ class FioTestCase(unittest.TestCase):
p = fio.Fio(args, self.ctx)
result = {}
- p.client = mock_ssh.SSH()
+ p.client = mock_ssh.SSH.from_node()
sample_output = self._read_sample_output(self.sample_output['write'])
- mock_ssh.SSH().execute.return_value = (0, sample_output, '')
+ mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
p.run(result)
@@ -143,10 +143,10 @@ class FioTestCase(unittest.TestCase):
p = fio.Fio(args, self.ctx)
result = {}
- p.client = mock_ssh.SSH()
+ p.client = mock_ssh.SSH.from_node()
sample_output = self._read_sample_output(self.sample_output['rw'])
- mock_ssh.SSH().execute.return_value = (0, sample_output, '')
+ mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
p.run(result)
@@ -171,10 +171,10 @@ class FioTestCase(unittest.TestCase):
p = fio.Fio(args, self.ctx)
result = {}
- p.client = mock_ssh.SSH()
+ p.client = mock_ssh.SSH.from_node()
sample_output = self._read_sample_output(self.sample_output['rw'])
- mock_ssh.SSH().execute.return_value = (0, sample_output, '')
+ mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
self.assertRaises(AssertionError, p.run, result)
def test_fio_successful_bw_iops_sla(self, mock_ssh):
@@ -192,10 +192,10 @@ class FioTestCase(unittest.TestCase):
p = fio.Fio(args, self.ctx)
result = {}
- p.client = mock_ssh.SSH()
+ p.client = mock_ssh.SSH.from_node()
sample_output = self._read_sample_output(self.sample_output['rw'])
- mock_ssh.SSH().execute.return_value = (0, sample_output, '')
+ mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
p.run(result)
@@ -220,10 +220,10 @@ class FioTestCase(unittest.TestCase):
p = fio.Fio(args, self.ctx)
result = {}
- p.client = mock_ssh.SSH()
+ p.client = mock_ssh.SSH.from_node()
sample_output = self._read_sample_output(self.sample_output['rw'])
- mock_ssh.SSH().execute.return_value = (0, sample_output, '')
+ mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
self.assertRaises(AssertionError, p.run, result)
def test_fio_unsuccessful_script_error(self, mock_ssh):
@@ -238,9 +238,9 @@ class FioTestCase(unittest.TestCase):
p = fio.Fio(args, self.ctx)
result = {}
- p.client = mock_ssh.SSH()
+ p.client = mock_ssh.SSH.from_node()
- mock_ssh.SSH().execute.return_value = (1, '', 'FOOBAR')
+ mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
self.assertRaises(RuntimeError, p.run, result)
def _read_sample_output(self, file_name):
diff --git a/tests/unit/benchmark/scenarios/storage/test_storagecapacity.py b/tests/unit/benchmark/scenarios/storage/test_storagecapacity.py
index 6fb5f5686..095674f72 100644
--- a/tests/unit/benchmark/scenarios/storage/test_storagecapacity.py
+++ b/tests/unit/benchmark/scenarios/storage/test_storagecapacity.py
@@ -50,7 +50,7 @@ class StorageCapacityTestCase(unittest.TestCase):
def test_capacity_successful_setup(self, mock_ssh):
c = storagecapacity.StorageCapacity(self.scn, self.ctx)
- mock_ssh.SSH().execute.return_value = (0, '', '')
+ mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
c.setup()
self.assertIsNotNone(c.client)
self.assertTrue(c.setup_done)
@@ -58,7 +58,7 @@ class StorageCapacityTestCase(unittest.TestCase):
def test_capacity_disk_size_successful(self, mock_ssh):
c = storagecapacity.StorageCapacity(self.scn, self.ctx)
- mock_ssh.SSH().execute.return_value = (0, DISK_SIZE_SAMPLE_OUTPUT, '')
+ mock_ssh.SSH.from_node().execute.return_value = (0, DISK_SIZE_SAMPLE_OUTPUT, '')
c.run(self.result)
expected_result = jsonutils.loads(
DISK_SIZE_SAMPLE_OUTPUT)
@@ -72,7 +72,7 @@ class StorageCapacityTestCase(unittest.TestCase):
}
c = storagecapacity.StorageCapacity(args, self.ctx)
- mock_ssh.SSH().execute.return_value = (0, BLOCK_SIZE_SAMPLE_OUTPUT, '')
+ mock_ssh.SSH.from_node().execute.return_value = (0, BLOCK_SIZE_SAMPLE_OUTPUT, '')
c.run(self.result)
expected_result = jsonutils.loads(
BLOCK_SIZE_SAMPLE_OUTPUT)
@@ -88,7 +88,7 @@ class StorageCapacityTestCase(unittest.TestCase):
}
c = storagecapacity.StorageCapacity(args, self.ctx)
- mock_ssh.SSH().execute.return_value = (0, DISK_UTIL_RAW_OUTPUT, '')
+ mock_ssh.SSH.from_node().execute.return_value = (0, DISK_UTIL_RAW_OUTPUT, '')
c.run(self.result)
expected_result = jsonutils.loads(
DISK_UTIL_SAMPLE_OUTPUT)
@@ -97,7 +97,7 @@ class StorageCapacityTestCase(unittest.TestCase):
def test_capacity_unsuccessful_script_error(self, mock_ssh):
c = storagecapacity.StorageCapacity(self.scn, self.ctx)
- mock_ssh.SSH().execute.return_value = (1, '', 'FOOBAR')
+ mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
self.assertRaises(RuntimeError, c.run, self.result)