37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
|
|
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"
|