Exclude cid01 and dbs01 nodes from test_check_module_versions
Related-PROD: PROD-21990
Change-Id: Ib7ac0fec5ef39c62fbb43b642ae599b1ea2252b3
diff --git a/cvp_checks/tests/test_packet_checker.py b/cvp_checks/tests/test_packet_checker.py
index a583c24..f76c339 100644
--- a/cvp_checks/tests/test_packet_checker.py
+++ b/cvp_checks/tests/test_packet_checker.py
@@ -1,26 +1,24 @@
import pytest
import json
-import os
-from cvp_checks import utils
def test_check_package_versions(local_salt_client, nodes_in_group):
- output = local_salt_client.cmd("L@"+','.join(nodes_in_group), 'lowpkg.list_pkgs', expr_form='compound')
+ output = local_salt_client.cmd("L@"+','.join(nodes_in_group),
+ 'lowpkg.list_pkgs',
+ expr_form='compound')
# Let's exclude cid01 and dbs01 nodes from this check
exclude_nodes = local_salt_client.cmd("I@galera:master or I@gerrit:client",
'test.ping',
expr_form='compound').keys()
-
- if len(output.keys()) < 2:
+ total_nodes = [i for i in output.keys() if i not in exclude_nodes]
+ if len(total_nodes) < 2:
pytest.skip("Nothing to compare - only 1 node")
nodes = []
pkts_data = []
my_set = set()
- for node in output:
- if node in exclude_nodes:
- continue
+ for node in total_nodes:
nodes.append(node)
my_set.update(output[node].keys())
@@ -44,19 +42,29 @@
def test_check_module_versions(local_salt_client, nodes_in_group):
pre_check = local_salt_client.cmd(
- "L@"+','.join(nodes_in_group), 'cmd.run', ['dpkg -l | grep "python-pip "'], expr_form='compound')
+ "L@"+','.join(nodes_in_group),
+ 'cmd.run',
+ ['dpkg -l | grep "python-pip "'],
+ expr_form='compound')
if pre_check.values().count('') > 0:
pytest.skip("pip is not installed on one or more nodes")
- if len(pre_check.keys()) < 2:
+
+ exclude_nodes = local_salt_client.cmd("I@galera:master or I@gerrit:client",
+ 'test.ping',
+ expr_form='compound').keys()
+ total_nodes = [i for i in pre_check.keys() if i not in exclude_nodes]
+
+ if len(total_nodes) < 2:
pytest.skip("Nothing to compare - only 1 node")
- output = local_salt_client.cmd("L@"+','.join(nodes_in_group), 'pip.freeze', expr_form='compound')
+ output = local_salt_client.cmd("L@"+','.join(nodes_in_group),
+ 'pip.freeze', expr_form='compound')
nodes = []
pkts_data = []
my_set = set()
- for node in output:
+ for node in total_nodes:
nodes.append(node)
my_set.update([x.split("=")[0] for x in output[node]])
output[node] = dict([x.split("==") for x in output[node]])