Skip to content

refactor nettools and add tests #531

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 120 commits into from
Mar 11, 2021
Merged
Changes from 1 commit
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
d4f4b6e
fix: adding a forgotten default value for optional arg
sameh-farouk Jan 3, 2021
1eb8913
feature: Adding compatibility to IPv6
sameh-farouk Jan 3, 2021
95d36dd
docs: Update tcp_connection_test funcion docstring
sameh-farouk Jan 3, 2021
186b18d
test: Adding tests for nettools.tcp_connection_test()
sameh-farouk Jan 3, 2021
582312e
refactor: Simpelfying wait_connection_test() and removing redundant code
sameh-farouk Jan 3, 2021
ff77663
docs: Changes to wait_connection_test function docstring
sameh-farouk Jan 3, 2021
6ae330c
test: Adding test for nettools.wait_connection_test()
sameh-farouk Jan 3, 2021
47bfed5
fix: Respecting the timeout arg passed to nettools.wait_http_test()
sameh-farouk Jan 3, 2021
5155f84
fix: nettools.check_url_reachable() gives false negative
sameh-farouk Jan 3, 2021
0e36e82
feature: Add compatibility for IPv6 in get_reachable_ip_address()
sameh-farouk Jan 3, 2021
c053154
feature: Add compatibility to IPv6 in nettools.get_default_ip_config()
sameh-farouk Jan 3, 2021
657e898
refactor: Refactor and optimize the code of get_network_info()
sameh-farouk Jan 3, 2021
d61e0f7
refactor: refactor and optimize nettools.ping_machine()
sameh-farouk Jan 3, 2021
5fa45e8
fix: add apple specific option -o to exit after recv 1 replay packet
sameh-farouk Jan 4, 2021
3234ef6
typo: update tests names to fix typo plublic -> public
sameh-farouk Jan 4, 2021
5e1038c
refactor: update names of enclosing functions, following naming conve…
sameh-farouk Jan 4, 2021
7166df1
refactor :Simplifying the return statement in check_url_reachable()
sameh-farouk Jan 4, 2021
9ba8c77
refactor :Simplifying the return statement in ping_machine()
sameh-farouk Jan 4, 2021
45b214e
docs: Declaring arguments and return type in functions annotations
sameh-farouk Jan 4, 2021
1194847
refactor: remove unused imports
sameh-farouk Jan 4, 2021
ee49407
fix: Handling uncaught socket.timeout exception in check_url_reachable()
sameh-farouk Jan 4, 2021
66a6de2
fix: Setting the default value of request headers to {} instead of None
sameh-farouk Jan 4, 2021
0a1b904
test: Adding more tests for nettools
sameh-farouk Jan 4, 2021
6c96cf0
test: Adding more tests for nettools and minor changes to some tests
sameh-farouk Jan 5, 2021
aba5785
feature: adding ipv6 compatibilty and minor tweaks in udp_connection_…
sameh-farouk Jan 5, 2021
62d8b0e
fix: fixing TypeError in nettools.udp_connection_test()
sameh-farouk Jan 5, 2021
2bcfeda
test: Adding test case for nettools.udp_connection_test()
sameh-farouk Jan 5, 2021
98c22ac
Docs: Adding missing docstring to test_nettools.py and minor tweaks t…
sameh-farouk Jan 5, 2021
7d9db1f
refactor: raising explicitly ValueError exception in case of invalid url
sameh-farouk Jan 5, 2021
2912904
refactor: raising explicitly ValueError exception in case of invalid ip
sameh-farouk Jan 5, 2021
fcacc94
refactor: refacoring nettools.get_default_ip_config()
sameh-farouk Jan 5, 2021
b3dc114
test: Adding test case for nettools.get_nic_names()
sameh-farouk Jan 5, 2021
7d748fb
test: Adding more tests
sameh-farouk Jan 5, 2021
885d192
test: Adding more tests
sameh-farouk Jan 5, 2021
fa871a9
fix: trying to fix KeyError on CI test server
sameh-farouk Jan 5, 2021
e96b5df
test: adding debuging code to investigate KeyError on CI test server
sameh-farouk Jan 5, 2021
0c8627f
test: adding debuging code to investigate KeyError on CI test server
sameh-farouk Jan 5, 2021
78eaba3
fix: possible fix for get_network_info() KeyError on CI serevr
sameh-farouk Jan 6, 2021
30fe84e
fix: possible fix for get_network_info() KeyError on CI serevr
sameh-farouk Jan 6, 2021
caa9096
refactor: Adding debug code and investigating CI issue
sameh-farouk Jan 6, 2021
39c5797
fix: Replacing executors.run_local with subprocess.check_output
sameh-farouk Jan 6, 2021
ea61c3e
test: Adding test case for get_mac_address func
sameh-farouk Jan 6, 2021
db530cb
test: Adding no cover flag to proxy functions
sameh-farouk Jan 6, 2021
8058fc7
fix: Correcting silly mistake var name output -> stdout
sameh-farouk Jan 6, 2021
381cf15
Revert "fix: Replacing executors.run_local with subprocess.check_output"
sameh-farouk Jan 6, 2021
2b9b349
investigate: Adding Debug code
sameh-farouk Jan 6, 2021
180820a
fix: this should fix the unexpected output from get_network_info
sameh-farouk Jan 6, 2021
b9732d1
docs: Updating wait_http_test function docstring
sameh-farouk Jan 10, 2021
69d3844
docs: Updating get_default_ip_config function docstring
sameh-farouk Jan 10, 2021
2200d13
fix: reimplementing is_nic_connected for macOS
sameh-farouk Jan 10, 2021
cf28416
refactor: remove redundant code in is_nic_connected()
sameh-farouk Jan 10, 2021
857b463
test: Adding tests for is_nic_connected()
sameh-farouk Jan 10, 2021
08ef77d
Docs: Upadating ping_machine docstring
sameh-farouk Jan 10, 2021
9ca1526
test: Adding tests for ping_machine function
sameh-farouk Jan 10, 2021
93f1ce3
debug: Adding debug code toinvistigate build issue
sameh-farouk Jan 10, 2021
c9abb9c
feature: Allow ping_machine function to accept ipv6 address
sameh-farouk Jan 10, 2021
cdec418
test: Changes to ping_machine tests due to blocked inbound icmp packets
sameh-farouk Jan 10, 2021
ca42d82
refactor: Removing debug code
sameh-farouk Jan 10, 2021
a68d9dc
refactor: Optimize nettools.wait_connection_test function
sameh-farouk Jan 11, 2021
2109399
refactor: use socket.listen method instead of nc command
sameh-farouk Jan 11, 2021
c598c3a
feature: Adding a new function get_free_port() to nettools
sameh-farouk Jan 13, 2021
a78a1ed
test: Refactoring the tests to use nettools.get_free_port()
sameh-farouk Jan 13, 2021
3627955
mkae tcp_connection_test() raises exceptions in case of address-relat…
sameh-farouk Jan 13, 2021
2380313
refactor: minor changes and refactoring
sameh-farouk Jan 17, 2021
e4a027c
refactor: remove unused import
sameh-farouk Jan 17, 2021
c964ac7
fix: replace executors.run_local with subprocess.check_output
sameh-farouk Jan 17, 2021
4071ab1
reimplementing nettools.download function
sameh-farouk Jan 17, 2021
b68aa35
docs: changes to adheres to google style docstr
sameh-farouk Jan 17, 2021
81393e6
docs: minor update to get_free_port docstr
sameh-farouk Jan 17, 2021
891a6bd
tests: Adding new tests
sameh-farouk Jan 17, 2021
2ecf550
tests: remove (missing_ok=False) arg from Path.unlink (py3.8 only fea…
sameh-farouk Jan 17, 2021
086464c
test: mark test_28 as expected to fail
sameh-farouk Jan 17, 2021
1a60e3e
test: fix test 23 fail on ubuntu 20.04
sameh-farouk Jan 17, 2021
016b42a
Merge remote-tracking branch 'origin/development' into sameh-farouk-i…
sameh-farouk Jan 18, 2021
9f5043c
docs: Apply suggestions from code review fixing typos in docstring
sameh-farouk Jan 18, 2021
fd2d752
Apply suggestions from code review - use _ for unused variable
sameh-farouk Jan 18, 2021
3078ddc
refactor: remove redundant code
sameh-farouk Jan 18, 2021
ab019bc
refactor: simplifying an conditional expression
sameh-farouk Jan 18, 2021
f0d0f04
refactor: Rearranging the IDs of the tests
sameh-farouk Jan 18, 2021
022e57a
docs: Formating the steps for the tests on the docstring
sameh-farouk Jan 18, 2021
5266aa4
docs: update the steps for test Scenario #30 on the docstring
sameh-farouk Jan 18, 2021
bb0d475
docs: Generate tests docs
sameh-farouk Jan 18, 2021
8b98030
docs: fix more typos in docstring
sameh-farouk Jan 19, 2021
a420fc5
format: Remove unnecessary comments floating around
sameh-farouk Jan 19, 2021
d50be09
test: Incorporating feedback - use sals.fs instead of os module
sameh-farouk Jan 19, 2021
52258db
test: Incorporating feedback - use sals.fs instead of os module
sameh-farouk Jan 19, 2021
680a2d7
Merge the remote branch
sameh-farouk Jan 19, 2021
2eddf2d
feature: adding logging to nettools.tcp_connection_test func
sameh-farouk Jan 19, 2021
c8f550d
feature: updating logging for nettools.tcp_connection_test func
sameh-farouk Jan 19, 2021
8713ec5
feature: adding logging to nettools.udp_connection_test func
sameh-farouk Jan 19, 2021
a64cce1
updating logging for nettools.tcp_connection_test func
sameh-farouk Jan 19, 2021
d8177ce
refactor: change the default waittime for wait_connection_test func
sameh-farouk Jan 19, 2021
a5ff3a4
feature: adding logging to nettools.wait_connection_test func
sameh-farouk Jan 19, 2021
514cc34
fix: fixing an unnecessary sleep time in edge cases
sameh-farouk Jan 19, 2021
c2afd26
updating logging for nettools.wait_connection_test func
sameh-farouk Jan 19, 2021
b72ff39
feature: adding logging to nettools.wait_http_test func
sameh-farouk Jan 19, 2021
603adf2
docs: Updating docstring for nettools.wait_connection_test func
sameh-farouk Jan 19, 2021
1fcfb6e
feature: adding logging to nettools.check_url_reachable func
sameh-farouk Jan 20, 2021
0f27855
refactor: Adding connection attempts counter to logging
sameh-farouk Jan 20, 2021
71b3afc
fix: fixing ValueError object has no attribute message error
sameh-farouk Jan 20, 2021
efa288a
feature: adding logging to nettools.get_reachable_ip_address func
sameh-farouk Jan 20, 2021
f85926f
catching OverflowError raises if port number is invalid
sameh-farouk Jan 20, 2021
6c20499
docs: update the module docstring
sameh-farouk Jan 20, 2021
5e1922f
refactor: break out of the loop properly after finding the specified …
sameh-farouk Jan 20, 2021
024ca51
docs: fix a typo
sameh-farouk Jan 20, 2021
ff0996c
feature: adding logging to nettools.get_network_info func
sameh-farouk Jan 20, 2021
facc897
feature: adding logging to nettools.is_nic_connected func
sameh-farouk Jan 20, 2021
fc74e3f
feature: adding logging to nettools.ping_machine func
sameh-farouk Jan 20, 2021
604cf04
feature: adding logging to nettools.download func
sameh-farouk Jan 20, 2021
a0edfc9
docs: Upade nettools.get_free_port doctring
sameh-farouk Jan 20, 2021
4903d92
feature: adding logging to nettools.get_free_port func
sameh-farouk Jan 20, 2021
ccc8c01
regenerate test docs
sameh-farouk Jan 20, 2021
4dc6c1f
regenerate docs for nettools
sameh-farouk Jan 20, 2021
be84f4b
tests: replcae few print statments in unit tests with a proper logging
sameh-farouk Jan 20, 2021
421c5f7
Merge branch 'development' into this feature branch
sameh-farouk Jan 25, 2021
a022711
Removing .tool-versions from repository
sameh-farouk Feb 8, 2021
354d48f
updated module docstring with a brief
sameh-farouk Feb 8, 2021
7f1fadd
refactor: Sorting imports
sameh-farouk Feb 8, 2021
bf1f450
refactor: Modifying the type of some logging messages
sameh-farouk Feb 8, 2021
38fbde1
refactor: applying @abom code review
sameh-farouk Mar 7, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: Modifying the type of some logging messages
  • Loading branch information
sameh-farouk committed Feb 8, 2021
commit bf1f450adb0487c5e0818e154f0b0e83655353c9
10 changes: 4 additions & 6 deletions jumpscale/sals/nettools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def tcp_connection_test(ipaddr: str, port: int, timeout: Optional[int] = None) -
bool: True if the test succeeds, False otherwise
"""
# conn = None
j.logger.info(f"Attempting to establish TCP connection to (IP: {ipaddr}, TCP: {port})")
j.logger.debug(f"Attempting to establish TCP connection to (IP: {ipaddr}, TCP: {port})")
try:
conn = socket.create_connection((ipaddr, port), timeout)
except (socket.gaierror, socket.herror) as e:
Expand All @@ -66,12 +66,10 @@ def tcp_connection_test(ipaddr: str, port: int, timeout: Optional[int] = None) -
reason = e.strerror
else:
reason = repr(e)
j.logger.warning(
f"TCP connection attempt to (IP: {ipaddr}, TCP: {port}) failed because of this error: {reason}"
)
j.logger.debug(f"TCP connection attempt to (IP: {ipaddr}, TCP: {port}) failed because of this error: {reason}")
return False
else:
j.logger.info(f"Successful TCP connection to (IP: {ipaddr}, TCP: {port})")
j.logger.debug(f"Successful TCP connection to (IP: {ipaddr}, TCP: {port})")
conn.close()
j.logger.debug("Connection closed")
return True
Expand Down Expand Up @@ -114,7 +112,7 @@ def udp_connection_test(ipaddr: str, port: int, timeout: Optional[int] = 1, mess
j.logger.debug("Expecting to receive at least one byte from the socket as indication to succeed connection")
data, _ = sock.recvfrom(1)
except socket.timeout:
j.logger.warning(f"Timeout of {timeout}s reached while waiting for server (IP: {ipaddr}, UDP: {port}) replay")
j.logger.debug(f"Timeout of {timeout}s reached while waiting for server (IP: {ipaddr}, UDP: {port}) replay")
return False
except OSError as e:
j.logger.warning(f"UDP connection failed because of this error: {e.strerror or repr(e)}")
Expand Down