Skip to content

Commit f6fe7ec

Browse files
authored
Merge pull request #538 from nix-community/ubuntu-kexec-test
also test debian/fedora with linux-kexec-test
2 parents abb0d72 + 68cec9b commit f6fe7ec

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

tests/flake-module.nix

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
testInputsStable = testInputsUnstable // {
1818
kexec-installer = "${inputs'.nixos-images.packages.kexec-installer-nixos-stable-noninteractive}/nixos-kexec-installer-noninteractive-${system}.tar.gz";
1919
};
20-
ubuntuTestInputs = testInputsUnstable // {
20+
linuxTestInputs = testInputsUnstable // {
2121
nix-vm-test = inputs.nix-vm-test;
2222
};
2323
in
@@ -29,6 +29,17 @@
2929
from-nixos-with-generated-config = import ./from-nixos-generate-config.nix testInputsUnstable;
3030
from-nixos-build-on-remote = import ./from-nixos-build-on-remote.nix testInputsUnstable;
3131
from-nixos-separated-phases = import ./from-nixos-separated-phases.nix testInputsUnstable;
32-
ubuntu-kexec-test = import ./ubuntu-kexec-test.nix ubuntuTestInputs;
32+
ubuntu-kexec-test = import ./linux-kexec-test.nix (linuxTestInputs // {
33+
distribution = "ubuntu";
34+
version = "24_04";
35+
});
36+
fedora-kexec-test = import ./linux-kexec-test.nix (linuxTestInputs // {
37+
distribution = "fedora";
38+
version = "40";
39+
});
40+
debian-kexec-test = import ./linux-kexec-test.nix (linuxTestInputs // {
41+
distribution = "debian";
42+
version = "12";
43+
});
3344
});
3445
}

tests/ubuntu-kexec-test.nix renamed to tests/linux-kexec-test.nix

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
{ pkgs, nixos-anywhere, kexec-installer, nix-vm-test, system-to-install, ... }:
1+
{ pkgs, nixos-anywhere, kexec-installer, nix-vm-test, system-to-install, distribution, version, ... }:
22

3-
(nix-vm-test.lib.${pkgs.system}.ubuntu."24_04" {
3+
(nix-vm-test.lib.${pkgs.system}.${distribution}.${version} {
44
sharedDirs = { };
55

66
# Configure VM with 2GB memory
77
machineConfigModule = { ... }: {
8-
nodes.vm.virtualisation.memorySize = 2048;
8+
nodes.vm.virtualisation.memorySize = 1500;
99
};
1010

1111
# The test script
@@ -19,8 +19,12 @@
1919
# Wait for the system to be fully booted
2020
vm.wait_for_unit("multi-user.target")
2121
22+
# Detect SSH service name (ssh on Ubuntu/Debian, sshd on Fedora/RHEL)
23+
ssh_service = "sshd" if "${distribution}" in ["fedora", "centos", "rhel"] else "ssh"
24+
2225
# Unmask SSH service (which is masked by default in the test VM)
23-
vm.succeed("systemctl unmask ssh.service ssh.socket")
26+
vm.succeed(f"systemctl unmask {ssh_service}.service || true")
27+
vm.succeed(f"systemctl unmask {ssh_service}.socket || true")
2428
2529
# Generate SSH host keys (required for SSH to start)
2630
vm.succeed("ssh-keygen -A")
@@ -38,10 +42,7 @@
3842
)
3943
4044
# Start SSH service
41-
vm.succeed("systemctl start ssh")
42-
43-
# Wait for SSH to be available
44-
vm.wait_for_open_port(22)
45+
vm.succeed(f"systemctl start {ssh_service}")
4546
4647
# Forward SSH port using vm.forward_port method
4748
ssh_port = 2222

0 commit comments

Comments
 (0)