Merge pull request #20770 from mguentner/more_ipfs
services: IPFS: add test and more config parameters
This commit is contained in:
commit
69bee1b361
|
@ -47,6 +47,18 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
gatewayAddress = mkOption {
|
||||
type = types.str;
|
||||
default = "/ip4/127.0.0.1/tcp/8080";
|
||||
description = "Where the IPFS Gateway can be reached";
|
||||
};
|
||||
|
||||
apiAddress = mkOption {
|
||||
type = types.str;
|
||||
default = "/ip4/127.0.0.1/tcp/5001";
|
||||
description = "Where IPFS exposes its API to";
|
||||
};
|
||||
|
||||
enableGC = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
|
@ -98,6 +110,8 @@ in
|
|||
cd ${cfg.dataDir}
|
||||
${pkgs.su}/bin/su -s ${pkgs.bash}/bin/sh ${cfg.user} -c "${ipfs}/bin/ipfs init"
|
||||
fi
|
||||
${pkgs.su}/bin/su -s ${pkgs.bash}/bin/sh ${cfg.user} -c "${ipfs}/bin/ipfs config Addresses.API ${cfg.apiAddress}"
|
||||
${pkgs.su}/bin/su -s ${pkgs.bash}/bin/sh ${cfg.user} -c "${ipfs}/bin/ipfs config Addresses.Gateway ${cfg.gatewayAddress}"
|
||||
'';
|
||||
|
||||
serviceConfig = {
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
|
||||
import ./make-test.nix ({ pkgs, ...} : {
|
||||
name = "ipfs";
|
||||
meta = with pkgs.stdenv.lib.maintainers; {
|
||||
maintainers = [ mguentner ];
|
||||
};
|
||||
|
||||
nodes = {
|
||||
adder =
|
||||
{ config, pkgs, ... }:
|
||||
{
|
||||
services.ipfs = {
|
||||
enable = true;
|
||||
gatewayAddress = "/ip4/127.0.0.1/tcp/2323";
|
||||
apiAddress = "/ip4/127.0.0.1/tcp/2324";
|
||||
};
|
||||
};
|
||||
getter =
|
||||
{ config, pkgs, ... }:
|
||||
{
|
||||
services.ipfs.enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
startAll;
|
||||
$adder->waitForUnit("ipfs");
|
||||
# * => needs ipfs dht (internet)
|
||||
# $getter->waitForUnit("ipfs");
|
||||
$adder->waitUntilSucceeds("ipfs --api /ip4/127.0.0.1/tcp/2324 id");
|
||||
$adder->mustSucceed("([[ -n '$(ipfs --api /ip4/127.0.0.1/tcp/2324 config Addresses.gatewayAddress | grep /ip4/127.0.0.1/tcp/2323)' ]])");
|
||||
# * $getter->waitUntilSucceeds("ipfs --api /ip4/127.0.0.1/tcp/5001 id");
|
||||
# * my $ipfsHash = $adder->mustSucceed("echo fnord | ipfs --api /ip4/127.0.0.1/tcp/2324 add | cut -d' ' -f2");
|
||||
$adder->mustSucceed("([[ -n '$(echo fnord | ipfs --api /ip4/127.0.0.1/tcp/2324 add | grep added)' ]])");
|
||||
# * $getter->mustSucceed("ipfs --api /ip4/127.0.0.1/tcp/5001 cat $ipfsHash");
|
||||
'';
|
||||
})
|
Loading…
Reference in New Issue