Ejemplo n.º 1
0
def test_time(nr=0):
    total = node_count * service_per_pod * (nr+1)
    testnodes = [
        # "10.19.137.140",
        # "10.19.137.148",
        "10.19.137.148",
        # "10.19.140.8",
    ]
    ipvsnodes = [
        "10.19.137.148",
    ]
    for n in testnodes:
        pod_name = "memcached-%d-%s" % (nr, "-".join(n.split(".")), )
        o = pod_exec(namespace, pod_name, ["bash", "-c",
"time for c in {1..10}; do for i in {1..%d}; do echo > /dev/tcp/service-memcached-$i/11211; done; done" % (total-1)],
                     timeout=600)
        for l in o.split("\n"):
            ll = l.strip()
            if not ll:
                continue
            if "real" in ll or "user" in ll or "sys" in ll:
                continue
            print ll
        r = {"node": n, "service_count": total}
        if n in ipvsnodes:
            r['kube-proxy'] = "ipvs"
        else:
            r['kube-proxy'] = "iptables"
        for m in pattern.findall(o):
            r[m[0]+"_time"] = int(m[1]) * 60 + float(m[2])
        print json.dumps(r), ","
Ejemplo n.º 2
0
def _check_service(pod, service, timeout):
    s = time.time()
    o = pod_exec(namespace, pod, ["/opt/check.sh", service], timeout=timeout)
    if o.find(SUCCESS_MARK) == -1:
        print "Fail to check %s on %s, error message: [%s]. it took %s" % (
            service, pod, o, str(time.time() - s))
        return False
    return True
Ejemplo n.º 3
0
def _check_ping(pod, ip):
    o = pod_exec(namespace,
                 pod, ["bash", "-c", "ping %s -c 2 -w 5" % ip],
                 timeout=60)
    m = re.search("(\d+) packets received", o)
    if not m:
        return False
    if int(m.group(1)) == 0:
        return False
    return True
Ejemplo n.º 4
0
def _check_service(pod, service, timeout):
    o = pod_exec(namespace, pod, ["/opt/check.sh", service], timeout=timeout)
    if o.find(SUCCESS_MARK) == -1:
        return False
    return True
Ejemplo n.º 5
0
def _check(pod, server, port):
    return pod_exec(namespace, pod, ["/opt/check2.sh", str(server), str(port)])