lgirdk / boardfarm

Automated testing with python
BSD 3-Clause Clear License
21 stars 33 forks source link

Sometimes getting IP of an interface fails which needs to be fixed #320

Closed sravichandran-contractor closed 5 years ago

sravichandran-contractor commented 5 years ago

Most of the times expired issue is seen while getting IP address from an interface.

For example in devices/base.py, we are trying to fetch an IP, sometimes expired message is thrown if IP is not present due to delay.

It would be better to have few retries before throwing error message.

def get_interface_ipaddr(self, interface): self.sendline("\nifconfig %s" % interface) self.expect('addr:(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}).*(Bcast|P-t-P):', timeout=5) ipaddr = self.match.group(1) self.expect(self.prompt) return ipaddr

def get_interface_ip6addr(self, interface): self.sendline("\nifconfig %s" % interface) self.expect_exact("ifconfig %s" % interface) self.expect(self.prompt)

    for match in re.findall(AllValidIpv6AddressesRegex, self.before):
        ip6addr = ipaddress.IPv6Address(unicode(match))
        if not ip6addr.is_link_local:
            # TODO: at some point just return ip6addr
            return match
kvetrivel-contractor commented 5 years ago

This commit fixes the above issue -> https://review.gerrithub.io/c/lgirdk/boardfarm/+/458869

kvetrivel-contractor commented 5 years ago

Passed logs in ams :

http://172.16.1.237:7777/ipuvaqihaq.md

sravichandran-contractor commented 5 years ago

retry() or retry_on_exception() can be used in script to avoid this issue