parser.add_argument("--cluster", type=str, help="Which cluster is under testing.", default="shanghai") parser.add_argument("--batchsize", type=int, help="parallel degree.", default=6) parser.add_argument("--namespace", type=str, help="namespace used for the test", default="health-check") args = parser.parse_args() cluster = args.cluster switch_cluster(cluster) cluster_configs = { "shanghai": [ "~/.kube/config-shanghai-1", "~/.kube/config-shanghai-2", "~/.kube/config-shanghai-3" ], "yancheng": [ "~/.kube/config-yancheng-1", "~/.kube/config-yancheng-2", "~/.kube/config-yancheng-3" ] } batchsize = args.batchsize uid = datetime.datetime.now().strftime("-%Y-%m-%d-%H-%M-%S") # uid = "-2017-08-23-16-27-17" namespace = args.namespace
NOT_FOUND, register_cluster, switch_cluster, cleanup_pods, cleanup_services, ) from k8sclient.Components import PodBuilder, ServicePort, ServiceBuilder import re import time import sys register_cluster("yancheng", "~/.kube/config-yancheng") register_cluster("shanghai", "~/.kube/config-shanghai") if len(sys.argv) > 1: switch_cluster(sys.argv[1]) image = "ihub.helium.io:30100/library/alpine-iperf" server_args = "iperf -f M -i 1 -m -s" client_args = r"iperf -f M -t 10 -i 1 -c %s" namespace = "k8sft" nodes = sorted(list_ready_nodes()) server_port = ServicePort("serverport", 5001, 5001) global_server_name = "iperf-server" glimit = {'cpu': '0', 'memory': '8Gi'} grequest = {'cpu': '0', 'memory': '0'} server_service = ServiceBuilder(global_server_name, namespace).add_port(server_port) reports = {} report_css = """<style> table, th, td {
parser = argparse.ArgumentParser() parser.add_argument("--clusterconfig", type=str, help="Which cluster is under testing.") parser.add_argument( "--namespace", type=str, help="The namespace under which pods/services would be checked.") parser.add_argument("--node", type=str, help="The node where the test would be originated.") parser.add_argument("--uid", type=str, help="UID for this test session.") args = parser.parse_args() register_cluster("target", args.clusterconfig) switch_cluster("target") print "Test %s, using config: %s" % (args.node, args.clusterconfig) SUCCESS_MARK = "CHECK_PASS" def _check_pod_running(n): node_mark = "-".join(n.split(".")) pod_1 = ("pod-%s-%d" % (node_mark, 0)) + args.uid pod_2 = ("pod-%s-%d" % (node_mark, 1)) + args.uid return is_pod_running(args.namespace, pod_1) and is_pod_running( args.namespace, pod_2) nodes = list_ready_nodes() target_nodes = [n for n in nodes if _check_pod_running(n)] if args.node not in target_nodes: