-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nixos/tests/peertube: add test for plugins
Co-authored-by: a-kenji <[email protected]>
- Loading branch information
Showing
5 changed files
with
95 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
nixos/tests/web-apps/peertube.nix → nixos/tests/web-apps/peertube/base.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ system ? builtins.currentSystem | ||
, pkgs ? import ../../../.. { inherit system; } | ||
}: | ||
{ | ||
base = import ./base.nix { inherit system pkgs; }; | ||
plugins = import ./plugins.nix { inherit system pkgs; }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import ../../make-test-python.nix ({ pkgs, ... }: { | ||
name = "peertube-plugins"; | ||
meta.maintainers = with pkgs.lib.maintainers; [ a-kenji sbruder ]; | ||
|
||
nodes = { | ||
server = { lib, pkgs, ... }: { | ||
services.peertube = { | ||
enable = true; | ||
localDomain = "peertube.local"; | ||
enableWebHttps = false; | ||
|
||
database.createLocally = true; | ||
redis.createLocally = true; | ||
|
||
plugins = with pkgs.peertube.plugins; [ | ||
peertube-plugin-hello-world | ||
]; | ||
}; | ||
specialisation = { | ||
no-plugins.configuration = { | ||
services.peertube.plugins = lib.mkForce [ ]; | ||
}; | ||
}; | ||
}; | ||
}; | ||
|
||
testScript = { nodes, ... }: '' | ||
import json | ||
import re | ||
def get_config(): | ||
content = server.succeed("curl --fail http://localhost:9000/") | ||
return json.loads( | ||
json.loads( | ||
'"' | ||
+ re.search( | ||
r'<script type="application\/javascript">window.PeerTubeServerConfig = "(.*?)"<\/script>', | ||
content, | ||
).group(1) | ||
+ '"' | ||
) | ||
) | ||
server.start() | ||
# This waits for the peertube service starting, | ||
# getting stopped by the plugin provisioning script | ||
# and starting again. | ||
server.wait_for_open_port(9000) | ||
server.wait_for_closed_port(9000) | ||
server.wait_for_open_port(9000) | ||
config = get_config() | ||
plugins = config["plugin"]["registered"] | ||
assert len(plugins) == 1 | ||
hello_world_plugin = plugins[0] | ||
assert hello_world_plugin["npmName"] == "peertube-plugin-hello-world" | ||
assert ( | ||
hello_world_plugin["version"] | ||
== "${pkgs.peertube.plugins.peertube-plugin-hello-world.version}" | ||
) | ||
client_scripts = [ | ||
f'http://localhost:9000/plugins/hello-world/{hello_world_plugin["version"]}/client-scripts/{script["script"]}' | ||
for script in hello_world_plugin["clientScripts"].values() | ||
] | ||
server.succeed(f"curl --fail {client_scripts[0]}") | ||
server.succeed( | ||
"${nodes.server.config.system.build.toplevel}/specialisation/no-plugins/bin/switch-to-configuration test >&2" | ||
) | ||
# This again waits for peertube to be restarted | ||
server.wait_for_closed_port(9000) | ||
server.wait_for_open_port(9000) | ||
config = get_config() | ||
assert len(config["plugin"]["registered"]) == 0 | ||
''; | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters