mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-10-24 04:33:17 +00:00
Keep grouping proof helpers callable and pin admission ambiguity
Rename the parameterised benchmark bridge so Go does not discover it as a benchmark entry point. Preserve the reference's exact-owner keys even for empty internal sets while retaining nonempty hostname-form admission. Pin unique versus ambiguous host attachment in the real monitored-count/prospective-admission path without mutating stored inventory. Contract-Neutral: Test harness correction and faithful internal owner representation only; complete inventory, canonical identity, grouping evidence, counted-system admission and public schemas stay unchanged. Change-source: pulse-maintainer
This commit is contained in:
@@ -691,3 +691,27 @@ func TestBroadcastGroupingMatchesPreviousAlgorithm(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestTopLevelOwnerIndexPreservesAmbiguityInMonitoredCountAndAdmission(t *testing.T) {
|
||||
for _, targetCount := range []int{1, 2} {
|
||||
t.Run(fmt.Sprintf("%d_targets", targetCount), func(t *testing.T) {
|
||||
resources := []Resource{
|
||||
topLevelTestProxmoxNode("platform", "tower.lab", "pve-source", "https://tower.lab:8006"),
|
||||
topLevelTestTrueNAS("nas", "tower.lab"),
|
||||
}
|
||||
registry := NewRegistry(nil)
|
||||
registry.IngestResources(resources[:targetCount])
|
||||
if got := MonitoredSystemCount(registry); got != targetCount {
|
||||
t.Fatalf("counted inventory changed: %d/%d", got, targetCount)
|
||||
}
|
||||
projection := ProjectMonitoredSystemCandidate(registry, MonitoredSystemCandidate{Source: SourceAgent, Type: ResourceTypeAgent, Hostname: "tower", AgentID: "new-agent"})
|
||||
additional := targetCount - 1
|
||||
if projection.CurrentCount != targetCount || projection.AdditionalCount != additional || projection.ProjectedCount != targetCount+additional {
|
||||
t.Fatalf("unique attachment/ambiguous admission changed: %+v", projection)
|
||||
}
|
||||
if got := len(registry.List()); got != targetCount {
|
||||
t.Fatalf("read-only projection changed stored inventory: %d/%d", got, targetCount)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -310,7 +310,7 @@ func CheckTopLevelOwnerIndexResourcesForTest(t testing.TB, resources []Resource)
|
||||
t.Logf("connected grouping retains %d resources in %d groups with byte-equal records", members, got.Count())
|
||||
}
|
||||
|
||||
func BenchmarkTopLevelOwnerIndexResourcesForTest(b *testing.B, resources []Resource) {
|
||||
func RunTopLevelOwnerIndexBenchmarkForTest(b *testing.B, resources []Resource) {
|
||||
for _, method := range []struct {
|
||||
name string
|
||||
resolve func([]Resource) TopLevelSystemResolver
|
||||
|
||||
@@ -58,5 +58,5 @@ func TestTopLevelOwnerIndexConnectedDemo(t *testing.T) {
|
||||
|
||||
func BenchmarkTopLevelOwnerIndexConnectedDemo(b *testing.B) {
|
||||
resources := connectedOwnerIndexResources(b)
|
||||
unified.BenchmarkTopLevelOwnerIndexResourcesForTest(b, resources)
|
||||
unified.RunTopLevelOwnerIndexBenchmarkForTest(b, resources)
|
||||
}
|
||||
|
||||
@@ -433,9 +433,6 @@ func buildTopLevelSystemFallbackIndex(groups map[int]topLevelSystemResolvedGroup
|
||||
return roots[i] < roots[j]
|
||||
})
|
||||
add := func(owners map[string][]int, key string, root int) {
|
||||
if key == "" {
|
||||
return
|
||||
}
|
||||
bucket := owners[key]
|
||||
// All aliases of one root are added together, so a last-entry check
|
||||
// deduplicates its comparable/short forms without a per-key set.
|
||||
@@ -448,9 +445,11 @@ func buildTopLevelSystemFallbackIndex(groups map[int]topLevelSystemResolvedGroup
|
||||
for host := range group.exactHosts {
|
||||
add(index.hosts, host, root)
|
||||
comparable := normalizeComparableHostname(host)
|
||||
add(index.hostForms, comparable, root)
|
||||
if comparable != "" {
|
||||
add(index.hostForms, NormalizeHostname(comparable), root)
|
||||
add(index.hostForms, comparable, root)
|
||||
if short := NormalizeHostname(comparable); short != "" {
|
||||
add(index.hostForms, short, root)
|
||||
}
|
||||
}
|
||||
}
|
||||
for ip := range group.exactIPs {
|
||||
|
||||
Reference in New Issue
Block a user