Update error messages in sanity tests
Update error messages throughout sanity tests
to use the same (or similar) format of error message.
Change-Id: I4db0517a5b264151ddaa6ea2c2a04d37e139944e
Related-PROD: #PROD-32415
diff --git a/test_set/cvp-sanity/tests/test_k8s.py b/test_set/cvp-sanity/tests/test_k8s.py
index 312d162..cd2fbfd 100644
--- a/test_set/cvp-sanity/tests/test_k8s.py
+++ b/test_set/cvp-sanity/tests/test_k8s.py
@@ -22,9 +22,8 @@
if 'Healthy' not in line:
errors.append(line)
break
- assert not errors, 'k8s is not healthy: {}'.format(json.dumps(
- errors,
- indent=4))
+ assert not errors, 'k8s is not healthy:\n{}'.format(
+ json.dumps(errors, indent=4))
def test_k8s_get_nodes_status(local_salt_client):
@@ -45,9 +44,8 @@
if 'Ready' != line.split()[1]:
errors.append(line)
break
- assert not errors, 'k8s is not healthy: {}'.format(json.dumps(
- errors,
- indent=4))
+ assert not errors, 'k8s is not healthy:\n{}'.format(
+ json.dumps(errors, indent=4))
def test_k8s_get_calico_status(local_salt_client):
@@ -67,9 +65,8 @@
else:
if 'up' not in line or 'Established' not in line:
errors.append(line)
- assert not errors, 'Calico node status is not good: {}'.format(json.dumps(
- errors,
- indent=4))
+ assert not errors, 'Calico node status is not good:\n{}'.format(
+ json.dumps(errors, indent=4))
def test_k8s_cluster_status(local_salt_client):
@@ -89,9 +86,8 @@
if 'is running' not in line:
errors.append(line)
break
- assert not errors, 'k8s cluster info is not good: {}'.format(json.dumps(
- errors,
- indent=4))
+ assert not errors, 'k8s cluster info is not good:\n{}'.format(
+ json.dumps(errors, indent=4))
def test_k8s_kubelet_status(local_salt_client):
@@ -107,8 +103,8 @@
for node in result:
if not result[node]:
errors.append(node)
- assert not errors, 'Kublete is not running on these nodes: {}'.format(
- errors)
+ assert not errors, 'Kublete is not running on the nodes:\n{}'.format(
+ errors)
def test_k8s_check_system_pods_status(local_salt_client):
@@ -129,9 +125,8 @@
if 'Running' not in line:
errors.append(line)
break
- assert not errors, 'Some system pods are not running: {}'.format(json.dumps(
- errors,
- indent=4))
+ assert not errors, 'Some system pods are not running:\n{}'.format(
+ json.dumps(errors, indent=4))
def test_check_k8s_image_availability(local_salt_client):
@@ -172,8 +167,10 @@
tgt='etcd:server',
param='kubernetes:common:addons:dashboard:public_ip')
- assert external_ip, "Kubernetes dashboard public ip is not found in pillars"
- assert external_ip.__len__() > 0, "Kubernetes dashboard is enabled but not defined in pillars"
+ assert external_ip, (
+ "Kubernetes dashboard public ip is not found in pillars")
+ assert external_ip.__len__() > 0, (
+ "Kubernetes dashboard is enabled but not defined in pillars")
# dashboard port 8443 is hardcoded in kubernetes formula
url = "https://{}:8443".format(external_ip)
check = local_salt_client.cmd(
@@ -181,6 +178,7 @@
param='curl {} 2>&1 | grep kubernetesDashboard'.format(url),
expr_form='pillar'
)
- assert len(check.values()[0]) != 0, \
- 'Kubernetes dashboard is not reachable on {} ' \
- 'from ctl nodes'.format(url)
+ assert len(check.values()[0]) != 0, (
+ 'Kubernetes dashboard is not reachable on {} from '
+ 'ctl nodes'.format(url)
+ )