Add test to check # of node in reclass and in salt

Related-PROD: PROD-22775

Change-Id: I6b69844b52691c8d0bfd3f5994d159cde9ad0606
diff --git a/test_set/cvp-sanity/tests/test_salt_master.py b/test_set/cvp-sanity/tests/test_salt_master.py
index 7ae5754..546ff75 100644
--- a/test_set/cvp-sanity/tests/test_salt_master.py
+++ b/test_set/cvp-sanity/tests/test_salt_master.py
@@ -1,8 +1,11 @@
+import json
+
+
 def test_uncommited_changes(local_salt_client):
     git_status = local_salt_client.cmd(
         tgt='salt:master',
         param='cd /srv/salt/reclass/classes/cluster/; git status',
-        expr_form='pillar')
+        expr_form='pillar', check_status=True)
     assert 'nothing to commit' in git_status.values()[0], 'Git status showed' \
            ' some unmerged changes {}'''.format(git_status.values()[0])
 
@@ -11,8 +14,29 @@
     reclass = local_salt_client.cmd(
         tgt='salt:master',
         param='reclass-salt --top; echo $?',
-        expr_form='pillar')
+        expr_form='pillar', check_status=True)
     result = reclass[reclass.keys()[0]][-1]
 
     assert result == '0', 'Reclass is broken' \
                           '\n {}'.format(reclass)
+
+
+def test_reclass_nodes(local_salt_client):
+    reclass = local_salt_client.cmd(
+        tgt='salt:master',
+        param='reclass-salt -o json --top',
+        expr_form='pillar', check_status=True)
+    salt = local_salt_client.cmd(
+        tgt='salt:master',
+        param='salt-run manage.status timeout=10 --out=json',
+        expr_form='pillar', check_status=True).values()[0]
+    reclass_warnings = reclass[reclass.keys()[0]].split('{\n  "base":')[0]
+    if reclass_warnings:
+        print "\nReclass-salt output has warnings"
+    reclass_nodes = reclass[reclass.keys()[0]].split('{\n  "base":')[1]
+    assert reclass_nodes != '', 'No nodes were found in' \
+                                ' reclass-salt --top output'
+    reclass_nodes = sorted(json.loads(reclass_nodes.strip("}")).keys())
+    salt_nodes = sorted([x for xs in json.loads(salt).values() for x in xs])
+    assert salt_nodes == reclass_nodes, 'Mismatch between registered salt nodes (left) ' \
+                                        'and defined reclass nodes (right)'