test(agent): cover stripe, mixed, and special-vdev pool_type classification
This commit is contained in:
parent
e763ea96bd
commit
041dfc8fc0
1 changed files with 51 additions and 0 deletions
|
|
@ -53,6 +53,57 @@ defmodule ProxmoxAgent.Collectors.ZfsTest do
|
||||||
assert sample.pools == []
|
assert sample.pools == []
|
||||||
assert length(sample.errors) >= 1
|
assert length(sample.errors) >= 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "classifies pool_type for stripe, mixed, and special vdevs" do
|
||||||
|
list_json =
|
||||||
|
Jason.encode!(%{
|
||||||
|
"pools" => %{
|
||||||
|
"stripe" => %{"name" => "stripe", "size" => 1, "alloc" => 0, "free" => 1,
|
||||||
|
"frag" => 0, "cap" => 0, "health" => "ONLINE"},
|
||||||
|
"mixed" => %{"name" => "mixed", "size" => 1, "alloc" => 0, "free" => 1,
|
||||||
|
"frag" => 0, "cap" => 0, "health" => "ONLINE"},
|
||||||
|
"mirror_with_log" => %{"name" => "mirror_with_log", "size" => 1, "alloc" => 0, "free" => 1,
|
||||||
|
"frag" => 0, "cap" => 0, "health" => "ONLINE"}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
vdev = fn name, type ->
|
||||||
|
{name, %{"name" => name, "vdev_type" => type, "state" => "ONLINE",
|
||||||
|
"read_errors" => "0", "write_errors" => "0", "checksum_errors" => "0"}}
|
||||||
|
end
|
||||||
|
|
||||||
|
status_json =
|
||||||
|
Jason.encode!(%{
|
||||||
|
"pools" => %{
|
||||||
|
"stripe" => %{
|
||||||
|
"name" => "stripe", "state" => "ONLINE", "error_count" => "0",
|
||||||
|
"vdevs" => Map.new([vdev.("sda", "disk"), vdev.("sdb", "disk")])
|
||||||
|
},
|
||||||
|
"mixed" => %{
|
||||||
|
"name" => "mixed", "state" => "ONLINE", "error_count" => "0",
|
||||||
|
"vdevs" => Map.new([vdev.("mirror-0", "mirror"), vdev.("raidz1-1", "raidz1")])
|
||||||
|
},
|
||||||
|
"mirror_with_log" => %{
|
||||||
|
"name" => "mirror_with_log", "state" => "ONLINE", "error_count" => "0",
|
||||||
|
"vdevs" => Map.new([vdev.("mirror-0", "mirror"), vdev.("log-0", "log")])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
runner = fn
|
||||||
|
"zpool", ["list" | _] -> {:ok, list_json}
|
||||||
|
"zpool", ["status" | _] -> {:ok, status_json}
|
||||||
|
end
|
||||||
|
|
||||||
|
sample = Zfs.collect_pools(runner: runner)
|
||||||
|
by_name = Map.new(sample.pools, &{&1.name, &1})
|
||||||
|
|
||||||
|
assert by_name["stripe"].pool_type == "stripe"
|
||||||
|
assert by_name["mixed"].pool_type == "mixed"
|
||||||
|
assert by_name["mirror_with_log"].pool_type == "mirror"
|
||||||
|
# log vdev is retained in the per-pool vdevs list even though it's ignored for layout classification
|
||||||
|
assert Enum.any?(by_name["mirror_with_log"].vdevs, &(&1.type == "log"))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "collect_datasets/1" do
|
describe "collect_datasets/1" do
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue