nixpkgs/nixos/tests/web-apps/peertube.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

150 lines
3.9 KiB
Nix
Raw Normal View History

2021-05-31 13:23:06 +02:00
import ../make-test-python.nix ({pkgs, ...}:
{
name = "peertube";
meta.maintainers = with pkgs.lib.maintainers; [ izorkin ];
nodes = {
database = {
networking = {
interfaces.eth1 = {
ipv4.addresses = [
{ address = "192.168.2.10"; prefixLength = 24; }
];
};
2022-02-26 17:09:18 +01:00
firewall.allowedTCPPorts = [ 5432 31638 ];
2021-05-31 13:23:06 +02:00
};
services.postgresql = {
enable = true;
enableTCPIP = true;
ensureDatabases = [ "peertube_test" ];
ensureUsers = [
{
name = "peertube_test";
ensureDBOwnership = true;
}
];
2021-05-31 13:23:06 +02:00
authentication = ''
hostnossl peertube_test peertube_test 192.168.2.11/32 md5
2021-05-31 13:23:06 +02:00
'';
initialScript = pkgs.writeText "postgresql_init.sql" ''
CREATE ROLE peertube_test LOGIN PASSWORD '0gUN0C1mgST6czvjZ8T9';
'';
};
2022-02-16 20:16:32 +01:00
services.redis.servers.peertube = {
2021-05-31 13:23:06 +02:00
enable = true;
bind = "0.0.0.0";
requirePass = "turrQfaQwnanGbcsdhxy";
2022-02-26 17:09:18 +01:00
port = 31638;
2021-05-31 13:23:06 +02:00
};
};
server = { pkgs, ... }: {
environment = {
etc = {
"peertube/password-init-root".text = ''
PT_INITIAL_ROOT_PASSWORD=zw4SqYVdcsXUfRX8aaFX
'';
2022-12-13 20:07:10 +01:00
"peertube/secrets-peertube".text = ''
063d9c60d519597acef26003d5ecc32729083965d09181ef3949200cbe5f09ee
'';
2021-05-31 13:23:06 +02:00
"peertube/password-posgressql-db".text = ''
0gUN0C1mgST6czvjZ8T9
'';
"peertube/password-redis-db".text = ''
turrQfaQwnanGbcsdhxy
'';
};
};
networking = {
interfaces.eth1 = {
ipv4.addresses = [
{ address = "192.168.2.11"; prefixLength = 24; }
];
};
extraHosts = ''
192.168.2.11 peertube.local
'';
firewall.allowedTCPPorts = [ 9000 ];
};
services.peertube = {
enable = true;
localDomain = "peertube.local";
enableWebHttps = false;
serviceEnvironmentFile = "/etc/peertube/password-init-root";
2022-12-13 20:07:10 +01:00
secrets = {
secretsFile = "/etc/peertube/secrets-peertube";
};
2021-05-31 13:23:06 +02:00
database = {
host = "192.168.2.10";
name = "peertube_test";
2021-05-31 13:23:06 +02:00
user = "peertube_test";
passwordFile = "/etc/peertube/password-posgressql-db";
};
redis = {
host = "192.168.2.10";
2022-02-26 17:09:18 +01:00
port = 31638;
2021-05-31 13:23:06 +02:00
passwordFile = "/etc/peertube/password-redis-db";
};
settings = {
listen = {
hostname = "0.0.0.0";
};
instance = {
name = "PeerTube Test Server";
};
};
};
};
client = {
environment.systemPackages = [ pkgs.jq pkgs.peertube.cli ];
2021-05-31 13:23:06 +02:00
networking = {
interfaces.eth1 = {
ipv4.addresses = [
{ address = "192.168.2.12"; prefixLength = 24; }
];
};
extraHosts = ''
192.168.2.11 peertube.local
'';
};
};
};
testScript = ''
start_all()
database.wait_for_unit("postgresql.service")
2022-02-16 20:16:32 +01:00
database.wait_for_unit("redis-peertube.service")
2021-05-31 13:23:06 +02:00
database.wait_for_open_port(5432)
2022-02-26 17:09:18 +01:00
database.wait_for_open_port(31638)
2021-05-31 13:23:06 +02:00
server.wait_for_unit("peertube.service")
server.wait_for_open_port(9000)
# Check if PeerTube is running
client.succeed("curl --fail http://peertube.local:9000/api/v1/config/about | jq -r '.instance.name' | grep 'PeerTube\ Test\ Server'")
# Check PeerTube CLI version
client.succeed('peertube-cli auth add -u "http://peertube.local:9000" -U "root" --password "zw4SqYVdcsXUfRX8aaFX"')
client.succeed('peertube-cli auth list | grep "http://peertube.local:9000"')
client.succeed('peertube-cli auth del "http://peertube.local:9000"')
client.fail('peertube-cli auth list | grep "http://peertube.local:9000"')
2021-05-31 13:23:06 +02:00
client.shutdown()
server.shutdown()
database.shutdown()
'';
})