git.iko.soy/typeable/nixpkgs
on master help sign in
nixos: Add VM test for blivet.

I'm really not sure whether these tests are actually run upstream, because there are quite a few oddities which either are my fault by just missing something important or upstream really doesn't bother to run those tests. One example of this are testDiskChunk1 and testDiskChunk2, which create two non-existing partitions and tries to allocate them. Now, in allocatePartitions(), the partedPartition attributes are reset to None and shortly afterwards a for loop is expecting it to be NOT None. So, for now I'm disabling these tests and will see if we stumble on them during work on nixpart 1.0, so we're really sure whether it's my fault or a real bug in blivet. Signed-off-by: aszlig <aszlig@redmoonstudios.org>

commitcff26e2d384bb43022eaced9ca0682b4f671b1ab authoraszlig <aszlig@redmoonstudios.org> dateWed 22 Oct 2014, 05:50 (12 years ago) parent16371fc
3 files changed+87−1
nixos/release.nix+1 nixos/tests/blivet.nix+85 pkgs/development/python-modules/blivet/default.nix+1−1
nixos/release.nix+1
@@ -234,6 +234,7 @@ in rec {
234234 # ‘nix-build tests/login.nix -A result’.
235235 tests.avahi = callTest tests/avahi.nix {};
236236 tests.bittorrent = callTest tests/bittorrent.nix {};
237+ tests.blivet = callTest tests/blivet.nix {};
237238 tests.containers = callTest tests/containers.nix {};
238239 tests.firefox = callTest tests/firefox.nix {};
239240 tests.firewall = callTest tests/firewall.nix {};
nixos/tests/blivet.nixnew file+85
@@ -0,0 +1,85 @@
1+import ./make-test.nix ({ pkgs, ... }: with pkgs.pythonPackages; rec {
2+ name = "blivet";
3+
4+ machine = {
5+ environment.systemPackages = [ pkgs.python blivet mock ];
6+ boot.supportedFilesystems = [ "btrfs" "jfs" "reiserfs" "xfs" ];
7+ virtualisation.memorySize = 768;
8+ };
9+
10+ debugBlivet = false;
11+ debugProgramCalls = false;
12+
13+ pythonTestRunner = pkgs.writeText "run-blivet-tests.py" ''
14+ import sys
15+ import logging
16+
17+ from unittest import TestLoader
18+ from unittest.runner import TextTestRunner
19+
20+ ${pkgs.lib.optionalString debugProgramCalls ''
21+ blivet_program_log = logging.getLogger("program")
22+ blivet_program_log.setLevel(logging.DEBUG)
23+ blivet_program_log.addHandler(logging.StreamHandler(sys.stderr))
24+ ''}
25+
26+ ${pkgs.lib.optionalString debugBlivet ''
27+ blivet_log = logging.getLogger("blivet")
28+ blivet_log.setLevel(logging.DEBUG)
29+ blivet_log.addHandler(logging.StreamHandler(sys.stderr))
30+ ''}
31+
32+ runner = TextTestRunner(verbosity=2, failfast=False, buffer=False)
33+ result = runner.run(TestLoader().discover('tests/', pattern='*_test.py'))
34+ sys.exit(not result.wasSuccessful())
35+ '';
36+
37+ blivetTest = pkgs.writeScript "blivet-test.sh" ''
38+ #!${pkgs.stdenv.shell} -e
39+
40+ # Use the hosts temporary directory, because we have a tmpfs within the VM
41+ # and we don't want to increase the memory size of the VM for no reason.
42+ mkdir -p /tmp/xchg/bigtmp
43+ TMPDIR=/tmp/xchg/bigtmp
44+ export TMPDIR
45+
46+ mkPythonPath() {
47+ nix-store -qR "$@" \
48+ | sed -e 's|$|/lib/${pkgs.python.libPrefix}/site-packages|'
49+ }
50+
51+ cp -Rd "${blivet.src}/tests" .
52+
53+ # Skip SELinux tests
54+ rm -f tests/formats_test/selinux_test.py
55+
56+ # Race conditions in growing/shrinking during resync
57+ rm -f tests/devicelibs_test/mdraid_*
58+
59+ # Deactivate small BTRFS device test, because it fails with newer btrfsprogs
60+ sed -i -e '/^class *BTRFSAsRootTestCase3(/,/^[^ ]/ {
61+ /^class *BTRFSAsRootTestCase3(/d
62+ /^$/d
63+ /^ /d
64+ }' tests/devicelibs_test/btrfs_test.py
65+
66+ # How on earth can these tests ever work even upstream? O_o
67+ sed -i -e '/def testDiskChunk[12]/,/^ *[^ ]/{n; s/^ */&return # /}' \
68+ tests/partitioning_test.py
69+
70+ # fix hardcoded temporary directory
71+ sed -i \
72+ -e '1i import tempfile' \
73+ -e 's|_STORE_FILE_PATH = .*|_STORE_FILE_PATH = tempfile.gettempdir()|' \
74+ tests/loopbackedtestcase.py
75+
76+ PYTHONPATH=".:$(mkPythonPath "${blivet}" "${mock}" | paste -sd :)" \
77+ python "${pythonTestRunner}"
78+ '';
79+
80+ testScript = ''
81+ $machine->waitForUnit("multi-user.target");
82+ $machine->succeed("${blivetTest}");
83+ $machine->execute("rm -rf /tmp/xchg/bigtmp");
84+ '';
85+})
pkgs/development/python-modules/blivet/default.nix+1−1
@@ -36,7 +36,7 @@ in buildPythonPackage rec {
3636 six
3737 ];
3838
39− # Tests in <nixos/tests/blivet.nix> coming soon.
39+ # Tests are in <nixos/tests/blivet.nix>.
4040 doCheck = false;
4141
4242 meta = {