[CVP] Switch RabbitMQ tests to JSON formatter
Newer RabbitMQ versions support JSON formatter output, which lets
avoid issues with CVP when node names are too long and split into
multiple lines.
Closes-Bug: PROD-36566
Change-Id: I7499467cfd98b80e12f43ba46b0429e3cef1efd4
diff --git a/test_set/cvp-sanity/tests/test_rabbit_cluster.py b/test_set/cvp-sanity/tests/test_rabbit_cluster.py
index c69d605..7038cb0 100644
--- a/test_set/cvp-sanity/tests/test_rabbit_cluster.py
+++ b/test_set/cvp-sanity/tests/test_rabbit_cluster.py
@@ -1,3 +1,4 @@
+import json
import utils
import pytest
@@ -48,7 +49,7 @@
expr_form='compound'
).popitem()[1]) >= 0
- suffix = ' --formatter erlang' if newer_rabbit else ''
+ suffix = ' --formatter json' if newer_rabbit else ''
# request actual data from rmq nodes
rabbit_actual_data = local_salt_client.cmd(
tgt='rabbitmq:server',
@@ -56,6 +57,17 @@
r'| grep "nodes,\|running_nodes"'.format(suffix),
expr_form='pillar'
)
+ if newer_rabbit:
+ temp = {}
+ for node in rabbit_actual_data:
+ try:
+ node_data = json.loads(rabbit_actual_data[node])
+ temp[node] = "{}, {}".format(
+ node_data["disk_nodes"], node_data["running_nodes"])
+ except json.decoder.JSONDecodeError:
+ pass
+ rabbit_actual_data = temp
+
for node in rabbitmq_pillar_data:
if node in config.get('skipped_nodes'):
del rabbit_actual_data[node]