예제 #1
0
def test_bucket_single_test():
    """ Main function for a single test case. """
    args = parse_args()
    test_duration_sec = args.test_duration_sec
    tshark_slack_sec  = args.tshark_slack_sec
    adjust_path = get_adjust_path(args)
    mn_cleanup()

    """ Controller """
    print "Setting up controller..."
    c_params = {'query': args.query, 'fwding': args.fwding,
                'only_count_results': 'true'}
    c_name   = args.ctlr
    c_outfile = adjust_path("pyretic-stdout.txt")
    c_errfile = adjust_path("pyretic-stderr.txt")
    pypath = "/home/mininet/pyretic:/home/mininet/mininet:/home/mininet/pox"
    (ctlr, c_out, c_err) = pyretic_controller(c_name, c_params, c_outfile,
                                              c_errfile, pypath)

    """ Network """
    print "Setting up mininet..."
    topo_args = {'class_name': args.topo_name, 'class_args': args.topo_args}
    (net, hosts, switches) = get_mininet(topo_args, args.listen_port)

    """ Wait for switches to be prepped """
    print "Waiting to install switch rules..."
    wait_switch_rules_installed(switches)

    """ Capture """
    print "Starting tshark capture..."
    t_outfile = adjust_path("tshark-stdout.txt")
    t_errfile = adjust_path("tshark-stderr.txt")
    ints_list = globals()[args.interface_map]()
    capture_dir = args.capture_dir
    (tshark, t_out, t_err) = capture_packets(t_outfile, t_errfile, ints_list, capture_dir)
    time.sleep(tshark_slack_sec)

    """ Workload """
    print "Starting workload..."
    workload(net, hosts)
    time.sleep(test_duration_sec)

    """ Finish up """
    print "Actual run done. Cleaning up..."
    kill_process(ctlr, "controller")
    kill_process(tshark, "tshark")
    close_fds([c_out, c_err], "controller")
    close_fds([t_out, t_err], "tshark")
    net.stop()

    """ Verify results """
    print "Verifying correctness..."
    tshark_filter_params = {'filter_funs': args.tshark_filter_funs,
                            'test_nums': args.test_nums }
    tshark_counts = get_tshark_counts(t_outfile, tshark_filter_params, c_name)
    buckets_counts = ctlr_counts(c_outfile, c_name)
    success_file = adjust_path(args.success_file)
    write_passfail_info(success_file, tshark_counts, buckets_counts, c_name)
예제 #2
0
def query_test():
    """ A simpler, cleaner, end to end testing script. """
    args = parse_args()
    rfolder = args.results_folder
    create_folder_if_not_exists(rfolder)
    pyopts = args.pyopts
    test = args.test
    test_module = get_test_module(test)
    polopts = get_testwise_params(args.polopts)
    polopts["test"] = test
    polopts["pyopts"] = pyopts

    mn_cleanup()
    (ctlr, c_out, c_err) = get_controller(rfolder, pyopts, test, polopts)
    test_module.init_setup(**polopts)
    (net, hosts, switches) = get_mininet(test_module, polopts)
    (rules_installed) = wait_switch_rules_installed(switches, INSTALL_TIMEOUT_SEC)
    # net.pingAll()
    (ovhp, ovhf) = get_tshark_ovhead(test_module, polopts, rfolder)
    time.sleep(TSHARK_SLACK_SEC)
    (optps, optfs) = get_tshark_optimal(test_module, polopts, rfolder)
    # optps, optfs = [], []
    time.sleep(TSHARK_SLACK_SEC)
    run_iperf_test(test_module, polopts, rfolder, net)
    time.sleep(TEST_DURATION_SEC + 2 * TSHARK_SLACK_SEC)
    kill_processes([ctlr, ovhp] + optps)
    close_fds([c_out, c_err, ovhf] + optfs)

    net.stop()

    print "Done!"
예제 #3
0
파일: mininet_e2e.py 프로젝트: faramirs/wot
def query_test():
    """ A simpler, cleaner, end to end testing script. """
    args = parse_args()
    rfolder = args.results_folder
    create_folder_if_not_exists(rfolder)
    pyopts = args.pyopts
    test = args.test
    test_module = get_test_module(test)
    polopts = get_testwise_params(args.polopts)
    polopts['test'] = test
    polopts['pyopts'] = pyopts

    mn_cleanup()
    (ctlr, c_out, c_err) = get_controller(rfolder, pyopts, test, polopts)
    test_module.init_setup(**polopts)
    (net, hosts, switches) = get_mininet(test_module, polopts)
    (rules_installed) = wait_switch_rules_installed(switches,
                                                    INSTALL_TIMEOUT_SEC)
    # net.pingAll()
    (ovhp, ovhf) = get_tshark_ovhead(test_module, polopts, rfolder)
    time.sleep(TSHARK_SLACK_SEC)
    (optps, optfs) = get_tshark_optimal(test_module, polopts, rfolder)
    # optps, optfs = [], []
    time.sleep(TSHARK_SLACK_SEC)
    run_iperf_test(test_module, polopts, rfolder, net)
    time.sleep(TEST_DURATION_SEC + 2 * TSHARK_SLACK_SEC)
    kill_processes([ctlr, ovhp] + optps)
    close_fds([c_out, c_err, ovhf] + optfs)

    net.stop()

    print "Done!"
예제 #4
0
def test_bucket_single_test():
    """ Main function for a single test case. """
    args = parse_args()
    test_duration_sec = args.test_duration_sec
    tshark_slack_sec = args.tshark_slack_sec
    adjust_path = get_adjust_path(args.results_folder)
    mn_cleanup()

    """ Controller """
    print "Setting up controller..."
    c_params = {"query": args.query, "fwding": args.fwding, "only_count_results": "true"}
    pyopts = args.pyopts
    c_name = args.ctlr
    c_outfile = adjust_path("pyretic-stdout.txt")
    c_errfile = adjust_path("pyretic-stderr.txt")
    usern = subprocess.call("./pyretic/tests/get_user.sh")
    pypath = "/home/%s/pyretic:/home/%s/mininet:/home/%s/pox" % ((usern,) * 3)
    (ctlr, c_out, c_err) = pyretic_controller(c_name, c_params, c_outfile, c_errfile, pypath, pyopts)

    """ Network """
    print "Setting up mininet..."
    topo_args = {"class_name": args.topo_name, "class_args": args.topo_args}
    (net, hosts, switches) = get_mininet(topo_args, args.listen_port)

    """ Wait for switches to be prepped """
    print "Waiting to install switch rules..."
    rules_installed = wait_switch_rules_installed(switches, args.install_timeout_sec)

    """ Capture """
    print "Starting tshark capture..."
    t_outfile = adjust_path("tshark-stdout.txt")
    t_errfile = adjust_path("tshark-stderr.txt")
    ints_list = globals()[args.interface_map]()
    capture_dir = args.capture_dir
    (tshark, t_out, t_err) = capture_packets(t_outfile, t_errfile, ints_list, capture_dir)
    print "Waiting out tshark slack", tshark_slack_sec
    time.sleep(tshark_slack_sec)

    """ Workload """
    print "Starting workload..."
    drop_pc = workload(net, hosts)
    time.sleep(test_duration_sec)

    """ Finish up """
    print "Waiting out tshark slack"
    time.sleep(tshark_slack_sec)
    print "Actual run done. Cleaning up..."
    kill_process(ctlr, "controller")
    kill_process(tshark, "tshark")
    close_fds([c_out, c_err], "controller")
    close_fds([t_out, t_err], "tshark")
    net.stop()
    # time.sleep(tshark_slack_sec)

    """ Verify results """
    print "Verifying correctness..."
    tshark_filter_params = {"filter_funs": args.tshark_filter_funs, "test_nums": args.test_nums}
    tshark_counts = get_tshark_counts(t_outfile, tshark_filter_params, c_name)
    buckets_counts = ctlr_counts(c_outfile, c_name)
    success_file = adjust_path(args.success_file)
    write_passfail_info(
        success_file, tshark_counts, buckets_counts, drop_pc, c_name, rules_installed, c_outfile, c_errfile
    )
예제 #5
0
def test_bucket_single_test():
    """ Main function for a single test case. """
    args = parse_args()
    test_duration_sec = args.test_duration_sec
    tshark_slack_sec = args.tshark_slack_sec
    adjust_path = get_adjust_path(args.results_folder)
    mn_cleanup()
    """ Controller """
    print "Setting up controller..."
    c_params = {
        'query': args.query,
        'fwding': args.fwding,
        'only_count_results': 'true'
    }
    pyopts = args.pyopts
    c_name = args.ctlr
    c_outfile = adjust_path("pyretic-stdout.txt")
    c_errfile = adjust_path("pyretic-stderr.txt")
    usern = subprocess.call('./pyretic/tests/get_user.sh')
    pypath = "/home/%s/pyretic:/home/%s/mininet:/home/%s/pox" % ((usern, ) * 3)
    (ctlr, c_out, c_err) = pyretic_controller(c_name, c_params, c_outfile,
                                              c_errfile, pypath, pyopts)
    """ Network """
    print "Setting up mininet..."
    topo_args = {'class_name': args.topo_name, 'class_args': args.topo_args}
    (net, hosts, switches) = get_mininet(topo_args, args.listen_port)
    """ Wait for switches to be prepped """
    print "Waiting to install switch rules..."
    rules_installed = wait_switch_rules_installed(switches,
                                                  args.install_timeout_sec)
    """ Capture """
    print "Starting tshark capture..."
    t_outfile = adjust_path("tshark-stdout.txt")
    t_errfile = adjust_path("tshark-stderr.txt")
    ints_list = globals()[args.interface_map]()
    capture_dir = args.capture_dir
    (tshark, t_out, t_err) = capture_packets(t_outfile, t_errfile, ints_list,
                                             capture_dir)
    print "Waiting out tshark slack", tshark_slack_sec
    time.sleep(tshark_slack_sec)
    """ Workload """
    print "Starting workload..."
    drop_pc = workload(net, hosts)
    time.sleep(test_duration_sec)
    """ Finish up """
    print "Waiting out tshark slack"
    time.sleep(tshark_slack_sec)
    print "Actual run done. Cleaning up..."
    kill_process(ctlr, "controller")
    kill_process(tshark, "tshark")
    close_fds([c_out, c_err], "controller")
    close_fds([t_out, t_err], "tshark")
    net.stop()
    # time.sleep(tshark_slack_sec)
    """ Verify results """
    print "Verifying correctness..."
    tshark_filter_params = {
        'filter_funs': args.tshark_filter_funs,
        'test_nums': args.test_nums
    }
    tshark_counts = get_tshark_counts(t_outfile, tshark_filter_params, c_name)
    buckets_counts = ctlr_counts(c_outfile, c_name)
    success_file = adjust_path(args.success_file)
    write_passfail_info(success_file, tshark_counts, buckets_counts, drop_pc,
                        c_name, rules_installed, c_outfile, c_errfile)