Moznetwork should test that the IP returned by get_ip is usable.

RESOLVED WONTFIX

Status

Testing
Mozbase
RESOLVED WONTFIX
5 years ago
4 years ago

People

(Reporter: chmanchester, Assigned: parkouss)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

5 years ago
Moznetwork tests get_ip by determining whether the address it returns is among those in the output of ifconfig or ipconfig. It would be useful to additionally test whether the ip is usable, perhaps by starting mozhttpd or a SocketServer with this address.
(Reporter)

Updated

5 years ago
See Also: → bug 892087
(Assignee)

Comment 1

4 years ago
Created attachment 8530514 [details] [diff] [review]
Moznetwork should test that the IP returned by get_ip is usable

Hi,

here is an attempt to implement what you asked. This will not work for ipv6, but I think it is not supported by moznetwork.

I added two unit tests that runs well locally. By the way, other unittests doesn't work for me - I suspect that it is because I'm on archlinux and there is no more ifconfix command - just ip.
Assignee: nobody → j.parkouss
Attachment #8530514 - Flags: review?(cmanchester)
(Reporter)

Comment 2

4 years ago
Comment on attachment 8530514 [details] [diff] [review]
Moznetwork should test that the IP returned by get_ip is usable

Review of attachment 8530514 [details] [diff] [review]:
-----------------------------------------------------------------

Thanks for the patch! I think when I filed this bug the intention was to write a test that performs this check, not to incorporate this check in the call to get_ip. The way the bug summary is worded really suggests what you have here, sorry for the confusion. Looking at this it's possible this could be a useful check nonetheless. :wlach, perhaps you advise on this?

::: testing/mozbase/moznetwork/moznetwork/moznetwork.py
@@ +81,5 @@
> +    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> +    try:
> +        sock.bind((ip, 0))
> +    except socket.error, exc:
> +        raise NetworkError("Check IP failed: %s" % exc)

I don't honestly know whether this will end up throwing more often than usual, so this might be risky.
Attachment #8530514 - Flags: review?(cmanchester) → feedback?(wlachance)
(Assignee)

Comment 3

4 years ago
Oh, I see! Yep, I misunderstood the purpose of the bug;
Comment on attachment 8530514 [details] [diff] [review]
Moznetwork should test that the IP returned by get_ip is usable

Review of attachment 8530514 [details] [diff] [review]:
-----------------------------------------------------------------

Yeah, I'm not sure if this check is really that helpful. If the ip address isn't usable, that will become obvious pretty soon after this. It's pretty rare for these types of methods to perform these types of checks.

I'm going to wontfix this bug: moznetwork is really pretty unlikely to break, so I don't think we really need an updated unit test. Sorry about the confusion!
Attachment #8530514 - Flags: feedback?(wlachance) → feedback-
Status: NEW → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.