2021-11-02 06:29:58 +00:00
|
|
|
# Test a minimal HDFS cluster with no HA
|
2019-12-16 20:43:19 +00:00
|
|
|
import ../make-test-python.nix ({...}: {
|
2018-05-21 02:09:31 +01:00
|
|
|
nodes = {
|
2018-07-20 21:56:59 +01:00
|
|
|
namenode = {pkgs, ...}: {
|
2018-05-21 02:09:31 +01:00
|
|
|
services.hadoop = {
|
2021-10-20 21:33:56 +01:00
|
|
|
package = pkgs.hadoop;
|
2021-11-02 13:04:04 +00:00
|
|
|
hdfs = {
|
|
|
|
namenode = {
|
2021-11-02 16:16:48 +00:00
|
|
|
enable = true;
|
2021-11-02 13:04:04 +00:00
|
|
|
formatOnInit = true;
|
|
|
|
};
|
2021-11-02 16:16:48 +00:00
|
|
|
httpfs.enable = true;
|
2021-11-02 06:29:58 +00:00
|
|
|
};
|
2018-05-21 02:09:31 +01:00
|
|
|
coreSite = {
|
|
|
|
"fs.defaultFS" = "hdfs://namenode:8020";
|
2021-11-02 13:04:04 +00:00
|
|
|
"hadoop.proxyuser.httpfs.groups" = "*";
|
|
|
|
"hadoop.proxyuser.httpfs.hosts" = "*";
|
2018-05-21 02:09:31 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2018-07-20 21:56:59 +01:00
|
|
|
datanode = {pkgs, ...}: {
|
2018-05-21 02:09:31 +01:00
|
|
|
services.hadoop = {
|
2021-10-20 21:33:56 +01:00
|
|
|
package = pkgs.hadoop;
|
2021-11-02 16:16:48 +00:00
|
|
|
hdfs.datanode.enable = true;
|
2018-05-21 02:09:31 +01:00
|
|
|
coreSite = {
|
|
|
|
"fs.defaultFS" = "hdfs://namenode:8020";
|
2021-11-02 13:04:04 +00:00
|
|
|
"hadoop.proxyuser.httpfs.groups" = "*";
|
|
|
|
"hadoop.proxyuser.httpfs.hosts" = "*";
|
2018-05-21 02:09:31 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
testScript = ''
|
2019-12-16 20:43:19 +00:00
|
|
|
start_all()
|
2018-05-21 02:09:31 +01: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)
|
|
|
|
namenode.wait_for_open_port(9870)
|
2018-05-21 02:09:31 +01:00
|
|
|
|
2019-12-16 20:43:19 +00:00
|
|
|
datanode.wait_for_unit("hdfs-datanode")
|
|
|
|
datanode.wait_for_unit("network.target")
|
|
|
|
datanode.wait_for_open_port(9864)
|
|
|
|
datanode.wait_for_open_port(9866)
|
|
|
|
datanode.wait_for_open_port(9867)
|
2018-05-21 02:09:31 +01:00
|
|
|
|
2020-09-16 18:01:10 +01:00
|
|
|
namenode.succeed("curl -f http://namenode:9870")
|
|
|
|
datanode.succeed("curl -f http://datanode:9864")
|
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
|
|
|
|
|
|
|
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 02:09:31 +01:00
|
|
|
'';
|
|
|
|
})
|