2021-11-02 06:29:58 +00:00
|
|
|
# Test a minimal HDFS cluster with no HA
|
2022-02-27 05:11:05 +00:00
|
|
|
import ../make-test-python.nix ({ package, lib, ... }:
|
|
|
|
{
|
2022-01-08 13:08:34 +00:00
|
|
|
name = "hadoop-hdfs";
|
|
|
|
|
2022-02-27 05:11:05 +00:00
|
|
|
nodes = let
|
|
|
|
coreSite = {
|
|
|
|
"fs.defaultFS" = "hdfs://namenode:8020";
|
|
|
|
"hadoop.proxyuser.httpfs.groups" = "*";
|
|
|
|
"hadoop.proxyuser.httpfs.hosts" = "*";
|
|
|
|
};
|
|
|
|
in {
|
2022-01-08 13:08:34 +00:00
|
|
|
namenode = { pkgs, ... }: {
|
2018-05-21 01:09:31 +00:00
|
|
|
services.hadoop = {
|
2022-01-08 13:08:34 +00:00
|
|
|
inherit package;
|
2021-11-02 13:04:04 +00:00
|
|
|
hdfs = {
|
|
|
|
namenode = {
|
2021-11-02 16:16:48 +00:00
|
|
|
enable = true;
|
2022-01-08 10:49:15 +00:00
|
|
|
openFirewall = true;
|
2021-11-02 13:04:04 +00:00
|
|
|
formatOnInit = true;
|
|
|
|
};
|
2022-01-08 10:49:15 +00:00
|
|
|
httpfs = {
|
2022-02-27 05:11:05 +00:00
|
|
|
# The NixOS hadoop module only support webHDFS on 3.3 and newer
|
2023-04-30 14:26:16 +00:00
|
|
|
enable = lib.mkIf (lib.versionAtLeast package.version "3.3") true;
|
2022-01-08 10:49:15 +00:00
|
|
|
openFirewall = true;
|
|
|
|
};
|
2021-11-02 06:29:58 +00:00
|
|
|
};
|
2022-02-27 05:11:05 +00:00
|
|
|
inherit coreSite;
|
2018-05-21 01:09:31 +00:00
|
|
|
};
|
|
|
|
};
|
2022-01-08 13:08:34 +00:00
|
|
|
datanode = { pkgs, ... }: {
|
2018-05-21 01:09:31 +00:00
|
|
|
services.hadoop = {
|
2022-01-08 13:08:34 +00:00
|
|
|
inherit package;
|
2022-01-08 10:49:15 +00:00
|
|
|
hdfs.datanode = {
|
|
|
|
enable = true;
|
|
|
|
openFirewall = true;
|
2022-03-02 07:20:01 +00:00
|
|
|
dataDirs = [{
|
|
|
|
type = "DISK";
|
|
|
|
path = "/tmp/dn1";
|
|
|
|
}];
|
2022-01-08 10:49:15 +00:00
|
|
|
};
|
2022-02-27 05:11:05 +00:00
|
|
|
inherit coreSite;
|
2018-05-21 01:09:31 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
testScript = ''
|
2019-12-16 20:43:19 +00:00
|
|
|
start_all()
|
2018-05-21 01:09:31 +00:00
|
|
|
|
2019-12-16 20:43:19 +00:00
|
|
|
namenode.wait_for_unit("hdfs-namenode")
|
|
|
|
namenode.wait_for_unit("network.target")
|
|
|
|
namenode.wait_for_open_port(8020)
|
2022-02-27 05:11:05 +00:00
|
|
|
namenode.succeed("ss -tulpne | systemd-cat")
|
|
|
|
namenode.succeed("cat /etc/hadoop*/hdfs-site.xml | systemd-cat")
|
2019-12-16 20:43:19 +00:00
|
|
|
namenode.wait_for_open_port(9870)
|
2018-05-21 01:09:31 +00:00
|
|
|
|
2019-12-16 20:43:19 +00:00
|
|
|
datanode.wait_for_unit("hdfs-datanode")
|
|
|
|
datanode.wait_for_unit("network.target")
|
2023-04-30 14:26:16 +00:00
|
|
|
'' + (if lib.versionAtLeast package.version "3" then ''
|
2019-12-16 20:43:19 +00:00
|
|
|
datanode.wait_for_open_port(9864)
|
|
|
|
datanode.wait_for_open_port(9866)
|
|
|
|
datanode.wait_for_open_port(9867)
|
2018-05-21 01:09:31 +00:00
|
|
|
|
2020-09-16 17:01:10 +00:00
|
|
|
datanode.succeed("curl -f http://datanode:9864")
|
2022-02-27 05:11:05 +00:00
|
|
|
'' else ''
|
|
|
|
datanode.wait_for_open_port(50075)
|
|
|
|
datanode.wait_for_open_port(50010)
|
|
|
|
datanode.wait_for_open_port(50020)
|
|
|
|
|
|
|
|
datanode.succeed("curl -f http://datanode:50075")
|
|
|
|
'' ) + ''
|
|
|
|
namenode.succeed("curl -f http://namenode:9870")
|
2021-11-02 06:29:58 +00:00
|
|
|
|
|
|
|
datanode.succeed("sudo -u hdfs hdfs dfsadmin -safemode wait")
|
|
|
|
datanode.succeed("echo testfilecontents | sudo -u hdfs hdfs dfs -put - /testfile")
|
|
|
|
assert "testfilecontents" in datanode.succeed("sudo -u hdfs hdfs dfs -cat /testfile")
|
2021-11-02 13:04:04 +00:00
|
|
|
|
2023-04-30 14:26:16 +00:00
|
|
|
'' + lib.optionalString (lib.versionAtLeast package.version "3.3" ) ''
|
2021-11-02 13:04:04 +00:00
|
|
|
namenode.wait_for_unit("hdfs-httpfs")
|
|
|
|
namenode.wait_for_open_port(14000)
|
|
|
|
assert "testfilecontents" in datanode.succeed("curl -f \"http://namenode:14000/webhdfs/v1/testfile?user.name=hdfs&op=OPEN\" 2>&1")
|
2018-05-21 01:09:31 +00:00
|
|
|
'';
|
|
|
|
})
|