mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-11 20:25:32 +03:00

* nixosTests.tusd: Fix network race condition
Fixes error:
client # curl: (7) Failed to connect to server port 1080 after 8 ms: Could not connect to server
client # [ 5.621267] network-addresses-eth1-start[795]: adding address 192.168.1.1/24... done
* tusd: embed version in binary
Currently, tusd reports 'n/a' when its version is queried using `tusd -version`.
This change embeds the current version during the build process, so it correctly
reports the value.
See 8e66333a01/scripts/build_funcs.sh (L20)
---------
Co-authored-by: Niklas Hambüchen <mail@nh2.me>
51 lines
1 KiB
Nix
51 lines
1 KiB
Nix
{ pkgs, lib, ... }:
|
|
|
|
let
|
|
port = 1080;
|
|
|
|
client =
|
|
{ pkgs, ... }:
|
|
{
|
|
environment.systemPackages = [ pkgs.curl ];
|
|
};
|
|
|
|
server =
|
|
{ pkgs, ... }:
|
|
{
|
|
# tusd does not have a NixOS service yet.
|
|
systemd.services.tusd = {
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
|
ExecStart = ''${pkgs.tusd}/bin/tusd -port "${toString port}" -upload-dir=/data'';
|
|
};
|
|
};
|
|
networking.firewall.allowedTCPPorts = [ port ];
|
|
};
|
|
in
|
|
{
|
|
name = "tusd";
|
|
meta.maintainers = with lib.maintainers; [
|
|
nh2
|
|
kalbasit
|
|
];
|
|
|
|
nodes = {
|
|
inherit server;
|
|
inherit client;
|
|
};
|
|
|
|
testScript = ''
|
|
server.wait_for_unit("tusd.service")
|
|
server.wait_for_open_port(${toString port})
|
|
|
|
# Create large file.
|
|
client.succeed("${pkgs.coreutils}/bin/truncate --size=100M file-100M.bin")
|
|
|
|
# Upload it.
|
|
client.wait_for_unit("network.target")
|
|
client.succeed("${./tus-curl-upload.sh} file-100M.bin http://server:${toString port}/files/")
|
|
|
|
print("Upload succeeded")
|
|
'';
|
|
}
|