Currently, test_ofctl compares the sent messages in binary, so it
is difficult to figure out the differences of the sent messages
and the expected messages.

This patch fixes to compare the sent messages in json representation
in order to make easy to debug.

Signed-off-by: IWASE Yusuke <[email protected]>
---
 ryu/tests/unit/lib/test_ofctl.py | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/ryu/tests/unit/lib/test_ofctl.py b/ryu/tests/unit/lib/test_ofctl.py
index adb2719..a8ca01f 100644
--- a/ryu/tests/unit/lib/test_ofctl.py
+++ b/ryu/tests/unit/lib/test_ofctl.py
@@ -73,11 +73,12 @@ class Test_ofctl(unittest.TestCase):
         # expected message <--> sent message
         request.serialize()
         try:
-            eq_(request.buf, dp.request_msg.buf)
+            eq_(request.to_jsondict(), dp.request_msg.to_jsondict())
         except AssertionError as e:
             # For debugging
             json.dump(dp.request_msg.to_jsondict(),
-                      open('/tmp/' + name, 'w'), indent=3, sort_keys=True)
+                      open('/tmp/' + name + '_request.json', 'w'),
+                      indent=3, sort_keys=True)
             raise e
 
         # expected output <--> return of ofctl
@@ -99,7 +100,8 @@ class Test_ofctl(unittest.TestCase):
                 _remove(output, ['len', 'length']))
         except AssertionError as e:
             # For debugging
-            json.dump(output, open('/tmp/' + name, 'w'), indent=4)
+            json.dump(output, open('/tmp/' + name + '_reply.json', 'w'),
+                      indent=4)
             raise e
 
 
@@ -314,7 +316,7 @@ def _add_tests():
         parser_json_dir = os.path.join(parser_json_root, ofp_ver)
         ofctl_json_dir = os.path.join(ofctl_json_root, ofp_ver)
         for test in tests:
-            name = 'test_ofctl_' + test['request']
+            name = 'test_ofctl_' + ofp_ver + '_' + test['method'].__name__
             print('adding %s ...' % name)
             args = {}
             args_json_path = os.path.join(ofctl_json_dir, test['request'])
-- 
1.9.1


------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to