Exemplo n.º 1
0
    def runTest(self):
        #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

        # TODO: query interfaces but this is OK for now
        for i in range(1000):
            # keep long running test alive
            board.sendline()
            board.expect(prompt)
            print ("Starting connection %s" % i)
            sz, rate, ip, port = self.startSingleUDP(maxtime=single_max)
            print ("started UDP 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')
            if 0 != lan.expect([pexpect.TIMEOUT] + prompt, timeout=max_time + 5):
                lan.sendcontrol('c')
                lan.expect(prompt)
                self.check_and_clean_ips()

        self.recover()
Exemplo n.º 2
0
    def recover(self):
        board.touch()
        lan.sendcontrol('c')
        lan.expect(prompt)
        board.touch()

        print "Copying files from lan to dir = %s" % self.config.output_dir
        lan.sendline('readlink -f $HOME/%s/' % self.dir)
        lan.expect_exact('$HOME/%s/' % self.dir)
        board.touch()
        lan.expect(prompt)
        board.touch()
        fname = lan.before.replace('\n', '').replace('\r', '')
        board.touch()
        rm_r(os.path.join(self.config.output_dir, self.dir))
        scp_from(fname, lan.ipaddr, lan.username, lan.password, lan.port,
                 self.config.output_dir)

        # let board settle down
        board.expect(pexpect.TIMEOUT, timeout=30)
        board.touch()

        board.parse_stats(dict_to_log=self.logged)
        board.touch()
        self.result_message = 'JMeter: DONE, name = %s cpu usage = %s' % (
            self.shortname, self.logged['mpstat'])
Exemplo n.º 3
0
    def check_and_clean_ips(self):
        lan.sendline("echo SYNC; ps aux | grep  socat | sed -e 's/.*UDP/UDP/g' | tr '\n' ' '")
        lan.expect_exact("SYNC\r\n")
        lan.expect(prompt)
        seen_ips = re.findall('UDP4-SENDTO:([^:]*):', lan.before)

        for done_ip in set(zip(*self.all_ips)[0]) - set(seen_ips):
            self.cleanup_ip(done_ip)
            self.all_ips = [e for e in self.all_ips if e[0] != done_ip ]
Exemplo n.º 4
0
 def runTest(self):
     for sz in ["74", "128", "256", "512", "1024", "1280", "1518" ]:
         print("running %s UDP test" % sz)
         lan.sendline('netperf -H 192.168.0.1 -t UDP_STREAM -l 60 -- -m %s' % sz)
         lan.expect_exact('netperf -H 192.168.0.1 -t UDP_STREAM -l 60 -- -m %s' % sz)
         lan.expect('UDP UNIDIRECTIONAL')
         lan.expect(prompt, timeout=90)
         board.sendline()
         board.expect(prompt)
Exemplo n.º 5
0
 def runTest(self):
     for sz in ["74", "128", "256", "512", "1024", "1280", "1518"]:
         print("running %s UDP test" % sz)
         lan.sendline(
             'netperf -H 192.168.0.1 -t UDP_STREAM -l 60 -- -m %s' % sz)
         lan.expect_exact(
             'netperf -H 192.168.0.1 -t UDP_STREAM -l 60 -- -m %s' % sz)
         lan.expect('UDP UNIDIRECTIONAL')
         lan.expect(prompt, timeout=90)
         board.sendline()
         board.expect(prompt)
Exemplo n.º 6
0
    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()
Exemplo n.º 7
0
    def check_and_clean_ips(self):
        if 'TCP' in self.socat_send:
            c = 'TCP'
        else:
            c = 'UDP'
        lan.sendline(
            "echo SYNC; ps aux | grep  socat | sed -e 's/.*%s/%s/g' | tr '\n' ' '"
            % (c, c))
        lan.expect_exact("SYNC\r\n")
        lan.expect(prompt)
        seen_ips = re.findall('%s:([^:]*):' % self.socat_send, lan.before)

        if len(self.all_ips) > 0:
            ips_to_cleanup = set(zip(*self.all_ips)[0]) - set(seen_ips)
            for done_ip in ips_to_cleanup:
                self.cleanup_ip(done_ip)
                self.all_ips = [e for e in self.all_ips if e[0] != done_ip]
Exemplo n.º 8
0
    def recover(self):
        lan.sendcontrol('c')
        lan.expect(prompt)
        lan.sendline('pkill -9 -f hping3')
        lan.expect_exact('pkill -9 -f hping3')
        lan.expect(prompt)

        wan.sendcontrol('c')
        wan.expect(prompt)
        wan.sendline('pkill -9 -f nc ')
        wan.expect_exact('pkill -9 -f nc')
        wan.expect(prompt)

        board.parse_stats(dict_to_log=self.logged)

        args = (self.conn_rate, self.max_conns, self.logged['mpstat'])
        self.result_message = "hping3 udp firewall test, conn_rate = %s, max_conns = %s, cpu usage = %.2f" % args
Exemplo n.º 9
0
    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()
Exemplo n.º 10
0
    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()