minecraft-server: Add test

This commit is contained in:
Tim Steinbach 2020-11-28 12:42:46 -05:00
parent 0dc74a15ad
commit 13ebb30910
No known key found for this signature in database
GPG Key ID: FD36A5EAAC49035A
3 changed files with 43 additions and 2 deletions

View File

@ -209,6 +209,7 @@ in
memcached = handleTest ./memcached.nix {};
metabase = handleTest ./metabase.nix {};
minecraft = handleTest ./minecraft.nix {};
minecraft-server = handleTest ./minecraft-server.nix {};
miniflux = handleTest ./miniflux.nix {};
minio = handleTest ./minio.nix {};
minidlna = handleTest ./minidlna.nix {};

View File

@ -0,0 +1,37 @@
let
seed = "2151901553968352745";
rcon-pass = "foobar";
rcon-port = 43000;
in import ./make-test-python.nix ({ pkgs, ... }: {
name = "minecraft-server";
meta = with pkgs.stdenv.lib.maintainers; { maintainers = [ nequissimus ]; };
nodes.server = { ... }: {
environment.systemPackages = [ pkgs.mcrcon ];
nixpkgs.config.allowUnfree = true;
services.minecraft-server = {
declarative = true;
enable = true;
eula = true;
serverProperties = {
enable-rcon = true;
level-seed = seed;
online-mode = false;
"rcon.password" = rcon-pass;
"rcon.port" = rcon-port;
};
};
virtualisation.memorySize = 2048;
};
testScript = ''
server.wait_for_unit("minecraft-server")
server.wait_for_open_port(${toString rcon-port})
assert "${seed}" in server.succeed(
"mcrcon -H localhost -P ${toString rcon-port} -p '${rcon-pass}' -c 'seed'"
)
'';
})

View File

@ -1,4 +1,4 @@
{ stdenv, fetchurl, jre_headless }:
{ stdenv, fetchurl, nixosTests, jre_headless }:
stdenv.mkDerivation {
pname = "minecraft-server";
version = "1.16.4";
@ -25,7 +25,10 @@ stdenv.mkDerivation {
phases = "installPhase";
passthru.updateScript = ./update.sh;
passthru = {
tests = { inherit (nixosTests) minecraft-server; };
updateScript = ./update.sh;
};
meta = with stdenv.lib; {
description = "Minecraft Server";