rss-bridge: 2024-02-02 -> 2025-01-02 (#372627)
[NixPkgs.git] / nixos / tests / rkvm / default.nix
blob3c126f41f9293c0460e74ed71195955890b1f4e7
1 import ../make-test-python.nix (
2   { pkgs, ... }:
3   let
4     # Generated with
5     #
6     # nix shell .#rkvm --command "rkvm-certificate-gen --ip-addresses 10.0.0.1 cert.pem key.pem"
7     #
8     snakeoil-cert = ./cert.pem;
9     snakeoil-key = ./key.pem;
10   in
11   {
12     name = "rkvm";
14     nodes = {
15       server =
16         { pkgs, ... }:
17         {
18           imports = [ ../common/user-account.nix ];
20           virtualisation.vlans = [ 1 ];
22           networking = {
23             useNetworkd = true;
24             useDHCP = false;
25             firewall.enable = false;
26           };
28           systemd.network.networks."01-eth1" = {
29             name = "eth1";
30             networkConfig.Address = "10.0.0.1/24";
31           };
33           services.getty.autologinUser = "alice";
35           services.rkvm.server = {
36             enable = true;
37             settings = {
38               certificate = snakeoil-cert;
39               key = snakeoil-key;
40               password = "snakeoil";
41               switch-keys = [
42                 "left-alt"
43                 "right-alt"
44               ];
45             };
46           };
47         };
49       client =
50         { pkgs, ... }:
51         {
52           imports = [ ../common/user-account.nix ];
54           virtualisation.vlans = [ 1 ];
56           networking = {
57             useNetworkd = true;
58             useDHCP = false;
59             firewall.enable = false;
60           };
62           systemd.network.networks."01-eth1" = {
63             name = "eth1";
64             networkConfig.Address = "10.0.0.2/24";
65           };
67           services.getty.autologinUser = "alice";
69           services.rkvm.client = {
70             enable = true;
71             settings = {
72               server = "10.0.0.1:5258";
73               certificate = snakeoil-cert;
74               key = snakeoil-key;
75               password = "snakeoil";
76             };
77           };
78         };
79     };
81     testScript = ''
82       server.wait_for_unit("getty@tty1.service")
83       server.wait_until_succeeds("pgrep -f 'agetty.*tty1'")
84       server.wait_for_unit("rkvm-server")
85       server.wait_for_open_port(5258)
87       client.wait_for_unit("getty@tty1.service")
88       client.wait_until_succeeds("pgrep -f 'agetty.*tty1'")
89       client.wait_for_unit("rkvm-client")
91       server.sleep(1)
93       # Switch to client
94       server.send_key("alt-alt_r", delay=0.2)
95       server.send_chars("echo 'hello client' > /tmp/test.txt\n")
97       # Switch to server
98       server.send_key("alt-alt_r", delay=0.2)
99       server.send_chars("echo 'hello server' > /tmp/test.txt\n")
101       server.sleep(1)
103       client.systemctl("stop rkvm-client.service")
104       server.systemctl("stop rkvm-server.service")
106       server_file = server.succeed("cat /tmp/test.txt")
107       assert server_file.strip() == "hello server"
109       client_file = client.succeed("cat /tmp/test.txt")
110       assert client_file.strip() == "hello client"
111     '';
112   }