We compare the logs in some tests, for example record/replay tests.
And those fail if for some reason the JSON object traversal happens
in the different order.

Sort the output in debug logs in order to fix sporadic test failures.
Should not affect performance in real-world cases as the actual
outgoing message is still not sorted.

Signed-off-by: Ilya Maximets <[email protected]>
---
 lib/jsonrpc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/jsonrpc.c b/lib/jsonrpc.c
index c8ce5362e..3db5f76e2 100644
--- a/lib/jsonrpc.c
+++ b/lib/jsonrpc.c
@@ -221,19 +221,19 @@ jsonrpc_log_msg(const struct jsonrpc *rpc, const char 
*title,
         }
         if (msg->params) {
             ds_put_cstr(&s, ", params=");
-            json_to_ds(msg->params, 0, &s);
+            json_to_ds(msg->params, JSSF_SORT, &s);
         }
         if (msg->result) {
             ds_put_cstr(&s, ", result=");
-            json_to_ds(msg->result, 0, &s);
+            json_to_ds(msg->result, JSSF_SORT, &s);
         }
         if (msg->error) {
             ds_put_cstr(&s, ", error=");
-            json_to_ds(msg->error, 0, &s);
+            json_to_ds(msg->error, JSSF_SORT, &s);
         }
         if (msg->id) {
             ds_put_cstr(&s, ", id=");
-            json_to_ds(msg->id, 0, &s);
+            json_to_ds(msg->id, JSSF_SORT, &s);
         }
         VLOG_DBG("%s: %s %s%s", rpc->name, title,
                  jsonrpc_msg_type_to_string(msg->type), ds_cstr(&s));
-- 
2.43.0

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to