nixos/tests/openarena: run real openarena clients
The old Quake3 NixOS test was removed in
50ea99cbc1
which served as a nice demo to
showcase what NixOS tests are capable of. This commit adds the same
functionality to run real openarena clients.
This commit is contained in:
parent
d3abaa51e1
commit
9f1c76f514
|
@ -1,41 +1,71 @@
|
||||||
import ./make-test-python.nix ({ pkgs, ...} : {
|
import ./make-test-python.nix ({ pkgs, ...} :
|
||||||
name = "openarena";
|
|
||||||
meta = with pkgs.stdenv.lib.maintainers; {
|
|
||||||
maintainers = [ tomfitzhenry ];
|
|
||||||
};
|
|
||||||
|
|
||||||
machine =
|
let
|
||||||
|
client =
|
||||||
{ pkgs, ... }:
|
{ pkgs, ... }:
|
||||||
|
|
||||||
{ imports = [];
|
{ imports = [ ./common/x11.nix ];
|
||||||
environment.systemPackages = with pkgs; [
|
hardware.opengl.driSupport = true;
|
||||||
socat
|
environment.systemPackages = [ pkgs.openarena ];
|
||||||
];
|
};
|
||||||
services.openarena = {
|
|
||||||
enable = true;
|
in {
|
||||||
extraFlags = [
|
name = "openarena";
|
||||||
"+set dedicated 2"
|
meta = with pkgs.stdenv.lib.maintainers; {
|
||||||
"+set sv_hostname 'My NixOS server'"
|
maintainers = [ fpletz ];
|
||||||
"+map oa_dm1"
|
};
|
||||||
];
|
|
||||||
};
|
nodes =
|
||||||
|
{ server =
|
||||||
|
{ services.openarena = {
|
||||||
|
enable = true;
|
||||||
|
extraFlags = [ "+set g_gametype 0" "+map oa_dm7" "+addbot Angelyss" "+addbot Arachna" ];
|
||||||
|
openPorts = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
client1 = client;
|
||||||
|
client2 = client;
|
||||||
};
|
};
|
||||||
|
|
||||||
testScript =
|
testScript =
|
||||||
''
|
''
|
||||||
machine.wait_for_unit("openarena.service")
|
start_all()
|
||||||
machine.wait_until_succeeds("ss --numeric --udp --listening | grep -q 27960")
|
|
||||||
|
|
||||||
# The log line containing 'resolve address' is last and only message that occurs after
|
server.wait_for_unit("openarena")
|
||||||
# the server starts accepting clients.
|
server.wait_until_succeeds("ss --numeric --udp --listening | grep -q 27960")
|
||||||
machine.wait_until_succeeds(
|
|
||||||
"journalctl -u openarena.service | grep 'resolve address: dpmaster.deathmask.net'"
|
client1.wait_for_x()
|
||||||
|
client2.wait_for_x()
|
||||||
|
|
||||||
|
client1.execute("openarena +set r_fullscreen 0 +set name Foo +connect server &")
|
||||||
|
client2.execute("openarena +set r_fullscreen 0 +set name Bar +connect server &")
|
||||||
|
|
||||||
|
server.wait_until_succeeds(
|
||||||
|
"journalctl -u openarena -e | grep -q 'Foo.*entered the game'"
|
||||||
|
)
|
||||||
|
server.wait_until_succeeds(
|
||||||
|
"journalctl -u openarena -e | grep -q 'Bar.*entered the game'"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Check it's possible to join the server.
|
server.sleep(10) # wait for a while to get a nice screenshot
|
||||||
# Can't use substring match instead of grep because the output is not utf-8
|
|
||||||
machine.succeed(
|
client1.screenshot("screen_client1_1")
|
||||||
"echo -n -e '\\xff\\xff\\xff\\xffgetchallenge' | socat - UDP4-DATAGRAM:127.0.0.1:27960 | grep -q challengeResponse"
|
client2.screenshot("screen_client2_1")
|
||||||
)
|
|
||||||
|
client1.block()
|
||||||
|
|
||||||
|
server.sleep(10)
|
||||||
|
|
||||||
|
client1.screenshot("screen_client1_2")
|
||||||
|
client2.screenshot("screen_client2_2")
|
||||||
|
|
||||||
|
client1.unblock()
|
||||||
|
|
||||||
|
server.sleep(10)
|
||||||
|
|
||||||
|
client1.screenshot("screen_client1_3")
|
||||||
|
client2.screenshot("screen_client2_3")
|
||||||
'';
|
'';
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue