test: add config builder test
This commit is contained in:
parent
4b62376743
commit
26eb9af430
36
tests/test_config.py
Normal file
36
tests/test_config.py
Normal file
@ -0,0 +1,36 @@
|
||||
from metis.pkg import inventory, config
|
||||
|
||||
def test_config_build_labels_and_taints():
|
||||
inv = inventory.Inventory(
|
||||
classes=[
|
||||
inventory.NodeClass(
|
||||
Name="c1",
|
||||
Arch="arm64",
|
||||
OS="linux",
|
||||
Image="file:///tmp/base.img",
|
||||
DefaultLabels={"a": "1"},
|
||||
DefaultTaints=["t1"],
|
||||
)
|
||||
],
|
||||
Nodes=[
|
||||
inventory.NodeSpec(
|
||||
Name="n1",
|
||||
Class="c1",
|
||||
Hostname="n1",
|
||||
IP="1.1.1.1",
|
||||
K3sRole="agent",
|
||||
Labels={"b": "2"},
|
||||
Taints=["t2"],
|
||||
LonghornDisks=[inventory.LonghornDisk(Mountpoint="/mnt/d1", UUID="uuid-1", FS="ext4")],
|
||||
SSHUser="ubuntu",
|
||||
SSHAuthorized=["key"],
|
||||
)
|
||||
],
|
||||
)
|
||||
cfg, err = config.Build(inv, "n1")
|
||||
assert err is None
|
||||
assert cfg.Labels == {"a": "1", "b": "2"}
|
||||
assert cfg.Taints == ["t1", "t2"]
|
||||
assert cfg.Fstab[0].Mountpoint == "/mnt/d1"
|
||||
assert cfg.Fstab[0].UUID == "uuid-1"
|
||||
assert cfg.K3s.Role == "agent"
|
||||
Loading…
x
Reference in New Issue
Block a user