diff mbox series

[ovs-dev,03/22] jsonrpc: Sort JSON objects while printing debug messages.

Message ID 20231214010431.1664005-4-i.maximets@ovn.org
State Accepted
Commit d07a3b798d7d04332d0f65dddacb09fc7ba04558
Delegated to: Ilya Maximets
Headers show
Series [ovs-dev,01/22] ovsdb-server.at: Enbale debug logs in active-backup tests. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/intel-ovs-compilation success test: success

Commit Message

Ilya Maximets Dec. 14, 2023, 1:04 a.m. UTC
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 <i.maximets@ovn.org>
---
 lib/jsonrpc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Mike Pattrick Jan. 2, 2024, 3:46 p.m. UTC | #1
On Wed, Dec 13, 2023 at 8:05 PM Ilya Maximets <i.maximets@ovn.org> wrote:
>
> 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 <i.maximets@ovn.org>

Acked-by: Mike Pattrick <mkp@redhat.com>
diff mbox series

Patch

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));