summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorIWASE Yusuke <iwase.yusuke0@gmail.com>2015-10-26 17:30:56 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-10-28 14:32:03 +0900
commit7af6e28ea3e43766d7d8210e4658848483bb776c (patch)
treee9a57740272e32b2a44b27ce3a42f22969651b33
parentce6e5ddd62fecc039887e61f4045b8acb90d49da (diff)
tester: Reduce pylint warnings
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/tests/switch/tester.py59
1 files changed, 26 insertions, 33 deletions
diff --git a/ryu/tests/switch/tester.py b/ryu/tests/switch/tester.py
index 0912a57c..f678663f 100644
--- a/ryu/tests/switch/tester.py
+++ b/ryu/tests/switch/tester.py
@@ -28,17 +28,6 @@ import traceback
from random import randint
from ryu import cfg
-
-# import all packet libraries.
-PKT_LIB_PATH = 'ryu.lib.packet'
-for modname, moddef in sys.modules.items():
- if not modname.startswith(PKT_LIB_PATH) or not moddef:
- continue
- for (clsname, clsdef, ) in inspect.getmembers(moddef):
- if not inspect.isclass(clsdef):
- continue
- exec('from %s import %s' % (modname, clsname))
-
from ryu.base import app_manager
from ryu.controller import handler
from ryu.controller import ofp_event
@@ -56,6 +45,16 @@ from ryu.ofproto import ofproto_v1_3
from ryu.ofproto import ofproto_v1_4
from ryu.ofproto import ofproto_v1_5
+# import all packet libraries.
+PKT_LIB_PATH = 'ryu.lib.packet'
+for modname, moddef in sys.modules.items():
+ if not modname.startswith(PKT_LIB_PATH) or not moddef:
+ continue
+ for (clsname, clsdef, ) in inspect.getmembers(moddef):
+ if not inspect.isclass(clsdef):
+ continue
+ exec('from %s import %s' % (modname, clsname))
+
""" Required test network:
@@ -341,11 +340,10 @@ class OfTester(app_manager.RyuApp):
def _convert_dpid(self, dpid_str):
try:
- dpid = int(dpid_str, 16)
+ return int(dpid_str, 16)
except ValueError as err:
self.logger.error('Invarid dpid parameter. %s', err)
self._test_end()
- return dpid
def close(self):
if self.test_thread is not None:
@@ -539,8 +537,8 @@ class OfTester(app_manager.RyuApp):
self.logger.info(' %-100s %s', test.description, result[0])
if 1 < len(result):
self.logger.info(' %s', result[1])
- if (result[1] == RYU_INTERNAL_ERROR
- or result == 'An unknown exception'):
+ if result[1] == RYU_INTERNAL_ERROR\
+ or result == 'An unknown exception':
self.logger.error(traceback.format_exc())
hub.sleep(0)
@@ -918,13 +916,11 @@ class OfTester(app_manager.RyuApp):
value1 = __reasm_match(value1)
value2 = __reasm_match(value2)
if str(value1) != str(value2):
- flow_stats = []
- for attr in attr_list:
- flow_stats.append('%s=%s' % (attr, getattr(stats1, attr)))
- return False, 'flow_stats(%s)' % ','.join(flow_stats)
+ return False, 'flow_stats(%s != %s)' % (value1, value2)
return True, None
- def _compare_meter(self, stats1, stats2):
+ @classmethod
+ def _compare_meter(cls, stats1, stats2):
"""compare the message used to install and the message got from
the switch."""
attr_list = ['flags', 'meter_id', 'bands']
@@ -932,25 +928,21 @@ class OfTester(app_manager.RyuApp):
value1 = getattr(stats1, attr)
value2 = getattr(stats2, attr)
if str(value1) != str(value2):
- meter_stats = []
- for attr in attr_list:
- meter_stats.append('%s=%s' % (attr, getattr(stats1, attr)))
- return False, 'meter_stats(%s)' % ','.join(meter_stats)
+ return False, 'meter_stats(%s != %s)' % (value1, value2)
return True, None
- def _compare_group(self, stats1, stats2):
+ @classmethod
+ def _compare_group(cls, stats1, stats2):
attr_list = ['type', 'group_id', 'buckets']
for attr in attr_list:
value1 = getattr(stats1, attr)
value2 = getattr(stats2, attr)
if str(value1) != str(value2):
- group_stats = []
- for attr in attr_list:
- group_stats.append('%s=%s' % (attr, getattr(stats1, attr)))
- return False, 'group_stats(%s)' % ','.join(group_stats)
+ return False, 'group_stats(%s != %s)' % (value1, value2)
return True, None
- def _diff_packets(self, model_pkt, rcv_pkt):
+ @classmethod
+ def _diff_packets(cls, model_pkt, rcv_pkt):
msg = []
for rcv_p in rcv_pkt.protocols:
if not isinstance(rcv_p, six.binary_type):
@@ -1004,7 +996,7 @@ class OfTester(app_manager.RyuApp):
if stat.cookie != THROUGHPUT_COOKIE:
continue
result[str(stat.match)] = (stat.byte_count, stat.packet_count)
- return (time.time(), result)
+ return time.time(), result
def _test_throughput_check(self, throughputs, start, end):
msgs = []
@@ -1376,7 +1368,8 @@ class Test(stringify.StringifyMixin):
self.prerequisite,
self.tests) = self._parse_test(test_json)
- def _parse_test(self, buf):
+ @classmethod
+ def _parse_test(cls, buf):
def __test_pkt_from_json(test):
data = eval('/'.join(test))
data.serialize()
@@ -1468,7 +1461,7 @@ class Test(stringify.StringifyMixin):
tests.append(test_pkt)
- return (description, prerequisite, tests)
+ return description, prerequisite, tests
class DummyDatapath(ofproto_protocol.ProtocolDesc):