Example #1
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
Example #2
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()
Example #3
0
    def runTest(self):
        if not wan:
            msg = 'No WAN Device defined, skipping test_create_session.'
            lib.common.test_msg(msg)
            self.skipTest(msg)

        from boardfarm import devices
        # this should fail, as "DebianBoxNonExistent" is not (yet) a device
        try:
            kwargs = {
                'name': "wan_test_calls_fail",
                'ipaddr': wan.ipaddr,
                'port': 22,
                'color': 'magenta'
            }
            self.session = devices.get_device("DebianBoxNonExistent", **kwargs)
        except:
            pass
        else:
            assert self.session is None, "Test Failed on wrong class name"
            print(
                "Failed to create session on wrong class name (expected) PASS")

        # this must fail, as "169.254.12.18" is not a valid ip
        try:
            kwargs = {
                'name': "wan_test_ip_fail",
                'ipaddr': "169.254.12.18",
                'port': 22,
                'color': 'cyan'
            }
            self.session = devices.get_device("DebianBox", **kwargs)
        except:
            pass
        else:
            assert self.session is None, "Test Failed on wrong IP"
            print("Failed to create session on wrong IP (expected) PASS")

        # this must fail, as 50 is not a valid port
        try:
            kwargs = {
                'name': "wan_test_port_fail",
                'ipaddr': wan.ipaddr,
                'port': 50,
                'color': 'red'
            }
            self.session = devices.get_device("DebianBox", **kwargs)
        except:
            pass
        else:
            assert self.session is None, "Test Failed on wrong port"
            print("Failed to create session on wrong port (expected) PASS")

        # this must fail, close but no cigar
        try:
            kwargs = {
                'name': "wan_test_type_fail",
                'ipaddr': wan.ipaddr,
                'port': 50,
                'color': 'red'
            }
            self.session = devices.get_device("debina", **kwargs)
        except:
            pass
        else:
            assert self.session is None, "Test Failed on misspelled class name"
            print(
                "Failed to create session on misspelled class name (expected) PASS"
            )

        # this should pass
        try:
            kwargs = {
                'name': "correct_wan_parms",
                'ipaddr': wan.ipaddr,
                'port': wan.port,
                'color': 'yellow'
            }
            self.session = devices.get_device("debian", **kwargs)
        except:
            assert 0, "Failed to create session, Test FAILED!"
        else:
            assert self.session is not None, "Test Failed on correct paramters!!"

        print("Session created successfully")

        # is the session really logged onto the wan?

        wan.sendline()
        wan.expect(wan.prompt)
        wan.sendline("ip a")
        wan.expect_exact("ip a")
        wan.expect(wan.prompt)
        w = wan.before

        self.session.sendline()
        self.session.expect(self.session.prompt)
        self.session.sendline("ip a")
        self.session.expect_exact("ip a")
        self.session.expect(self.session.prompt)
        s = self.session.before

        assert w == s, "Interfaces differ!!! Test Failed"

        self.session.sendline("exit")

        print("Test passed")