feat(agent): system info collector for pveversion/zfs/apt
This commit is contained in:
parent
da5ed6cd08
commit
61fa959d52
5 changed files with 89 additions and 0 deletions
38
agent/test/proxmox_agent/collectors/system_info_test.exs
Normal file
38
agent/test/proxmox_agent/collectors/system_info_test.exs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
defmodule ProxmoxAgent.Collectors.SystemInfoTest do
|
||||
use ExUnit.Case, async: true
|
||||
|
||||
alias ProxmoxAgent.Collectors.SystemInfo
|
||||
|
||||
@fixtures Path.expand("../../fixtures/system", __DIR__)
|
||||
|
||||
defp fake_runner do
|
||||
fn
|
||||
"pveversion", [] -> {:ok, File.read!(Path.join(@fixtures, "pveversion.txt"))}
|
||||
"zfs", ["--version"] -> {:ok, File.read!(Path.join(@fixtures, "zfs_version.txt"))}
|
||||
"apt", ["list", "--upgradable"] -> {:ok, File.read!(Path.join(@fixtures, "apt_upgradable.txt"))}
|
||||
end
|
||||
end
|
||||
|
||||
test "collects pveversion, zfs version and pending upgrade count" do
|
||||
sample = SystemInfo.collect(runner: fake_runner())
|
||||
|
||||
assert sample.pve_version =~ "pve-manager/8.3.1"
|
||||
assert sample.zfs_version =~ "2.3.0"
|
||||
assert sample.pending_updates == 2
|
||||
assert sample.errors == []
|
||||
end
|
||||
|
||||
test "partial sample when one command fails" do
|
||||
partial = fn
|
||||
"pveversion", [] -> {:ok, "pve-manager/8.3.1/abc (running kernel: 6.8.12-1-pve)\n"}
|
||||
"zfs", ["--version"] -> {:error, {:enoent, "zfs"}}
|
||||
"apt", ["list", "--upgradable"] -> {:ok, "Listing...\n"}
|
||||
end
|
||||
|
||||
sample = SystemInfo.collect(runner: partial)
|
||||
assert sample.pve_version =~ "8.3.1"
|
||||
assert sample.zfs_version == nil
|
||||
assert sample.pending_updates == 0
|
||||
assert length(sample.errors) == 1
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue