Skip to content
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

test_report and test_traceroute_as_path are impure #233

Open
RaitoBezarius opened this issue Aug 23, 2022 · 1 comment
Open

test_report and test_traceroute_as_path are impure #233

RaitoBezarius opened this issue Aug 23, 2022 · 1 comment

Comments

@RaitoBezarius
Copy link
Contributor

I'm packaging ripe-atlas-tools for NixOS and running the tests in sandbox environment is usually done as part of our packaging process.

It seems like there is some cache mechanisms for some IP machinery and it is trying to get or create a path to the cache based on $HOME :

FAILED tests/commands/test_report.py::TestReportCommand::test_arg_from_file
FAILED tests/commands/test_report.py::TestReportCommand::test_arg_from_stdin
FAILED tests/renderers/test_traceroute_aspath.py::TestTracerouteASPathRenderer::test_arg_radius
FAILED tests/renderers/test_traceroute_aspath.py::TestTracerouteASPathRenderer::test_basic
tests/renderers/test_traceroute_aspath.py:43: in run_renderer
    output += renderer.on_result(Result.get(res))
/nix/store/knn7lhskvyf9l53j0f318cj9vj1yr004-ripe-atlas-tools-3.0.2/lib/python3.10/site-packages/ripe/atlas/tools/renderers/traceroute_aspath.py:82: in on_result
    ip = IP(address)
/nix/store/knn7lhskvyf9l53j0f318cj9vj1yr004-ripe-atlas-tools-3.0.2/lib/python3.10/site-packages/ripe/atlas/tools/ipdetails.py:46: in __init__
    details = self._get_details()
/nix/store/knn7lhskvyf9l53j0f318cj9vj1yr004-ripe-atlas-tools-3.0.2/lib/python3.10/site-packages/ripe/atlas/tools/ipdetails.py:58: in _get_details
    details = cache.get("IPDetails:{}".format(self.address))
/nix/store/knn7lhskvyf9l53j0f318cj9vj1yr004-ripe-atlas-tools-3.0.2/lib/python3.10/site-packages/ripe/atlas/tools/cache.py:73: in get
    if key in self._db:
/nix/store/knn7lhskvyf9l53j0f318cj9vj1yr004-ripe-atlas-tools-3.0.2/lib/python3.10/site-packages/ripe/atlas/tools/cache.py:48: in _db
    self._db_file = dbm.open(self._get_or_create_db_path(), "c")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

file = '/homeless-shelter/.config/ripe-atlas-tools/cache-3.10.6.db', flag = 'c'
mode = 438

    def open(file, flag='r', mode=0o666): [...]
E       _gdbm.error: [Errno 2] No such file or directory: '/homeless-shelter/.config/ripe-atlas-tools/cache-3.10.6.db'

/nix/store/xf1k5k05vg3zn7dfcpfh1qa7ga48hi3m-python3-3.10.6/lib/python3.10/dbm/__init__.py:95: error

I'm not exactly sure the tests were meant to install a path in $XDG_CONFIG_PATH/ripe-atlas-tools, what do you think?

@chrisamin
Copy link
Contributor

This needs some reworking. Would it be okay to create a temporary directory (probably using Python tempfile.TemporaryDirectory) within the tests?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants