summaryrefslogtreecommitdiffstats
path: root/clover/tracing/validate.py
diff options
context:
space:
mode:
authorEddie Arrage <eddie.arrage@huawei.com>2018-03-15 10:08:30 -0700
committerEddie Arrage <eddie.arrage@huawei.com>2018-03-29 16:49:25 -0700
commit45ff7042f3909c32d6282e3bc31be650ba1a41c7 (patch)
tree0573cda1526a9f6e9df3d44400fd0e6cfc14d6c7 /clover/tracing/validate.py
parent9f3d87d798cf04c243e82d284a7dc4f7b3ec5c1a (diff)
Initial commit for tracing
- Uses REST interface to obtain traces for services from Jaeger - Discover services availabe in tracing - Works only with Jaeger at the moment (not zipkin) - Optional Redis interface added to store traces per test - Install doc and validation script added for Jaeger - Renamed doc to docs Change-Id: I420137c818df290ecd40aa8d318c6961c511a947 Signed-off-by: Eddie Arrage <eddie.arrage@huawei.com>
Diffstat (limited to 'clover/tracing/validate.py')
-rw-r--r--clover/tracing/validate.py66
1 files changed, 66 insertions, 0 deletions
diff --git a/clover/tracing/validate.py b/clover/tracing/validate.py
new file mode 100644
index 0000000..eed6f9a
--- /dev/null
+++ b/clover/tracing/validate.py
@@ -0,0 +1,66 @@
+# Copyright (c) Authors of Clover
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+
+from tracing import Tracing
+from kubernetes import client, config
+
+
+JAEGER_IP = "localhost"
+# JAEGER_IP = "1.1.1.1"
+JAEGER_PORT = "30888"
+JAEGER_DEPLOYMENT = "jaeger-deployment"
+ISTIO_NAMESPACE = "istio-system"
+ISTIO_SERVICES = ["istio-ingress", "istio-mixer"]
+
+
+def validateDeploy():
+ config.load_kube_config()
+ v1 = client.AppsV1Api()
+
+ deployments = []
+ namespaces = []
+ validate = False
+ ret = v1.list_deployment_for_all_namespaces(watch=False)
+ for i in ret.items:
+ deployments.append(i.metadata.name)
+ namespaces.append(i.metadata.namespace)
+ if JAEGER_DEPLOYMENT in deployments:
+ d_index = deployments.index(JAEGER_DEPLOYMENT)
+ if ISTIO_NAMESPACE in namespaces[d_index]:
+ print("Deployment: {} present in {} namespace".format(
+ JAEGER_DEPLOYMENT, ISTIO_NAMESPACE))
+ validate = True
+ return validate
+
+# Services in Jaeger will only be present when traffic passes through Istio
+# Requires a deployment in Istio service mesh with some traffic targeting nodes
+def validateServices():
+ t = Tracing(JAEGER_IP, JAEGER_PORT)
+ services = t.getServices()
+ validate = True
+ if services:
+ for s in ISTIO_SERVICES:
+ if s in services:
+ print("Service in tracing: {} present".format(s))
+ else:
+ validate = False
+ else:
+ validate = False
+ return validate
+
+
+def main():
+ if validateDeploy() and validateServices():
+ print"Jaeger tracing validation has passed"
+ return True
+ else:
+ print"Jaeger tracing validation has failed"
+ return False
+
+
+if __name__ == '__main__':
+ main()