def runTest(self): install_lighttpd(wan) wan.sendline('/etc/init.d/lighttpd start') wan.expect(prompt) # Wan device: Create small file in web dir fname = 'small.txt' cmd = '\nhead -c 10000 /dev/urandom > /var/www/%s' % fname wan.sendline(cmd) wan.expect(prompt) # Lan Device: download small file a lot # TODO: this is actually a 404 for lighthttpd config issues? url = 'http://%s/%s' % (wan.gw, fname) # Start CPU monitor board.collect_stats(stats=['mpstat']) # Lan Device: download small file a lot lan.sendline('\nab -dn %s -c %s %s' % (self.num_conn, self.concurrency, url)) lan.expect('Benchmarking', timeout=5) timeout = 0.05 * self.num_conn if 0 != lan.expect([ 'Requests per second:\s+(\d+)', 'apr_socket_recv: Connection reset by peer' ], timeout=timeout): raise Exception("ab failed to run") self.reqs_per_sec = int(lan.match.group(1)) lan.expect(prompt) self.recover()
def runTest(self): self.dir = 'jmeter_%s' % self.shortname install_jmeter(lan) lan.sendline('rm -rf $HOME/%s' % self.dir) lan.expect(prompt) lan.sendline('mkdir -p $HOME/%s/wd' % self.dir) lan.expect(prompt) lan.sendline('mkdir -p $HOME/%s/results' % self.dir) lan.expect(prompt) if self.jmx.startswith('http'): lan.sendline('curl %s > $HOME/%s/test.jmx' % (self.jmx, self.dir)) lan.expect(prompt) else: print("Copying %s to lan device" % self.jmx) lan.sendline('echo $HOME') lan.expect_exact('echo $HOME') lan.expect(prompt) lan.copy_file_to_server(self.jmx, dst=lan.before.strip() + '/%s/test.jmx' % self.dir) board.collect_stats(stats=['mpstat']) lan.sendline('cd $HOME/%s/wd' % self.dir) lan.expect(prompt) lan.sendline( 'JVM_ARGS="-Xms4096m -Xmx8192m" jmeter -n -t ../test.jmx -l foo.log -e -o $HOME/%s/results' % self.dir) lan.expect_exact('$HOME/%s/results' % self.dir) for i in range(self.default_time): if 0 != lan.expect([pexpect.TIMEOUT] + prompt, timeout=5): break conns = board.get_nf_conntrack_conn_count() board.get_proc_vmstat() board.touch() if i > 100 and conns < 20: raise Exception("jmeter is dead/stuck/broke, aborting the run") if i == 599: raise Exception("jmeter did not have enough time to complete") lan.sendline('cd -') lan.expect(prompt) lan.sendline('rm test.jmx') lan.expect(prompt) self.recover()
def runTest(self): wan_ip = wan.get_interface_ipaddr(wan.iface_dut) wan.sendline('iperf -s -l 1M -w 1M') wan.expect('Server listening on ') board.collect_stats(stats=['mpstat']) time = 10 cmd = "iperf -R -c %s -P %s -t 10 -N -w 1M -l 1M | grep SUM" # prime the pipes... lan.sendline(cmd % (wan_ip, 4)) lan.expect(prompt) prev_con = 0 prev_failed = 0 for con_conn in range(32, 513, 16): try: tstart = datetime.now() lan.sendline(cmd % (wan_ip, con_conn)) failed_cons = 0 while (datetime.now() - tstart).seconds < (time * 2): timeout = (time * 2) - (datetime.now() - tstart).seconds if 0 == lan.expect( ['write failed: Connection reset by peer'] + prompt, timeout=timeout): failed_cons += 1 else: break print_bold("For iperf with %s connections, %s failed...." % (con_conn, failed_cons)) lan.expect('.*') wan.expect('.*') board.touch() prev_conn = con_conn prev_failed = failed_cons if con_conn == 512: self.result_message = "iPerf Concurrent passed 512 connections (failed conns = %s)" % failed_cons except: self.result_message = "iPerf Concurrent Connections failed entirely at %s (failed conns = %s)" % ( prev_conn, prev_failed) break print(self.result_message) self.recover()
def runTest(self): installers.install_iperf3(wan) installers.install_iperf3(self.client) wan.sendline('iperf3 -s -p %s' % self.server_port) wan.expect( '-----------------------------------------------------------') wan.expect( '-----------------------------------------------------------') if self.target_ip == None: self.target_ip = wan.gw board.collect_stats(stats=['mpstat']) self.client.sendline( 'iperf3 %s -c %s -P5 -t %s -i 0 -p %s' % (self.opts, self.target_ip, self.time, self.server_port)) self.client.expect(prompt, timeout=self.time + 10) sender = re.findall('SUM.*Bytes\s*(.*/sec).*sender', self.client.before)[-1] if 'Mbits' in sender: s_rate = float(sender.split()[0]) elif 'Kbits' in sender: s_rate = float(sender.split()[0]) / 1024 elif 'Gbits' in sender: s_rate = float(sender.split()[0]) * 1024 else: raise Exception("Unknown rate in sender results") recv = re.findall('SUM.*Bytes\s*(.*/sec).*receiver', self.client.before)[-1] if 'Mbits' in recv: r_rate = float(recv.split()[0]) elif 'Kbits' in recv: r_rate = float(recv.split()[0]) / 1024 elif 'Gbits' in recv: r_rate = float(recv.split()[0]) * 1024 else: raise Exception("Unknown rate in recv results") self.logged['s_rate'] = s_rate self.logged['r_rate'] = r_rate self.recovery()
def runTest(self): install_jmeter(lan) if self.jmx.startswith('http'): lan.sendline('curl %s > test.jmx' % self.jmx) lan.expect(prompt) else: print("Copying %s to lan device" % self.jmx) lan.copy_file_to_server(self.jmx, dst='/root/test.jmx') lan.sendline('rm -rf output *.log') lan.expect(prompt) lan.sendline('mkdir -p output') lan.expect(prompt) board.collect_stats(stats=['mpstat']) lan.sendline( 'JVM_ARGS="-Xms4096m -Xmx8192m" jmeter -n -t test.jmx -l foo.log -e -o output' ) lan.expect_exact('jmeter -n -t test.jmx -l foo.log -e -o output') for i in range(600): if 0 != lan.expect([pexpect.TIMEOUT] + prompt, timeout=5): break conns = board.get_nf_conntrack_conn_count() board.get_proc_vmstat() board.touch() if i > 100 and conns < 20: raise Exception("jmeter is dead/stuck/broke, aborting the run") if i == 599: raise Exception("jmeter did not have enough time to complete") #lan.sendline('rm -rf output') #lan.expect(prompt) lan.sendline('rm test.jmx') lan.expect(prompt) self.recover()
def runTest(self): random.seed(99) for d in [wan, lan]: d.sendline( 'apt-get update && apt-get -o Dpkg::Options::="--force-confnew" -y install socat pv' ) d.expect(prompt) max_time = 0 single_max = 45 board.collect_stats(stats=['mpstat']) # TODO: query interfaces but this is OK for now for i in range(self.conns): board.get_nf_conntrack_conn_count() board.touch() print("Starting connection %s" % i) sz, rate, ip, port = self.startSingleFlow(maxtime=single_max) print("started flow to %s:%s sz = %s, rate = %sk" % (ip, port, sz, rate)) max_time = max(max_time, sz / (rate * 1024)) self.check_and_clean_ips() print("waiting max time of %ss" % max_time) start = time.time() while time.time() - start < max_time + 5: lan.sendline('wait') lan.expect_exact('wait') lan.expect([pexpect.TIMEOUT] + prompt, timeout=5) lan.sendcontrol('c') lan.expect(prompt) self.check_and_clean_ips() board.get_nf_conntrack_conn_count() board.touch() self.recover()
def runTest(self): install_hping3(lan) wan_ip = wan.get_interface_ipaddr(wan.iface_dut) wan.sendline('nc -lvu %s 565' % wan_ip) wan.expect_exact('nc -lvu %s 565' % wan_ip) board.collect_stats(stats=['mpstat']) # dest ip and port are fixed, random src port, fixed src ip, 100 us between lan.sendline('hping3 -2 -c %s -d 120 -S -w 64 -p 445 -i %s %s' % (self.conns, self.conn_rate, wan_ip)) lan.expect('HPING') self.max_conns = 0 for not_used in range(10): self.max_conns = max(self.max_conns, board.get_nf_conntrack_conn_count()) board.get_proc_vmstat() lan.expect(pexpect.TIMEOUT, timeout=3) board.expect(pexpect.TIMEOUT, timeout=3) board.touch() self.recover()