Example #1
0
 def runTest(self):
     board.sendline('\nuci show mcproxy')
     board.expect_exact('mcproxy.config=mcproxy', timeout=5)
     board.expect_exact('mcproxy.config.protocol=IGMPv3', timeout=5)
     board.expect_exact('mcproxy.@pinstance[0]=pinstance', timeout=5)
     board.expect_exact('mcproxy.@pinstance[0].name=mcproxy1', timeout=5)
     board.expect(prompt)
     board.sendline('cat /etc/mcproxy.conf')
     board.expect('protocol IGMPv3;', timeout=5)
     board.expect('pinstance mcproxy1: "eth0" ==> "br-lan";')
     board.expect(prompt)
 def runTest(self):
     board.sendline("\nuci show mcproxy")
     board.expect_exact("mcproxy.config=mcproxy", timeout=5)
     board.expect_exact("mcproxy.config.protocol=IGMPv3", timeout=5)
     board.expect_exact("mcproxy.@pinstance[0]=pinstance", timeout=5)
     board.expect_exact("mcproxy.@pinstance[0].name=mcproxy1", timeout=5)
     board.expect(prompt)
     board.sendline("cat /etc/mcproxy.conf")
     board.expect("protocol IGMPv3;", timeout=5)
     board.expect('pinstance mcproxy1: "eth0" ==> "br-lan";')
     board.expect(prompt)
Example #3
0
    def recover(self, node1=lan, node2=wan):
        lib.common.test_msg("sending board ctrl-c")
        board.sendcontrol('c')
        board.sendcontrol('c')
        board.expect(prompt)
        lib.common.test_msg("sending node1 ctrl-c")
        node1.sendcontrol('c')
        node1.sendcontrol('c')
        node1.expect(prompt)
        lib.common.test_msg("sending node2ctrl-c")
        node2.sendcontrol('c')
        node2.sendcontrol('c')
        node2.expect(prompt)
        lib.common.test_msg("killing iperf on node1")
        self.kill_iperf(node1)
        lib.common.test_msg("killing iperf on node2")
        self.kill_iperf(node2)

        board.sendline('cat /proc/net/nf_conntrack | wc -l')
        board.expect(prompt)
        try:
            board.sendline('cat /proc/devices | grep sfe')
            board.expect('cat /proc/devices | grep sfe')
            board.expect('([0-9]+) sfe_ipv4')
            char_dev = board.match.group(1).strip()
            board.expect(prompt)
            board.sendline('mknod /dev/sfe c %s 0' % char_dev)
            board.expect(prompt)
            board.sendline('cat /dev/sfe')
            board.expect(prompt)
        except:
            pass
        board.sendline('ifconfig; route')
        board.expect_exact('ifconfig; route')
        board.expect(prompt)
        node1.sendline('ifconfig; route')
        node1.expect_exact('ifconfig; route')
        node1.expect(prompt)
        node2.sendline('ifconfig; route')
        node2.expect_exact('ifconfig; route')
        node2.expect(prompt)
Example #4
0
    def recover(self, node1=lan, node2=wan):
        lib.common.test_msg("sending board ctrl-c")
        board.sendcontrol('c')
        board.sendcontrol('c')
        board.expect(prompt)
        lib.common.test_msg("sending node1 ctrl-c")
        node1.sendcontrol('c')
        node1.sendcontrol('c')
        node1.expect(prompt)
        lib.common.test_msg("sending node2ctrl-c")
        node2.sendcontrol('c')
        node2.sendcontrol('c')
        node2.expect(prompt)
        lib.common.test_msg("killing iperf on node1")
        self.kill_iperf(node1)
        lib.common.test_msg("killing iperf on node2")
        self.kill_iperf(node2)

        board.sendline('cat /proc/net/nf_conntrack | wc -l')
        board.expect(prompt)
        try:
            board.sendline('cat /proc/devices | grep sfe')
            board.expect('cat /proc/devices | grep sfe')
            board.expect('([0-9]+) sfe_ipv4')
            char_dev = board.match.group(1).strip()
            board.expect(prompt)
            board.sendline('mknod /dev/sfe c %s 0' % char_dev)
            board.expect(prompt)
            board.sendline('cat /dev/sfe')
            board.expect(prompt)
        except:
            pass
        board.sendline('ifconfig; route')
        board.expect_exact('ifconfig; route')
        board.expect(prompt)
        node1.sendline('ifconfig; route')
        node1.expect_exact('ifconfig; route')
        node1.expect(prompt)
        node2.sendline('ifconfig; route')
        node2.expect_exact('ifconfig; route')
        node2.expect(prompt)
Example #5
0
    def boot(self, reflash=True):
        if not wan:
            msg = 'No WAN Device defined, skipping flash.'
            lib.common.test_msg(msg)
            self.skipTest(msg)

        wan.configure(kind="wan_device")
        if lan:
            lan.configure(kind="lan_device")

        # start tftpd server on appropriate device
        if self.config.board.get('wan_device', None) is not None:
            wan.start_tftp_server()
        else:
            tftp_servers = [ x['name'] for x in self.config.board['devices'] if 'tftpd-server' in x.get('options', "") ]
            # start all tftp servers for now
            for tftp_server in tftp_servers:
                tftp_device = getattr(self.config, tftp_server)
                tftp_device.start_tftp_server()


        board.reset()
        rootfs = None

        # Reflash only if at least one or more of these
        # variables are set, or else there is nothing to do in u-boot
        if reflash and (self.config.META_BUILD or self.config.ROOTFS or\
                            self.config.KERNEL or self.config.UBOOT):
            # Break into U-Boot, set environment variables
            board.wait_for_boot()
            board.setup_uboot_network()
            if self.config.META_BUILD:
                for attempt in range(3):
                    try:
                        board.flash_meta(self.config.META_BUILD)
                        break
                    except Exception as e:
                        print(e)
                        wan.restart_tftp_server()
                        board.reset(break_into_uboot=True)
                        board.setup_uboot_network()
                else:
                    raise Exception('Error during flashing...')
            if self.config.UBOOT:
                board.flash_uboot(self.config.UBOOT)
            if self.config.ROOTFS:
                # save filename for cases where we didn't flash it
                # but will use it later to load from memory
                rootfs = board.flash_rootfs(self.config.ROOTFS)
            if self.config.KERNEL:
                board.flash_linux(self.config.KERNEL)
            # Boot from U-Boot to Linux
            board.boot_linux(rootfs=rootfs)
        board.linux_booted = True
        board.wait_for_linux()
        linux_booted_seconds_up = board.get_seconds_uptime()
        # Retry setting up wan protocol
        for i in range(2):
            time.sleep(10)
            try:
                if "pppoe" in self.config.WAN_PROTO:
                    wan.turn_on_pppoe()
                board.config_wan_proto(self.config.WAN_PROTO)
                break
            except:
                print("\nFailed to check/set the router's WAN protocol.")
                pass
        board.wait_for_network()

        # wait for overlay to finish mounting
        for i in range(5):
            try:
                board.sendline('mount')
                board.expect_exact('overlayfs:/overlay on / type overlay')
                board.expect(prompt)
            except:
                if i == 4:
                    lib.common.test_msg("WARN: Overlay still not mounted")
                else:
                    pass
            else:
                break

        # Router mac addresses are likely to change, so flush arp
        if lan:
            lan.ip_neigh_flush()
        wan.ip_neigh_flush()

        # Clear default routes perhaps left over from prior use
        if lan:
            lan.sendline('\nip -6 route del default')
            lan.expect(prompt)
        wan.sendline('\nip -6 route del default')
        wan.expect(prompt)

        # Give other daemons time to boot and settle
        for i in range(5):
            board.get_seconds_uptime()
            time.sleep(5)

        try:
            board.sendline("passwd")
            board.expect("New password:"******"password")
            board.expect("Retype password:"******"password")
            board.expect(prompt)
        except:
            print("WARNING: Unable to set root password on router.")

        board.sendline('cat /proc/cmdline')
        board.expect(prompt)
        board.sendline('uname -a')
        board.expect(prompt)

        # we can't have random messsages messages
        board.sendline("echo \"1 1 1 7\" > /proc/sys/kernel/printk")
        board.expect(prompt)

        if hasattr(self.config, 'INSTALL_PKGS') and self.config.INSTALL_PKGS != "":
            for pkg in self.config.INSTALL_PKGS.split(' '):
                if len(pkg) > 0:
                    board.install_package(pkg)

        # Try to verify router has stayed up (and, say, not suddenly rebooted)
        end_seconds_up = board.get_seconds_uptime()
        print("\nThe router has been up %s seconds." % end_seconds_up)
        assert end_seconds_up > linux_booted_seconds_up
        assert end_seconds_up > 30

        self.logged['boot_time'] = end_seconds_up

        if lan:
            lan.start_lan_client()
Example #6
0
    def boot(self, reflash=True):
        if not wan:
            msg = 'No WAN Device defined, skipping flash.'
            lib.common.test_msg(msg)
            self.skipTest(msg)

        wan.configure(kind="wan_device")
        if lan:
            lan.configure(kind="lan_device")
        board.reset()
        rootfs = None

        # Reflash only if at least one or more of these
        # variables are set, or else there is nothing to do in u-boot
        if reflash and (self.config.META_BUILD or self.config.ROOTFS or\
                            self.config.KERNEL or self.config.UBOOT):
            # Break into U-Boot, set environment variables
            board.wait_for_boot()
            board.setup_uboot_network()
            if self.config.META_BUILD:
                for attempt in range(3):
                    try:
                        board.flash_meta(self.config.META_BUILD)
                        break
                    except Exception as e:
                        print(e)
                        wan.restart_tftp_server()
                        board.reset(break_into_uboot=True)
                        board.setup_uboot_network()
                else:
                    raise Exception('Error during flashing...')
            if self.config.UBOOT:
                board.flash_uboot(self.config.UBOOT)
            if self.config.ROOTFS:
                # save filename for cases where we didn't flash it
                # but will use it later to load from memory
                rootfs = board.flash_rootfs(self.config.ROOTFS)
            if self.config.KERNEL:
                board.flash_linux(self.config.KERNEL)
            # Boot from U-Boot to Linux
            board.boot_linux(rootfs=rootfs)
        board.linux_booted = True
        board.wait_for_linux()
        linux_booted_seconds_up = board.get_seconds_uptime()
        # Retry setting up wan protocol
        for i in range(2):
            time.sleep(10)
            try:
                if "pppoe" in self.config.WAN_PROTO:
                    wan.turn_on_pppoe()
                board.config_wan_proto(self.config.WAN_PROTO)
                break
            except:
                print("\nFailed to check/set the router's WAN protocol.")
                pass
        board.wait_for_network()

        # wait for overlay to finish mounting
        for i in range(5):
            try:
                board.sendline('mount')
                board.expect_exact('overlayfs:/overlay on / type overlay')
                board.expect(prompt)
            except:
                if i == 4:
                    lib.common.test_msg("WARN: Overlay still not mounted")
                else:
                    pass
            else:
                break

        # Router mac addresses are likely to change, so flush arp
        if lan:
            lan.ip_neigh_flush()
        wan.ip_neigh_flush()

        # Clear default routes perhaps left over from prior use
        if lan:
            lan.sendline('\nip -6 route del default')
            lan.expect(prompt)
        wan.sendline('\nip -6 route del default')
        wan.expect(prompt)

        # Give other daemons time to boot and settle
        for i in range(5):
            board.get_seconds_uptime()
            time.sleep(5)

        try:
            board.sendline("passwd")
            board.expect("New password:"******"password")
            board.expect("Retype password:"******"password")
            board.expect(prompt)
        except:
            print("WARNING: Unable to set root password on router.")

        board.sendline('cat /proc/cmdline')
        board.expect(prompt)
        board.sendline('uname -a')
        board.expect(prompt)

        # we can't have random messsages messages
        board.sendline("echo \"1 1 1 7\" > /proc/sys/kernel/printk")
        board.expect(prompt)

        if hasattr(self.config, 'INSTALL_PKGS') and self.config.INSTALL_PKGS != "":
            for pkg in self.config.INSTALL_PKGS.split(' '):
                if len(pkg) > 0:
                    board.install_package(pkg)

        # Try to verify router has stayed up (and, say, not suddenly rebooted)
        end_seconds_up = board.get_seconds_uptime()
        print("\nThe router has been up %s seconds." % end_seconds_up)
        assert end_seconds_up > linux_booted_seconds_up
        assert end_seconds_up > 30

        self.logged['boot_time'] = end_seconds_up

        if lan:
            lan.start_lan_client()