run pytest inside an ephemeral NixOS VM; update readme #85

Merged
inex merged 1 commits from flake-check-and-readme into master 2024-02-01 12:04:10 +02:00
Collaborator
There is no content yet.
inex was assigned by alexoundos 2024-01-23 21:38:40 +02:00
alexoundos added 2 commits 2024-01-23 21:38:40 +02:00
alexoundos force-pushed flake-check-and-readme from c82ecbd77c to 86442b18d1 2024-01-24 10:16:23 +02:00 Compare
inex added 1 commit 2024-01-24 12:08:15 +02:00
continuous-integration/drone/push Build is failing Details
4f18557402
feat: Add coverage to flake check
inex changed title from run pytest inside an ephemeral NixOS VM; update readme to WIP: run pytest inside an ephemeral NixOS VM; update readme 2024-01-24 12:57:27 +02:00
alexoundos changed title from WIP: run pytest inside an ephemeral NixOS VM; update readme to WIP: run pytest inside an ephemeral NixOS VM; update readme 2024-01-24 12:57:27 +02:00
houkime added a new dependency 2024-01-24 14:46:02 +02:00
alexoundos added 2 commits 2024-01-24 18:30:42 +02:00
alexoundos changed title from WIP: run pytest inside an ephemeral NixOS VM; update readme to run pytest inside an ephemeral NixOS VM; update readme 2024-01-24 18:31:03 +02:00
alexoundos force-pushed flake-check-and-readme from ca2423e751 to 849f84466e 2024-01-24 18:34:46 +02:00 Compare
inex approved these changes 2024-01-24 18:53:34 +02:00
alexoundos added 1 commit 2024-01-24 20:29:00 +02:00
continuous-integration/drone/push Build is failing Details
ceb75bf78c
fix vm-pytest-shared.sh and reduce messages line length
Poster
Collaborator

@houkime, @inex, please check again. I fixed identified problems.
I will squash commits after approval.

@houkime, @inex, please check again. I fixed identified problems. I will squash commits after approval.
alexoundos requested review from inex 2024-01-24 20:31:18 +02:00
inex requested review from houkime 2024-01-25 15:06:26 +02:00
alexoundos added 1 commit 2024-01-25 21:45:54 +02:00
continuous-integration/drone/push Build is failing Details
f96ba01c19
readme: more info about Nix flake nixpkgs input
inex approved these changes 2024-01-26 12:20:29 +02:00
Collaborator

./vm-pytest-shared.sh tests/test_jobs.py fails
Here is the log

+ export TMPDIR=.nixos-vm-tmp-dir
+ TMPDIR=.nixos-vm-tmp-dir
+ readonly NIXOS_VM_SHARED_DIR_HOST=.nixos-vm-tmp-dir/shared-xchg
+ NIXOS_VM_SHARED_DIR_HOST=.nixos-vm-tmp-dir/shared-xchg
+ readonly NIXOS_VM_SHARED_DIR_GUEST=/tmp/shared
+ NIXOS_VM_SHARED_DIR_GUEST=/tmp/shared
+ readonly VM_SRC_DIR=/root/source
+ VM_SRC_DIR=/root/source
+ mkdir -p .nixos-vm-tmp-dir
+ ln -sfv /home/user/selfprivacy-rest-api -T .nixos-vm-tmp-dir/shared-xchg
'.nixos-vm-tmp-dir/shared-xchg' -> '/home/user/selfprivacy-rest-api'
++ cat
+ SCRIPT='start_all()
machine.succeed("ln -sf /tmp/shared -T /root/source >&2")
machine.succeed("black --check /root/source >&2")
machine.succeed("cd /root/source && coverage run -m pytest -v tests/test_jobs.py >&2")
machine.succeed("cd /root/source && coverage report >&2")'
+ nix --extra-experimental-features 'nix-command flakes' run .#checks.x86_64-linux.default.driver -- /dev/fd/63
++ printf %s 'start_all()
machine.succeed("ln -sf /tmp/shared -T /root/source >&2")
machine.succeed("black --check /root/source >&2")
machine.succeed("cd /root/source && coverage run -m pytest -v tests/test_jobs.py >&2")
machine.succeed("cd /root/source && coverage report >&2")'
Machine state will be reset. To keep it, pass --keep-vm-state
start all VLans
start vlan
running vlan (pid 17409; ctl /home/user/selfprivacy-rest-api/.nixos-vm-tmp-dir/vde1.ctl)
(finished: start all VLans, in 0.00 seconds)
deleting VM state directory /home/user/selfprivacy-rest-api/.nixos-vm-tmp-dir/vm-state-machine
if you want to keep the VM state, pass --keep-vm-state
Test will time out and terminate in 3600 seconds
run the VM test script
additionally exposed symbols:
    machine,
    vlan1,
    start_all, test_script, machines, vlans, driver, log, os, create_machine, subtest, run_tests, join_all, retry, serial_stdout_off, serial_stdout_on, polling_condition, Machine
start all VMs
machine: starting vm
cleanup
(finished: cleanup, in 0.00 seconds)
Traceback (most recent call last):
  File "/nix/store/0q8sk7njr8nbbp2gww6m4yrm2f52j375-nixos-test-driver-1.1/bin/.nixos-test-driver-wrapped", line 9, in <module>
    sys.exit(main())
             ^^^^^^
  File "/nix/store/0q8sk7njr8nbbp2gww6m4yrm2f52j375-nixos-test-driver-1.1/lib/python3.11/site-packages/test_driver/__init__.py", line 126, in main
    driver.run_tests()
  File "/nix/store/0q8sk7njr8nbbp2gww6m4yrm2f52j375-nixos-test-driver-1.1/lib/python3.11/site-packages/test_driver/driver.py", line 159, in run_tests
    self.test_script()
  File "/nix/store/0q8sk7njr8nbbp2gww6m4yrm2f52j375-nixos-test-driver-1.1/lib/python3.11/site-packages/test_driver/driver.py", line 151, in test_script
    exec(self.tests, symbols, None)
  File "<string>", line 1, in <module>
  File "/nix/store/0q8sk7njr8nbbp2gww6m4yrm2f52j375-nixos-test-driver-1.1/lib/python3.11/site-packages/test_driver/driver.py", line 169, in start_all
    machine.start()
  File "/nix/store/0q8sk7njr8nbbp2gww6m4yrm2f52j375-nixos-test-driver-1.1/lib/python3.11/site-packages/test_driver/machine.py", line 1132, in start
    self.qmp_client = QMPSession.from_path(self.qmp_path)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/0q8sk7njr8nbbp2gww6m4yrm2f52j375-nixos-test-driver-1.1/lib/python3.11/site-packages/test_driver/qmp.py", line 50, in from_path
    return cls(sock)
           ^^^^^^^^^
  File "/nix/store/0q8sk7njr8nbbp2gww6m4yrm2f52j375-nixos-test-driver-1.1/lib/python3.11/site-packages/test_driver/qmp.py", line 44, in __init__
    self.send("qmp_capabilities")
  File "/nix/store/0q8sk7njr8nbbp2gww6m4yrm2f52j375-nixos-test-driver-1.1/lib/python3.11/site-packages/test_driver/qmp.py", line 98, in send
    return self._wait_for_new_result()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/0q8sk7njr8nbbp2gww6m4yrm2f52j375-nixos-test-driver-1.1/lib/python3.11/site-packages/test_driver/qmp.py", line 58, in _wait_for_new_result
    self.read_pending_messages()
  File "/nix/store/0q8sk7njr8nbbp2gww6m4yrm2f52j375-nixos-test-driver-1.1/lib/python3.11/site-packages/test_driver/qmp.py", line 62, in read_pending_messages
    line = self.reader.readline()
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/qp5zys77biz7imbk6yy85q5pdv7qk84j-python3-3.11.6/lib/python3.11/socket.py", line 706, in readinto
    return self._sock.recv_into(b)
           ^^^^^^^^^^^^^^^^^^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer
kill vlan (pid 17409)
./vm-pytest-shared.sh tests/test_jobs.py fails Here is the log ``` + export TMPDIR=.nixos-vm-tmp-dir + TMPDIR=.nixos-vm-tmp-dir + readonly NIXOS_VM_SHARED_DIR_HOST=.nixos-vm-tmp-dir/shared-xchg + NIXOS_VM_SHARED_DIR_HOST=.nixos-vm-tmp-dir/shared-xchg + readonly NIXOS_VM_SHARED_DIR_GUEST=/tmp/shared + NIXOS_VM_SHARED_DIR_GUEST=/tmp/shared + readonly VM_SRC_DIR=/root/source + VM_SRC_DIR=/root/source + mkdir -p .nixos-vm-tmp-dir + ln -sfv /home/user/selfprivacy-rest-api -T .nixos-vm-tmp-dir/shared-xchg '.nixos-vm-tmp-dir/shared-xchg' -> '/home/user/selfprivacy-rest-api' ++ cat + SCRIPT='start_all() machine.succeed("ln -sf /tmp/shared -T /root/source >&2") machine.succeed("black --check /root/source >&2") machine.succeed("cd /root/source && coverage run -m pytest -v tests/test_jobs.py >&2") machine.succeed("cd /root/source && coverage report >&2")' + nix --extra-experimental-features 'nix-command flakes' run .#checks.x86_64-linux.default.driver -- /dev/fd/63 ++ printf %s 'start_all() machine.succeed("ln -sf /tmp/shared -T /root/source >&2") machine.succeed("black --check /root/source >&2") machine.succeed("cd /root/source && coverage run -m pytest -v tests/test_jobs.py >&2") machine.succeed("cd /root/source && coverage report >&2")' Machine state will be reset. To keep it, pass --keep-vm-state start all VLans start vlan running vlan (pid 17409; ctl /home/user/selfprivacy-rest-api/.nixos-vm-tmp-dir/vde1.ctl) (finished: start all VLans, in 0.00 seconds) deleting VM state directory /home/user/selfprivacy-rest-api/.nixos-vm-tmp-dir/vm-state-machine if you want to keep the VM state, pass --keep-vm-state Test will time out and terminate in 3600 seconds run the VM test script additionally exposed symbols: machine, vlan1, start_all, test_script, machines, vlans, driver, log, os, create_machine, subtest, run_tests, join_all, retry, serial_stdout_off, serial_stdout_on, polling_condition, Machine start all VMs machine: starting vm cleanup (finished: cleanup, in 0.00 seconds) Traceback (most recent call last): File "/nix/store/0q8sk7njr8nbbp2gww6m4yrm2f52j375-nixos-test-driver-1.1/bin/.nixos-test-driver-wrapped", line 9, in <module> sys.exit(main()) ^^^^^^ File "/nix/store/0q8sk7njr8nbbp2gww6m4yrm2f52j375-nixos-test-driver-1.1/lib/python3.11/site-packages/test_driver/__init__.py", line 126, in main driver.run_tests() File "/nix/store/0q8sk7njr8nbbp2gww6m4yrm2f52j375-nixos-test-driver-1.1/lib/python3.11/site-packages/test_driver/driver.py", line 159, in run_tests self.test_script() File "/nix/store/0q8sk7njr8nbbp2gww6m4yrm2f52j375-nixos-test-driver-1.1/lib/python3.11/site-packages/test_driver/driver.py", line 151, in test_script exec(self.tests, symbols, None) File "<string>", line 1, in <module> File "/nix/store/0q8sk7njr8nbbp2gww6m4yrm2f52j375-nixos-test-driver-1.1/lib/python3.11/site-packages/test_driver/driver.py", line 169, in start_all machine.start() File "/nix/store/0q8sk7njr8nbbp2gww6m4yrm2f52j375-nixos-test-driver-1.1/lib/python3.11/site-packages/test_driver/machine.py", line 1132, in start self.qmp_client = QMPSession.from_path(self.qmp_path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/nix/store/0q8sk7njr8nbbp2gww6m4yrm2f52j375-nixos-test-driver-1.1/lib/python3.11/site-packages/test_driver/qmp.py", line 50, in from_path return cls(sock) ^^^^^^^^^ File "/nix/store/0q8sk7njr8nbbp2gww6m4yrm2f52j375-nixos-test-driver-1.1/lib/python3.11/site-packages/test_driver/qmp.py", line 44, in __init__ self.send("qmp_capabilities") File "/nix/store/0q8sk7njr8nbbp2gww6m4yrm2f52j375-nixos-test-driver-1.1/lib/python3.11/site-packages/test_driver/qmp.py", line 98, in send return self._wait_for_new_result() ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/nix/store/0q8sk7njr8nbbp2gww6m4yrm2f52j375-nixos-test-driver-1.1/lib/python3.11/site-packages/test_driver/qmp.py", line 58, in _wait_for_new_result self.read_pending_messages() File "/nix/store/0q8sk7njr8nbbp2gww6m4yrm2f52j375-nixos-test-driver-1.1/lib/python3.11/site-packages/test_driver/qmp.py", line 62, in read_pending_messages line = self.reader.readline() ^^^^^^^^^^^^^^^^^^^^^^ File "/nix/store/qp5zys77biz7imbk6yy85q5pdv7qk84j-python3-3.11.6/lib/python3.11/socket.py", line 706, in readinto return self._sock.recv_into(b) ^^^^^^^^^^^^^^^^^^^^^^^ ConnectionResetError: [Errno 104] Connection reset by peer kill vlan (pid 17409) ```
alexoundos changed title from run pytest inside an ephemeral NixOS VM; update readme to WIP: run pytest inside an ephemeral NixOS VM; update readme 2024-01-26 12:48:42 +02:00
Poster
Collaborator

@houkime, try this command to test whether such way of running tests is possible in your desktop:

$ nix --extra-experimental-features 'nix-command flakes' run .#checks.x86_64-linux.default.driver <(echo 'start_all()')

This is used internally in the vm script.

@houkime, try this command to test whether such way of running tests is possible in your desktop: ``` $ nix --extra-experimental-features 'nix-command flakes' run .#checks.x86_64-linux.default.driver <(echo 'start_all()') ``` This is used internally in the vm script.
alexoundos added 1 commit 2024-01-26 13:58:20 +02:00
continuous-integration/drone/push Build is failing Details
951a820101
rename vm-pytest-shared.sh => pytest-vm.sh
Poster
Collaborator

NixOS QEMU test driver fails on any non-NixOS installation with the same error message above:

$ nix --extra-experimental-features 'nix-command flakes' run git+https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api?rev=951a82010123b99a41d4f2c89df51f3313219fb7#checks.x86_64-linux.default.driver
NixOS QEMU test driver fails on any non-NixOS installation with the same error message above: ```console $ nix --extra-experimental-features 'nix-command flakes' run git+https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api?rev=951a82010123b99a41d4f2c89df51f3313219fb7#checks.x86_64-linux.default.driver ```
Poster
Collaborator
Reported the problem upstream: https://github.com/NixOS/nixpkgs/pull/257535#issuecomment-1912162282.
alexoundos added 2 commits 2024-01-26 20:37:58 +02:00
cc461936e5 move test dependencies and format check to the flake check derivations
+ refactor getting python module from API package
continuous-integration/drone/push Build is failing Details
4e9ac7a6c1
fix "not an absolute path: '.nixos-vm-tmp-dir'"
Poster
Collaborator

Currently, we have 3 ways:

  1. use interactive QEMU on non-NixOS machines
  2. use additional nixpkgs revision (older than 2023-12) before the bug was introduced
    (the implication is that additional /nix/store space needed (~250 MiB) for each SP machine, because Nix flake inputs are downloaded unconditionally)
  3. provide more info about the failure upstream
Currently, we have 3 ways: 1. use interactive QEMU on non-NixOS machines 2. use additional nixpkgs revision (older than 2023-12) before the bug was introduced (the implication is that additional /nix/store space needed (~250 MiB) for each SP machine, because Nix flake inputs are downloaded unconditionally) 3. provide more info about the failure [upstream](https://github.com/NixOS/nixpkgs/pull/257535#issuecomment-1912478235)
alexoundos added 1 commit 2024-01-29 20:27:43 +02:00
continuous-integration/drone/push Build is failing Details
7b1ae9e790
readme: troubleshooting: LANG environment variable
alexoundos added 3 commits 2024-01-31 16:27:58 +02:00
alexoundos force-pushed flake-check-and-readme from 9ea7bd199a to 1ec6be59fd 2024-01-31 22:07:53 +02:00 Compare
alexoundos changed title from WIP: run pytest inside an ephemeral NixOS VM; update readme to run pytest inside an ephemeral NixOS VM; update readme 2024-01-31 22:08:00 +02:00
alexoundos requested review from inex 2024-01-31 22:08:24 +02:00
inex approved these changes 2024-02-01 12:03:46 +02:00
inex merged commit d0eee319d3 into master 2024-02-01 12:04:10 +02:00
inex deleted branch flake-check-and-readme 2024-02-01 12:04:10 +02:00
Sign in to join this conversation.
There is no content yet.