aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/benchmark
diff options
context:
space:
mode:
authorRoss Brattain <ross.b.brattain@intel.com>2017-01-26 15:14:59 -0800
committerRoss Brattain <ross.b.brattain@intel.com>2017-02-08 06:50:31 +0000
commit0464f576ffaa830a30f984df3e61bd29b15ddcaa (patch)
treef7fce48f61f1d96a33cf6aca398c05c594dd7b4c /tests/unit/benchmark
parenta4241e6e9b121447a50fdfe0d79b322c2e2aaea9 (diff)
vnf_generic: convert sshmanager to class
@contextmanager have an issue with respect to exceptions that makes them not suitable for real usage. @contextmanager uses yield to create a generator and then uses generator.throw() to raise any exceptions. Exceptions thrown from generators loose their call stack due to the way generators work, so any exception inside a context manager is harder to debug. For this reason we don't use @contextmanager and instead always define a new class with __enter__ and __exit__. There is sample code that demonstrates the issue with @contextmanager and generator.throw() here https://gist.github.com/rbbratta/e28b6e64a4551522c3ac9815ca7f25f0 Change-Id: I5383c01f40a63e33680112f39b5bd9c858e328f1 Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
Diffstat (limited to 'tests/unit/benchmark')
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_vnf_generic.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py b/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py
index 0d9fbafc5..9b7174e7e 100644
--- a/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py
+++ b/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py
@@ -23,7 +23,7 @@ import mock
import os
from yardstick.benchmark.scenarios.networking.vnf_generic import \
- ssh_manager, NetworkServiceTestCase, IncorrectConfig, IncorrectSetup
+ SshManager, NetworkServiceTestCase, IncorrectConfig, IncorrectSetup
from yardstick.network_services.collector.subscriber import Collector
from yardstick.network_services.vnf_generic.vnf.base import \
GenericTrafficGen, GenericVNF
@@ -304,7 +304,7 @@ class TestNetworkServiceTestCase(unittest.TestCase):
mock.Mock(return_value=(0, SYS_CLASS_NET+IP_ADDR_SHOW, ""))
ssh.return_value = ssh_mock
for node, node_dict in self.context_cfg["nodes"].items():
- with ssh_manager(node_dict) as conn:
+ with SshManager(node_dict) as conn:
self.assertIsNotNone(conn)
def test___init__(self):