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'])
示例#2
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)
    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 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]
示例#5
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
    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()