flake VM: add additional /dev/vdb disk with empty ext4 FS #102

Merged
houkime merged 3 commits from vm-disk into master 2024-03-15 11:42:38 +02:00
1 changed files with 43 additions and 33 deletions

View File

@ -40,7 +40,7 @@
[testing in NixOS VM] [testing in NixOS VM]
nixos-test-driver - run an interactive NixOS VM with with all dependencies nixos-test-driver - run an interactive NixOS VM with all dependencies included and 2 disk volumes
pytest-vm - run pytest in an ephemeral NixOS VM with Redis, accepting pytest arguments pytest-vm - run pytest in an ephemeral NixOS VM with Redis, accepting pytest arguments
''; '';
in in
@ -78,7 +78,7 @@
}; };
nixosModules.default = nixosModules.default =
import ./nixos/module.nix self.packages.${system}.default; import ./nixos/module.nix self.packages.${system}.default;
devShells.${system}.default = pkgs.mkShell { devShells.${system}.default = pkgs.mkShellNoCC {
name = "SP API dev shell"; name = "SP API dev shell";
packages = with pkgs; [ packages = with pkgs; [
nixpkgs-fmt nixpkgs-fmt
@ -113,38 +113,48 @@
"black --check ${self.outPath} > $out"; "black --check ${self.outPath} > $out";
default = default =
pkgs.testers.runNixOSTest { pkgs.testers.runNixOSTest {
imports = [{ name = "default";
name = "default"; nodes.machine = { lib, pkgs, ... }: {
nodes.machine = { lib, pkgs, ... }: { # 2 additional disks (1024 MiB and 200 MiB) with empty ext4 FS
imports = [{ virtualisation.emptyDiskImages = [ 1024 200 ];
boot.consoleLogLevel = lib.mkForce 3; virtualisation.fileSystems."/volumes/vdb" = {

For tests we will need 2 volumes mounted under /volumes
Root volume may be mounted there too, but @inex , do we mount root under /volumes in prod?
At the second volume only needs 200 megs tops, we will move a small service to there

For tests we will need 2 volumes mounted under /volumes Root volume may be mounted there too, but @inex , do we mount root under /volumes in prod? At the second volume only needs 200 megs tops, we will move a small service to there
Review

No need to mount root there, because it is already mounted as /

No need to mount root there, because it is already mounted as `/`

For tests we will need 2 volumes mounted under /volumes

@houkime, done:

$ nix run -L "git+https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git?ref=vm-disk&rev=bddc6d18312c7ebdbf2b58be7e1aaa50876f0622#checks.x86_64-linux.default.driverInteractive" -- --no-interactive <(echo 'import time; machine.start(); time.sleep(1000000)')
> For tests we will need 2 volumes mounted under /volumes @houkime, done: ```console $ nix run -L "git+https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git?ref=vm-disk&rev=bddc6d18312c7ebdbf2b58be7e1aaa50876f0622#checks.x86_64-linux.default.driverInteractive" -- --no-interactive <(echo 'import time; machine.start(); time.sleep(1000000)') ```
documentation.enable = false; autoFormat = true;
services.journald.extraConfig = lib.mkForce ""; device = "/dev/vdb"; # this name is chosen by QEMU, not here
services.redis.servers.sp-api = { fsType = "ext4";
enable = true; noCheck = true;
save = [ ];
port = 6379; # FIXME
settings.notify-keyspace-events = "KEA";
};
environment.systemPackages = with pkgs; [
python-env
# TODO: these can be passed via wrapper script around app
rclone
restic
];
environment.variables.TEST_MODE = "true";
systemd.tmpfiles.settings.src.${vmtest-src-dir}.L.argument =
self.outPath;
}];
}; };
testScript = '' virtualisation.fileSystems."/volumes/vdc" = {
start_all() autoFormat = true;
machine.succeed("cd ${vmtest-src-dir} && coverage run --data-file=/tmp/.coverage -m pytest -p no:cacheprovider -v >&2") device = "/dev/vdc"; # this name is chosen by QEMU, not here
machine.succeed("coverage xml --rcfile=${vmtest-src-dir}/.coveragerc --data-file=/tmp/.coverage >&2") fsType = "ext4";
machine.copy_from_vm("coverage.xml", ".") noCheck = true;
machine.succeed("coverage report >&2") };
''; boot.consoleLogLevel = lib.mkForce 3;
}]; documentation.enable = false;
services.journald.extraConfig = lib.mkForce "";
services.redis.servers.sp-api = {
enable = true;
save = [ ];
port = 6379; # FIXME
settings.notify-keyspace-events = "KEA";
};
environment.systemPackages = with pkgs; [
python-env
# TODO: these can be passed via wrapper script around app
rclone
restic
];
environment.variables.TEST_MODE = "true";
systemd.tmpfiles.settings.src.${vmtest-src-dir}.L.argument =
self.outPath;
};
testScript = ''
start_all()
machine.succeed("cd ${vmtest-src-dir} && coverage run --data-file=/tmp/.coverage -m pytest -p no:cacheprovider -v >&2")
machine.succeed("coverage xml --rcfile=${vmtest-src-dir}/.coveragerc --data-file=/tmp/.coverage >&2")
machine.copy_from_vm("coverage.xml", ".")
machine.succeed("coverage report >&2")
'';
}; };
}; };
}; };