performance: Update plugins to new-style controls data

This commit is contained in:
Bryan Boreham
2019-10-14 17:40:24 +00:00
parent 0b641b1848
commit e1bfa01cae
2 changed files with 8 additions and 13 deletions

View File

@@ -252,8 +252,8 @@ func (r *Registry) updateAndGetControlsInTopology(pluginID string, topology *rep
for name, node := range topology.Nodes {
log.Debugf("plugins: checking node controls in node %s of %s", name, topology.Label)
newNode := node.WithID(name)
newLatestControls := report.MakeNodeControlDataLatestMap()
node.LatestControls.ForEach(func(controlID string, ts time.Time, data report.NodeControlData) {
newLatestControls := []string{}
for _, controlID := range node.ActiveControls() {
log.Debugf("plugins: got node control %s", controlID)
newControlID := ""
if _, found := topology.Controls[controlID]; !found {
@@ -263,9 +263,9 @@ func (r *Registry) updateAndGetControlsInTopology(pluginID string, topology *rep
newControlID = fakeControlID(pluginID, controlID)
log.Debugf("plugins: will replace node control %s with %s", controlID, newControlID)
}
newLatestControls = newLatestControls.Set(newControlID, ts, data)
})
newNode.LatestControls = newLatestControls
newLatestControls = append(newLatestControls, newControlID)
}
newNode = newNode.WithLatestActiveControls(newLatestControls...)
newNodes[newNode.ID] = newNode
}
topology.Controls = newControls

View File

@@ -627,14 +627,9 @@ func checkControls(t *testing.T, topology report.Topology, expectedControls, exp
if !found {
t.Fatalf("expected a node %s in a topology", nodeID)
}
actualNodeControls := []string{}
node.LatestControls.ForEach(func(controlID string, _ time.Time, _ report.NodeControlData) {
actualNodeControls = append(actualNodeControls, controlID)
})
nodeControlsSet := report.MakeStringSet(expectedNodeControls...)
actualNodeControlsSet := report.MakeStringSet(actualNodeControls...)
if !reflect.DeepEqual(nodeControlsSet, actualNodeControlsSet) {
t.Fatalf("node controls in node %s in topology %s are not equal:\n%s", nodeID, topology.Label, test.Diff(nodeControlsSet, actualNodeControlsSet))
actualNodeControls := node.ActiveControls()
if !reflect.DeepEqual(expectedNodeControls, actualNodeControls) {
t.Fatalf("node controls in node %s in topology %s are not equal:\n%s", nodeID, topology.Label, test.Diff(expectedNodeControls, actualNodeControls))
}
}