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

pytest-django: tests fail due to sandbox on aarch64-darwin #284099

Closed
n8henrie opened this issue Jan 26, 2024 · 2 comments · Fixed by #284401
Closed

pytest-django: tests fail due to sandbox on aarch64-darwin #284099

n8henrie opened this issue Jan 26, 2024 · 2 comments · Fixed by #284401
Labels
0.kind: bug 6.topic: darwin Running or building packages on Darwin 6.topic: python

Comments

@n8henrie
Copy link
Contributor

Describe the bug

pytest-django fails to build on aarch64-darwin due to failing tests due to a sandbox issue.

See also: #282912

Steps To Reproduce

$ nix build --rebuild .#python311.pkgs.pytest-django
error: builder for '/nix/store/l35qps1mk6nxhwwa9ijblsk6xw8q2fnf-python3.11-pytest-django-4.7.0.drv' failed with exit code 1;
       last 10 log lines:
       > ERROR tests/test_fixtures.py::TestLiveServer::test_change_settings - socket.gaierror: [Errno 8] nodename nor servname provided, or not known
       > ERROR tests/test_fixtures.py::TestLiveServer::test_transactions - socket.gaierror: [Errno 8] nodename nor servname provided, or not known
       > ERROR tests/test_fixtures.py::TestLiveServer::test_serve_static_dj17_without_staticfiles_app - socket.gaierror: [Errno 8] nodename nor servname provided, or not known
       > ERROR tests/test_fixtures.py::TestLiveServer::test_db_changes_visibility - socket.gaierror: [Errno 8] nodename nor servname provided, or not known
       > ERROR tests/test_fixtures.py::TestLiveServer::test_item - socket.gaierror: [Errno 8] nodename nor servname provided, or not known
       > ERROR tests/test_fixtures.py::TestLiveServer::test_url - socket.gaierror: [Errno 8] nodename nor servname provided, or not known
       > FAILED tests/test_fixtures.py::TestLiveServer::test_specified_port_django_111 - PermissionError: [Errno 1] Operation not permitted
       > FAILED tests/test_fixtures.py::TestLiveServer::test_serve_static_with_staticfiles_app - Failed: nomatch: '*test_a*PASSED*'
       > ============= 2 failed, 202 passed, 2 skipped, 10 errors in 25.24s =============
       > /nix/store/ymqnr6q4slam0ns76mjpcjry70fa8h3i-stdenv-darwin/setup: line 1591: pop_var_context: head of shell_variables not a function context
       For full logs, run 'nix log /nix/store/l35qps1mk6nxhwwa9ijblsk6xw8q2fnf-python3.11-pytest-django-4.7.0.drv'.
$ nix build --rebuild .#python311.pkgs.pytest-django --option sandbox false
$ echo $?
0

Expected behavior

Tests should pass, allowing the package build to succeed.

Notify maintainers

none listed for pytest-django specifically, @Hexa for django in general

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"aarch64-darwin"`
 - host os: `Darwin 23.2.0, macOS 14.2.1`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.19.2`
 - channels(n8henrie): `""`
 - channels(root): `""`
 - nixpkgs: `/nix/store/64npyyxn3bb6cxciz12yigldfc2p9fh1-source`

Add a 👍 reaction to issues you find important.

@n8henrie
Copy link
Contributor Author

https://discourse.nixos.org/t/dealing-with-tests-that-require-networking-support/13804

In a case like this, would disabling these tests be appropriate?

They seem to only need access to localhost -- is that permissible in a sandboxed build?

@n8henrie
Copy link
Contributor Author

They seem to only need access to localhost -- is that permissible in a sandboxed build?

Future self: this was fixed by adding __darwinAllowLocalNetworking, which seems to currently have zero mentions in the nixpkgs manual (or the nixos manual) or https://nix.dev/manual/nix/2.19/language/advanced-attributes.

Defined in nix: https://github.com/NixOS/nix/blob/40254092dd7bc402642b3fb4a66d4c999b3b7b0f/src/libstore/build/local-derivation-goal.cc#L2087

It adds -D _ALLOW_LOCAL_NETWORKING=1 to the sandbox-exec call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug 6.topic: darwin Running or building packages on Darwin 6.topic: python
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants