summaryrefslogtreecommitdiffstats
path: root/clover/tools/clover_validate_rr.py
diff options
context:
space:
mode:
authorStephen Wong <stephen.kf.wong@gmail.com>2018-03-12 16:41:57 -0700
committerStephen Wong <stephen.kf.wong@gmail.com>2018-03-30 19:31:15 -0700
commitcb2b1a1cc38e7b0b174a33553695805015ae382c (patch)
treebb8ca618d8f7fbddba215bbb40b0e87224277632 /clover/tools/clover_validate_rr.py
parentc43c773fc33167f46461b4fd1ae58e40d390d59e (diff)
Clover initial commit for servicemesh/route_rules,
orchestration/kube_client, and tools/clover_validate_rr Add an 'orchestration' directory. Please note that 'orchestration' does NOT mean Clover does any orchestration --- similar to how Clover doesn't by itself implement tracing or logging, orchestration is a directory for code related to Docker orchestration client --- such as k8s client kube_client utilizes the Kubernetes python client (a dependency) to perform tasks against Kubernetes API server. For this commit, it is only tested for weighted route rule verification, it does three tasks: (1) get a list of pods under a namespace --- pod dictionary now only contains pod name and label dictionary: used to match pod name with the node name in traces from OpenTracing (2) check to see if a particular pod is up in a particular namespace: used to check if Istio pods are running in istio-system namespace (3) check if a container exists in a list of pods under a namespace: used to check if application pods have istio-proxy container running route_rule directly invokes istioctl as there isn't any Istio Python client yet. Currently it reads and parses routerules from Istio, and validates if a particular trace result matches the routerules Finally, a sample tool clover_validate_rr is provided. This tool assumes a previous test has been ran (with an id with both the route-rule-under-test and corresponding traces are stored --- currently the assumption is tests were ran with redis-master running on system). The tool can be invoked: python clover_validate_rr.py -t <test-id> -s <service name> where test-id is the ID of the test (most likely uuid) and service name is the name of the service running in the Kubernetes cluster upon which test traces should be fetched against Change-Id: Ic8ab6efc23c71ac4643bee796ef986a86f6fc7dd Signed-off-by: Stephen Wong <stephen.kf.wong@gmail.com>
Diffstat (limited to 'clover/tools/clover_validate_rr.py')
-rw-r--r--clover/tools/clover_validate_rr.py56
1 files changed, 56 insertions, 0 deletions
diff --git a/clover/tools/clover_validate_rr.py b/clover/tools/clover_validate_rr.py
new file mode 100644
index 0000000..ff1f8b4
--- /dev/null
+++ b/clover/tools/clover_validate_rr.py
@@ -0,0 +1,56 @@
+#!/usr/bin/env python
+
+# 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
+
+import getopt
+import sys
+
+sys.path.insert(0, '..')
+
+from orchestration import kube_client
+import servicemesh.route_rules as rr
+from tracing.tracing import Tracing
+from validate_rr import ValidateWRR
+
+def main(argv):
+ service_name = None
+ test_id = None
+ help_str = 'clover_validate_rr.py -t <test-id> -s <service name>'
+ try:
+ opts, args = getopt.getopt(argv,"hs:t:",["service-name", "test-id"])
+ except getopt.GetoptError:
+ print help_str
+ sys.exit(2)
+ for opt, arg in opts:
+ if opt == '-h':
+ print help_str
+ sys.exit()
+ elif opt in ("-t", "--test-id"):
+ test_id = str(arg)
+ elif opt in ("-s", "--service-name"):
+ service_name = str(arg)
+
+ if not service_name or not test_id:
+ print help_str
+ sys.exit(3)
+
+ validate_wrr = ValidateWRR(test_id)
+
+ istio_pods = ['istio-ingress', 'istio-mixer', 'istio-pilot']
+ jaeger_pods = ['jaeger-deployment']
+
+ if not validate_wrr.check_pods_up(istio_pods + jaeger_pods,
+ 'istio-system'):
+ sys.exit(4)
+
+ ret, errors = validate_wrr.validate(service_name)
+ for err in errors:
+ print err
+
+if __name__ == "__main__":
+ main(sys.argv[1:])