ci / derle (push) Successful in 30s
Discovery already saw every node of a Proxmox cluster and placement could put a VM on any of them, but the template, the snippets and a simple SDN zone only worked on PVE_NODE, so a cluster could land where it could not be built. - Setup asks which nodes clusters may use (PVE_NODES; a multi-select in the TUI when Proxmox has more than one). Discovery offers only those. - Heads are placed on PVE_NODE only (head_node), where the template is, so no shared storage is needed; diskless compute nodes spread. - PVE_SDN_ZONE_TYPE (auto|simple|vxlan): more than one node makes the zone vxlan, every node a peer, MTU 1450. A zone of the wrong type is remade only while no cluster has a vnet in it. Guest fabric NICs take the bridge MTU through virtio (mtu = 1). - setup keeps nodes and head_node of its own site in sites.yaml, leaving the rest of the file as the operator wrote it. - verify checks the nodes are online and the zone matches. Run on the simulated Proxmox with the zone forced to vxlan: setup remade the zone, a two-node selftest passed, both compute NICs came up at 1450, and a DF ping of 1422 bytes passed between them while 1423 did not. Two real Proxmox nodes have not been tested. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
54 lines
1.8 KiB
Go
54 lines
1.8 KiB
Go
package proxmox
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/ilkermanap/hpcod/internal/provider"
|
|
)
|
|
|
|
// A Proxmox cluster may be shared with other work. The site offers only the
|
|
// nodes it was given, and says where heads go.
|
|
func TestDiscoverOffersOnlyTheSitesNodes(t *testing.T) {
|
|
routes := map[string]string{
|
|
"/api2/json/nodes": `{"data":[` +
|
|
`{"node":"pve1","status":"online","maxcpu":16,"maxmem":68719476736},` +
|
|
`{"node":"pve2","status":"online","maxcpu":16,"maxmem":68719476736},` +
|
|
`{"node":"db1","status":"online","maxcpu":64,"maxmem":549755813888}]}`,
|
|
"/api2/json/cluster/status": `{"data":[{"type":"cluster","quorate":1}]}`,
|
|
"/api2/json/cluster/resources": `{"data":[]}`,
|
|
}
|
|
for _, n := range []string{"pve1", "pve2", "db1"} {
|
|
routes["/api2/json/nodes/"+n+"/status"] = `{"data":{"cpuinfo":{"model":"Xeon","cpus":16}}}`
|
|
routes["/api2/json/nodes/"+n+"/storage"] = `{"data":[]}`
|
|
}
|
|
p := &Provider{
|
|
id: "lab", cli: testServer(t, routes), skipPCI: true, cpuOvercommit: 1, memOvercommit: 1,
|
|
nodes: map[string]bool{"pve1": true, "pve2": true}, headNode: "pve1",
|
|
}
|
|
site, err := p.Discover(t.Context())
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
var names []string
|
|
for _, n := range site.Nodes {
|
|
names = append(names, n.Name)
|
|
}
|
|
if got := strings.Join(names, ","); got != "pve1,pve2" {
|
|
t.Errorf("nodes = %s, want pve1,pve2: db1 is not this site's", got)
|
|
}
|
|
if site.HeadNode != "pve1" {
|
|
t.Errorf("head node = %q, want pve1", site.HeadNode)
|
|
}
|
|
}
|
|
|
|
func TestHeadNodeMustBeOneOfTheNodes(t *testing.T) {
|
|
_, err := newProvider(provider.SiteConfig{ID: "lab", Settings: map[string]string{
|
|
"endpoint": "https://192.0.2.1:8006", "token": "x!y=z",
|
|
"nodes": "pve2,pve3", "head_node": "pve1",
|
|
}})
|
|
if err == nil || !strings.Contains(err.Error(), "head_node pve1") {
|
|
t.Fatalf("err = %v, want one naming head_node pve1", err)
|
|
}
|
|
}
|