Esempio n. 1
0
def check_vitals():
    print color.INFO("Checking vital signs")
    mem = get_mem()
    diff = mem - memuse_at_start
    pages = diff / PAGE_SIZE
    if diff % PAGE_SIZE != 0:
        print color.WARNING("Memory increase was not a multple of page size.")
        wait_for_tw()
        return False
    print color.INFO("Memory use at test end:"), mem, "bytes"
    print color.INFO(
        "Memory difference from test start:"
    ), memuse_at_start, "bytes (Diff:", diff, "b == ", pages, "pages)"
    sock_mem.close()
    vm.stop()
    wait_for_tw()
    return True
Esempio n. 2
0
def fire_bursts(func, sub_test_name, lead_out=3):
    name_tag = "<" + sub_test_name + ">"
    print color.HEADER(test_name + " initiating " + sub_test_name)
    membase_start = func()
    mem_base = membase_start

    # Track heap behavior
    increases = 0
    decreases = 0
    constant = 0

    for i in range(0, BURST_COUNT):
        print color.INFO(name_tag), " Run ", i + 1
        memi = func()
        if memi > mem_base:
            memincrease = memi - mem_base
            increases += 1
        elif memi == mem_base:
            memincrease = 0
            constant += 1
        else:
            memincrease = 0
            decreases += 1

        # We want to know how much each burst increases memory relative to the last burst
        mem_base = memi

        if memincrease > acceptable_increase:
            print color.WARNING(
                name_tag), "Memory increased by ", memincrease, "b, ", float(
                    memincrease) / BURST_SIZE, "pr. packet \n"
        else:
            print color.OK(name_tag), "Memory increase ", memincrease, "b \n"

        # Memory can decrease, we don't care about that
        # if memincrease > 0:
        #  mem_base += memincrease
    print color.INFO(
        name_tag
    ), "Heap behavior: ", "+", increases, ", -", decreases, ", ==", constant
    print color.INFO(name_tag), "Done. Checking for liveliness"
    if memory_increase(lead_out, membase_start) > acceptable_increase:
        print color.FAIL(sub_test_name + " failed ")
        return False
    print color.PASS(sub_test_name + " succeeded ")
    return True
Esempio n. 3
0
def UDP_burst(burst_size=BURST_SIZE, burst_interval=BURST_INTERVAL):
    global memuse_at_start
    sock = socket.socket
    # SOCK_DGRAM is the socket type to use for UDP sockets
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    sock.settimeout(sock_timeout)
    # This is a stress-test, so we don't want to spend time checking the output
    # (especially not with python)
    # We just want to make sure the VM survives.
    data = "UDP is working as it's supposed to."

    try:
        for i in range(0, burst_size):
            sock.sendto(data, (HOST, PORT_FLOOD))
    except Exception as e:
        print color.WARNING(
            "<Test.py> Python socket timed out while sending. ")
        return False
    sock.close()
    time.sleep(burst_interval)
    return get_mem()
Esempio n. 4
0
def memory_increase(lead_time, expected_memuse=memuse_at_start):
    name_tag = "<" + test_name + "::memory_increase>"
    if lead_time:
        print color.INFO(
            name_tag
        ), "Checking for memory increase after a lead time of ", lead_time, "s."
        # Give the VM a chance to free up resources before asking
        time.sleep(lead_time)

    use = get_mem()
    increase = use - expected_memuse
    percent = 0.0
    if (increase):
        percent = float(increase) / expected_memuse

    if increase > acceptable_increase:
        print color.WARNING(name_tag), "Memory increased by ", percent, "%."
        print "(", expected_memuse, "->", use, ",", increase, "b increase, but no increase expected.)"
    else:
        print color.OK(name_tag + "Memory constant, no leak detected")
    return increase