Get group fix,flake8 errors fix,readme and config fix
diff --git a/cvp_checks/global_config.yaml b/cvp_checks/global_config.yaml
index 5b8e6c2..74dbbb5 100644
--- a/cvp_checks/global_config.yaml
+++ b/cvp_checks/global_config.yaml
@@ -12,15 +12,15 @@
# TEMPORARY: please do not comment this setting.
skipped_groups: [""]
-# Some tests may skip groups
-#test_mtu: {"skipped_groups": ["dbs"]}
+# mtu test setting
+# this test may skip groups (see example)
+test_mtu:
+ { #"skipped_groups": ["dbs"]
+ "skipped_ifaces": ["bonding_masters", "lo", "veth", "tap", "cali"]}
+# mask for interfaces to skip
# ntp test setting
# this test may skip specific node (use fqdn)
test_ntp_sync:
{ #"skipped_nodes": [""],
"time_deviation": 30}
-
-# mtu test setting
-# mask for interfaces to skip
-skipped_ifaces: ["bonding_masters", "lo", "veth", "tap", "cali"]
diff --git a/cvp_checks/tests/ceph/test_ceph_haproxy.py b/cvp_checks/tests/ceph/test_ceph_haproxy.py
index 7bff15b..d6c8e49 100644
--- a/cvp_checks/tests/ceph/test_ceph_haproxy.py
+++ b/cvp_checks/tests/ceph/test_ceph_haproxy.py
@@ -8,9 +8,9 @@
monitor_info = local_salt_client.cmd(
'ceph:mon',
'cmd.run',
- ["echo 'show stat' | nc -U "
- "/var/run/haproxy/admin.sock | "
- "grep ceph_mon_radosgw_cluster"],
+ ["echo 'show stat' | nc -U "
+ "/var/run/haproxy/admin.sock | "
+ "grep ceph_mon_radosgw_cluster"],
expr_form='pillar')
if not monitor_info:
pytest.skip("Ceph is not found on this environment")
diff --git a/cvp_checks/tests/test_contrail.py b/cvp_checks/tests/test_contrail.py
index a469976..b8955f0 100644
--- a/cvp_checks/tests/test_contrail.py
+++ b/cvp_checks/tests/test_contrail.py
@@ -1,6 +1,7 @@
import pytest
import json
+
def test_contrail_compute_status(local_salt_client):
probe = local_salt_client.cmd(
'opencontrail:control', 'cmd.run',
@@ -51,7 +52,7 @@
if 'crashes/core.java.' not in line:
name, status = line.split(None, 1)
else:
- name, status = line,'FATAL'
+ name, status = line, 'FATAL'
if status not in {'active', 'backup'}:
err_msg = "{node}:{service} - {status}".format(
node=node, service=name, status=status)
diff --git a/cvp_checks/tests/test_galera_cluster.py b/cvp_checks/tests/test_galera_cluster.py
index 003b0d6..5a74bdd 100644
--- a/cvp_checks/tests/test_galera_cluster.py
+++ b/cvp_checks/tests/test_galera_cluster.py
@@ -1,3 +1,6 @@
+import pytest
+
+
def test_galera_cluster_status(local_salt_client):
gs = local_salt_client.cmd(
'galera:*',
diff --git a/cvp_checks/tests/test_k8s.py b/cvp_checks/tests/test_k8s.py
index d7aed4b..2ff3383 100644
--- a/cvp_checks/tests/test_k8s.py
+++ b/cvp_checks/tests/test_k8s.py
@@ -1,6 +1,7 @@
import pytest
import json
+
def test_k8s_get_cs_status(local_salt_client):
result = local_salt_client.cmd(
'etcd:server', 'cmd.run',
@@ -17,11 +18,11 @@
continue
else:
if 'Healthy' not in line:
- errors.append (line)
+ errors.append(line)
break
assert not errors, 'k8s is not healthy: {}'.format(json.dumps(
- errors,
- indent=4))
+ errors,
+ indent=4))
def test_k8s_get_nodes_status(local_salt_client):
@@ -40,8 +41,8 @@
continue
else:
if 'Ready' not in line:
- errors.append (line)
+ errors.append(line)
break
assert not errors, 'k8s is not healthy: {}'.format(json.dumps(
- errors,
- indent=4))
+ errors,
+ indent=4))
diff --git a/cvp_checks/tests/test_mtu.py b/cvp_checks/tests/test_mtu.py
index be17237..8d76cef 100644
--- a/cvp_checks/tests/test_mtu.py
+++ b/cvp_checks/tests/test_mtu.py
@@ -9,10 +9,12 @@
utils.get_groups(os.path.basename(__file__))
)
def test_mtu(local_salt_client, group):
+ testname = os.path.basename(__file__).split('.')[0]
if "skipped" in group:
pytest.skip("skipped in config")
config = utils.get_configuration()
- skipped_ifaces = config["skipped_ifaces"]
+ skipped_ifaces = config.get(testname)["skipped_ifaces"] or \
+ ["bonding_masters", "lo", "veth", "tap", "cali"]
total = {}
network_info = local_salt_client.cmd(
group, 'cmd.run', ['ls /sys/class/net/'], expr_form='pcre')
@@ -68,4 +70,3 @@
assert len(mtu_data) == 0, \
"Several problems found for {0} group: {1}".format(
group, json.dumps(mtu_data, indent=4))
-
diff --git a/cvp_checks/tests/test_ntp_sync.py b/cvp_checks/tests/test_ntp_sync.py
index b900e12..09b323f 100644
--- a/cvp_checks/tests/test_ntp_sync.py
+++ b/cvp_checks/tests/test_ntp_sync.py
@@ -17,9 +17,10 @@
'cmd.run',
['date +%s'],
expr_form='compound')
+ diff = config.get(testname)["time_deviation"] or 30
for node, time in nodes_time.iteritems():
- if (int(time) - saltmaster_time) > config.get(testname)["time_deviation"] or \
- (int(time) - saltmaster_time) < -config.get(testname)["time_deviation"]:
+ if (int(time) - saltmaster_time) > diff or \
+ (int(time) - saltmaster_time) < -diff:
fail[node] = time
assert not fail, 'SaltMaster time: {}\n' \
diff --git a/cvp_checks/tests/test_rabbit_cluster.py b/cvp_checks/tests/test_rabbit_cluster.py
index 94de975..acd4a96 100644
--- a/cvp_checks/tests/test_rabbit_cluster.py
+++ b/cvp_checks/tests/test_rabbit_cluster.py
@@ -1,6 +1,3 @@
-import re
-
-
def test_checking_rabbitmq_cluster(local_salt_client):
# disable config for this test
# it may be reintroduced in future
diff --git a/cvp_checks/tests/test_repo_list.py b/cvp_checks/tests/test_repo_list.py
index bd3214c..07f16d0 100644
--- a/cvp_checks/tests/test_repo_list.py
+++ b/cvp_checks/tests/test_repo_list.py
@@ -19,9 +19,10 @@
['cat /etc/apt/sources.list.d/*;'
'cat /etc/apt/sources.list|grep deb|grep -v "#"'],
expr_form='pcre')
- actual_repo_list = [item.replace('/ ', ' ').replace('[arch=amd64] ','')
+ actual_repo_list = [item.replace('/ ', ' ').replace('[arch=amd64] ', '')
for item in raw_actual_info.values()[0].split('\n')]
- expected_salt_data = [repo['source'].replace('/ ', ' ').replace('[arch=amd64] ','')
+ expected_salt_data = [repo['source'].replace('/ ', ' ')
+ .replace('[arch=amd64] ', '')
for repo in info_salt.values()[0]
['linux:system:repo'].values()]
@@ -44,6 +45,6 @@
diff[repo] = rows
assert fail_counter == 0, \
"Several problems found for {0} group: {1}".format(
- group, json.dumps(diff, indent=4))
+ group, json.dumps(diff, indent=4))
if fail_counter == 0 and len(diff) > 0:
print "\nWarning: nodes contain more repos than reclass"
diff --git a/cvp_checks/utils/__init__.py b/cvp_checks/utils/__init__.py
index 85f5a61..4475683 100644
--- a/cvp_checks/utils/__init__.py
+++ b/cvp_checks/utils/__init__.py
@@ -2,19 +2,25 @@
import yaml
import requests
import re
-import pytest
+
class salt_remote:
- def cmd(self, tgt, fun, param=None,expr_form=None,tgt_type=None):
+ def cmd(self, tgt, fun, param=None, expr_form=None, tgt_type=None):
config = get_configuration()
- headers = {'Accept':'application/json'}
- login_payload = {'username':config['SALT_USERNAME'],'password':config['SALT_PASSWORD'],'eauth':'pam'}
- accept_key_payload = {'fun': fun,'tgt':tgt,'client':'local','expr_form':expr_form,'tgt_type':tgt_type}
+ headers = {'Accept': 'application/json'}
+ login_payload = {'username': config['SALT_USERNAME'],
+ 'password': config['SALT_PASSWORD'], 'eauth': 'pam'}
+ accept_key_payload = {'fun': fun, 'tgt': tgt, 'client': 'local',
+ 'expr_form': expr_form, 'tgt_type': tgt_type}
if param:
- accept_key_payload['arg']=param
+ accept_key_payload['arg'] = param
- login_request = requests.post(os.path.join(config['SALT_URL'],'login'),headers=headers,data=login_payload)
- request = requests.post(config['SALT_URL'],headers=headers,data=accept_key_payload,cookies=login_request.cookies)
+ login_request = requests.post(os.path.join(config['SALT_URL'],
+ 'login'),
+ headers=headers, data=login_payload)
+ request = requests.post(config['SALT_URL'], headers=headers,
+ data=accept_key_payload,
+ cookies=login_request.cookies)
return request.json()['return'][0]
@@ -40,12 +46,12 @@
if 'skipped_nodes' in config.get(testname).keys():
skipped_nodes += config.get(testname)['skipped_nodes'] or []
- if skipped_nodes:
+ if skipped_nodes != ['']:
print "\nNotice: {0} nodes will be skipped".format(skipped_nodes)
nodes = local_salt_client.cmd(
- '* and not '+list_to_target_string(skipped_nodes, 'and not'),
- 'test.ping',
- expr_form='compound')
+ '* and not ' + list_to_target_string(skipped_nodes, 'and not'),
+ 'test.ping',
+ expr_form='compound')
else:
nodes = local_salt_client.cmd('*', 'test.ping')
return nodes
@@ -76,8 +82,8 @@
if group_name not in skipped_groups:
groups.append(group_name)
else:
- if group_name+" - skipped" not in groups:
- groups.append(group_name+" - skipped")
+ if group_name + " - skipped" not in groups:
+ groups.append(group_name + " - skipped")
return groups
@@ -92,10 +98,10 @@
for param in global_config.keys():
if param in os.environ.keys():
if ',' in os.environ[param]:
- global_config[param]=[]
+ global_config[param] = []
for item in os.environ[param].split(','):
global_config[param].append(item)
else:
- global_config[param]=os.environ[param]
+ global_config[param] = os.environ[param]
return global_config