示例#1
0
        def run():
            for cmd in comp.tc_dropper_reset(nodes["comp5"].links["comp1"]['ifname']):
                print nodes["comp5"].name, "should be comp5"
                nodes["comp5"].run_cmd(cmd)
            for cmd in comp.tc_dropper_reset(nodes["comp1"].links["comp5"]['ifname']):
                nodes["comp1"].run_cmd(cmd)
                print nodes["comp1"].name, "should be comp1"
            # It's safer to restart each time actually...
            comp.run_cmd_on_server(nodes, 'pkill picoquicdemo')
            comp.run_cmd_on_server(nodes, ["sh", "-c", "'cd ~/picoquic; nohup ./picoquicdemo {} {} -p 4443 2>&1 > /tmp/log_server.log'".format(server_logs, plugins)], daemon=True)
            server_ip = SERVER_IP
            # Empty the buffers and let the server start quietly
            time.sleep(0.2)

            client_cmd = 'timeout 120 ~/picoquic/picoquicdemo -4 -G {} {} -l /dev/null {} 4443 2>&1 > /tmp/log_client.log'.format(size, plugins, server_ip)
            err = comp.run_cmd_on_client(nodes, client_cmd)

            if err != 0:
                print("client returned err %d" % err)
                return 0

            # Get the file to access it
            comp.scp_file_from_client(nodes, '/tmp/log_client.log', 'log_client.log')
            log_client = open('log_client.log')
            lines = log_client.readlines()
            elapsed_ms_str = lines[-2].split()[0]
            if (elapsed_ms_str.startswith('-') or "Client exit with code = 0" not in lines[-1]):
                print lines[-1]
                print "Error for this run..."
                # Relaunch the server
                return 0

            print "elapsed: %s milliseconds for %s" % (elapsed_ms_str, test_name)
            return float(elapsed_ms_str)
示例#2
0
        def run():
            start_time = time.time()
            additional_curl_params = ''
            if test_name == 'sp_vpn':
                additional_curl_params = '--interface {}'.format('128.0.0.2')
            err = comp.run_cmd_on_client(nodes, 'curl {}:8080/random_{} -s --connect-timeout 5 --output /dev/null -w "%{{time_total}}" {} > /tmp/curl.log'.format(
                '128.0.0.1' if test_name == 'sp_vpn' else server_ip, size, additional_curl_params)
            )

            elapsed_ms = (time.time() - start_time) * 1000

            if err != 0:
                print("client returned err %d" % err)
                return 0

                # Get the file to access it
            comp.scp_file_from_client(nodes, '/tmp/curl.log', 'curl.log')
            with open('curl.log') as f:
                lines = f.readlines()
            elapsed_ms = float(lines[-1]) * 1000
            print "elapsed: %f milliseconds for %s" % (elapsed_ms, test_name)
            return elapsed_ms
示例#3
0
        def run():
            # It's safer to restart each time actually...
            comp.run_cmd_on_server(nodes, 'pkill picoquicdemo')
            # Get rid of the variability of processes
            comp.run_cmd_on_server(nodes, ["sh", "-c", "'cd ~/picoquic; nohup nice --20 ./picoquicdemo {} {} -p 4443 2>&1 > /tmp/log_server.log'".format(server_logs, plugins)], daemon=True)
            server_ip = '42.2.1.1'

            # Empty the buffers and let the server start quietly
            time.sleep(0.2)

            # Get rid of the variability of processes
            client_cmd = 'timeout 40 nice --20 ~/picoquic/picoquicdemo -4 -G {} {} -l /dev/null {} 4443 2>&1 > /tmp/log_client.log'.format(size, plugins, server_ip)
            err = comp.run_cmd_on_client(nodes, client_cmd)

            if err != 0:
                print("client returned err %d" % err)
                return 0

            # Get the file to access it
            comp.scp_file_from_client(nodes, '/tmp/log_client.log', 'log_client.log')
            log_client = open('log_client.log')
            lines = log_client.readlines()
            elapsed_ms_str = lines[-2].split()[0]
            if elapsed_ms_str.startswith('-') or len([1 for line in lines if "Received file /doc-{}.html, after {} bytes, closing stream 4".format(size, size) in line]) == 0:
                print lines[-1]
                print "Error for this run..."
                # Relaunch the server
                return 0

            elf_us = 0
            plugin_us = 0
            for line in lines:
                if "ELF_load" in line:
                    elf_us += int(line.split()[-1])
                elif "Plugin_load" in line:
                    plugin_us += int(line.split()[-1])

            print "elapsed: %s milliseconds for %s, elf_us %d, plugin_us %d" % (elapsed_ms_str, test_name, elf_us, plugin_us)
            return float(elapsed_ms_str), elf_us, plugin_us