Code Review
/
yardstick.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Merge "Add "volumeMounts" parameter in Kubernetes context"
[yardstick.git]
/
yardstick
/
tests
/
unit
/
benchmark
/
contexts
/
test_node.py
diff --git
a/yardstick/tests/unit/benchmark/contexts/test_node.py
b/yardstick/tests/unit/benchmark/contexts/test_node.py
index
9761f6d
..
b67be37
100644
(file)
--- a/
yardstick/tests/unit/benchmark/contexts/test_node.py
+++ b/
yardstick/tests/unit/benchmark/contexts/test_node.py
@@
-13,6
+13,7
@@
import errno
import mock
from yardstick.common import constants as consts
import mock
from yardstick.common import constants as consts
+from yardstick.benchmark.contexts import base
from yardstick.benchmark.contexts import node
from yardstick.benchmark.contexts import node
@@
-33,9
+34,11
@@
class NodeContextTestCase(unittest.TestCase):
'file': self._get_file_abspath(self.NODES_SAMPLE)
}
'file': self._get_file_abspath(self.NODES_SAMPLE)
}
- def _remove_contexts(self):
- if self.test_context in self.test_context.list:
- self.test_context._delete_context()
+ @staticmethod
+ def _remove_contexts():
+ for context in base.Context.list:
+ context._delete_context()
+ base.Context.list = []
def _get_file_abspath(self, filename):
curr_path = os.path.dirname(os.path.abspath(__file__))
def _get_file_abspath(self, filename):
curr_path = os.path.dirname(os.path.abspath(__file__))
@@
-176,7
+179,7
@@
class NodeContextTestCase(unittest.TestCase):
'type': 'script'
}
obj.deploy()
'type': 'script'
}
obj.deploy()
-
self.assertTrue(dispatch_script_mock.called
)
+
dispatch_script_mock.assert_called_once(
)
@mock.patch('{}.NodeContext._dispatch_ansible'.format(PREFIX))
def test_deploy_anisible(self, dispatch_ansible_mock):
@mock.patch('{}.NodeContext._dispatch_ansible'.format(PREFIX))
def test_deploy_anisible(self, dispatch_ansible_mock):
@@
-186,7
+189,7
@@
class NodeContextTestCase(unittest.TestCase):
'type': 'ansible'
}
obj.deploy()
'type': 'ansible'
}
obj.deploy()
-
self.assertTrue(dispatch_ansible_mock.called
)
+
dispatch_ansible_mock.assert_called_once(
)
@mock.patch('{}.NodeContext._dispatch_script'.format(PREFIX))
def test_undeploy(self, dispatch_script_mock):
@mock.patch('{}.NodeContext._dispatch_script'.format(PREFIX))
def test_undeploy(self, dispatch_script_mock):
@@
-195,7
+198,7
@@
class NodeContextTestCase(unittest.TestCase):
'type': 'script'
}
obj.undeploy()
'type': 'script'
}
obj.undeploy()
-
self.assertTrue(dispatch_script_mock.called
)
+
dispatch_script_mock.assert_called_once(
)
@mock.patch('{}.NodeContext._dispatch_ansible'.format(PREFIX))
def test_undeploy_anisble(self, dispatch_ansible_mock):
@mock.patch('{}.NodeContext._dispatch_ansible'.format(PREFIX))
def test_undeploy_anisble(self, dispatch_ansible_mock):
@@
-204,7
+207,7
@@
class NodeContextTestCase(unittest.TestCase):
'type': 'ansible'
}
obj.undeploy()
'type': 'ansible'
}
obj.undeploy()
-
self.assertTrue(dispatch_ansible_mock.called
)
+
dispatch_ansible_mock.assert_called_once(
)
@mock.patch('{}.ssh.SSH._put_file_shell'.format(PREFIX))
@mock.patch('{}.ssh.SSH.execute'.format(PREFIX))
@mock.patch('{}.ssh.SSH._put_file_shell'.format(PREFIX))
@mock.patch('{}.ssh.SSH.execute'.format(PREFIX))
@@
-224,8
+227,8
@@
class NodeContextTestCase(unittest.TestCase):
execute_mock.return_value = (0, '', '')
obj._execute_remote_script('node5', info)
execute_mock.return_value = (0, '', '')
obj._execute_remote_script('node5', info)
-
self.assertTrue(put_file_mock.called
)
-
self.assertTrue(execute_mock.called
)
+
put_file_mock.assert_called_once(
)
+
execute_mock.assert_called(
)
@mock.patch('{}.NodeContext._execute_local_script'.format(PREFIX))
def test_execute_script_local(self, local_execute_mock):
@mock.patch('{}.NodeContext._execute_local_script'.format(PREFIX))
def test_execute_script_local(self, local_execute_mock):
@@
-234,7
+237,7
@@
class NodeContextTestCase(unittest.TestCase):
obj = node.NodeContext()
self.addCleanup(obj._delete_context)
obj._execute_script(node_name, info)
obj = node.NodeContext()
self.addCleanup(obj._delete_context)
obj._execute_script(node_name, info)
-
self.assertTrue(local_execute_mock.called
)
+
local_execute_mock.assert_called_once(
)
@mock.patch('{}.NodeContext._execute_remote_script'.format(PREFIX))
def test_execute_script_remote(self, remote_execute_mock):
@mock.patch('{}.NodeContext._execute_remote_script'.format(PREFIX))
def test_execute_script_remote(self, remote_execute_mock):
@@
-243,7
+246,7
@@
class NodeContextTestCase(unittest.TestCase):
obj = node.NodeContext()
self.addCleanup(obj._delete_context)
obj._execute_script(node_name, info)
obj = node.NodeContext()
self.addCleanup(obj._delete_context)
obj._execute_script(node_name, info)
-
self.assertTrue(remote_execute_mock.called
)
+
remote_execute_mock.assert_called_once(
)
def test_get_script(self):
script_args = 'hello.bash'
def test_get_script(self):
script_args = 'hello.bash'
@@
-276,7
+279,7
@@
class NodeContextTestCase(unittest.TestCase):
'pwd': 'ubuntu',
}]
obj._get_client(node_name_args)
'pwd': 'ubuntu',
}]
obj._get_client(node_name_args)
-
self.assertTrue(wait_mock.called
)
+
wait_mock.assert_called_once(
)
def test_get_server(self):
self.test_context.init(self.attrs)
def test_get_server(self):
self.test_context.init(self.attrs)