mirror of
https://github.com/weaveworks/scope.git
synced 2026-05-06 01:08:03 +00:00
performance: Update plugins to new-style controls data
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user