示例#1
0
def crash_test():
    print color.INFO("Opening persistent TCP connection for diagnostics")
    sock_mem.connect((HOST, PORT_MEM))
    get_mem_start()

    print color.HEADER("Initial crash test")
    burst_size = BURST_SIZE * 10

    ARP_burst(burst_size, 0)
    UDP_burst(burst_size, 0)
    ICMP_flood(burst_size, 0)
    httperf(burst_size, 0)
    time.sleep(BURST_INTERVAL)
    return get_mem()
示例#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
示例#3
0
                time_wait_proc += 1
        print color.INFO(
            "There are {0} sockets in use, waiting for value to drop below {1}"
            .format(time_wait_proc, socket_limit))
        time.sleep(7)


# Add custom event-handlers
vm.on_output("Ready to start", crash_test)
vm.on_output("Ready for ARP", ARP)
vm.on_output("Ready for UDP", UDP)
vm.on_output("Ready for ICMP", ICMP)
vm.on_output("Ready for TCP", TCP)
vm.on_output("Ready to end", check_vitals)

# Boot the VM, taking a timeout as parameter
timeout = BURST_COUNT * 20

if len(sys.argv) > 1:
    timeout = int(sys.argv[1])

if len(sys.argv) > 3:
    BURST_COUNT = int(sys.argv[2])
    BURST_SIZE = int(sys.argv[3])

print color.HEADER(test_name + " initializing")
print color.INFO(
    name_tag), "Doing", BURST_COUNT, "bursts of", BURST_SIZE, "packets each"

vm.make().boot(timeout)