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)

        maxtime = 5

        board.get_nf_conntrack_conn_count()

        for i in range(10000):
            sz, rate, ip, port = self.startSingleFlow(maxtime=maxtime)
            print("started UDP to %s:%s sz = %s, rate = %sk" %
                  (ip, port, sz, rate))
            time = sz / (rate * 1024)
            print("time should be ~%s" % time)
            self.check_and_clean_ips()
            lan.sendline('fg')
            lan.expect(prompt, timeout=5)

            board.get_pp_dev().sendline(
                'cat /proc/net/nf_conntrack | grep dst=%s.*dport=%s' %
                (ip, port))
            board.get_pp_dev().expect(prompt)

        board.get_nf_conntrack_conn_count()

        self.recover()
Exemplo n.º 2
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()
Exemplo n.º 3
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.º 4
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.º 5
0
    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()
Exemplo n.º 6
0
    def runTest(self):
        from devices import lan, debian, linux
        if lan.model == "debian":
            # check that lan is derived from LinuxDevice
            assert(issubclass(debian.DebianBox, linux.LinuxDevice))

        #get the mac address of the interface
        lan_mac = lan.get_interface_macaddr(lan.iface_dut)
        assert lan_mac != None, "Failed getting lan mac address"
        print("lan mac address: %s" % lan_mac)

        #check the system uptime
        uptime = lan.get_seconds_uptime()
        assert uptime != None, "Failed getting system uptime"
        print("system uptime is: %s" % uptime)

        #ping ip using function ping from linux.py
        ping_check = lan.ping("8.8.8.8")
        print("ping status is %s" % ping_check)

        #disable ipv6
        ipv6_disable = lan.disable_ipv6(lan.iface_dut)
        #enable ipv6
        ipv6_enable = lan.enable_ipv6(lan.iface_dut)
        board.set_printk()
        print("Test passed")

        #remove neighbour table entries
        lan.ip_neigh_flush()

        #set the link state up
        lan.set_link_state(lan.iface_dut, "up")

        #Checking the interface status
        link = lan.is_link_up(lan.iface_dut)
        assert link != None, "Failed to check the link is up"

        #add sudo when the username is root
        lan.sudo_sendline("ping -c5 '8.8.8.8'")
        lan.expect(lan.prompt, timeout=50)

        #add new user name in linux
        lan.add_new_user("test", "test")
        lan.sendline("userdel test")
        lan.expect(lan.prompt)

        text_file = tempfile.NamedTemporaryFile()
        letters = string.ascii_letters
        fcontent = ''.join(random.choice(letters) for i in range(50))

        text_file.write(fcontent)
        text_file.flush()

        fmd5 = hashlib.md5(open(text_file.name, 'rb').read()).hexdigest()
        print("File orginal md5sum: %s"% fmd5)
        print('copying file to lan at /tmp/dst.txt')
        lan.copy_file_to_server(text_file.name, "/tmp/dst.txt")
        print('Copy Done. Verify the integrity of the file')
        lan.sendline('md5sum /tmp/dst.txt')
        lan.expect(fmd5)
        lan.expect(lan.prompt)

        '''FUnctions moved from openwrt to linux '''
        #Wait until network interfaces have IP Addresses
        board.wait_for_network()
        print "Waited until network interfaces has ip address"

        #Check the available memory of the device
        memory_avail = board.get_memfree()
        print 'Available memory of the device:{}'.format(memory_avail)

        #Getting the vmstat
        vmstat_out = board.get_proc_vmstat()
        assert vmstat_out is not None, 'virtual machine status is None'
        print "Got the vmstat{}".format(vmstat_out)

        #Get the total number of connections in the network
        nw_count = board.get_nf_conntrack_conn_count()
        assert nw_count is not None , 'connections are empty'
        print 'Get the total number of connections in the network{}'.format(nw_count)

        #Getting the DNS server upstream
        ip_addr = board.get_dns_server_upstream()
        assert ip_addr is not None, 'Getting nameserver ip is None'
        print "Got the DNS server upstream{}".format(ip_addr)
        print('Test Passed')