func testCleanup(t *testing.T, g *graph.Graph, cmds []string, ints []string) { // cleanup side on the test testPassed := false onChange := func(ws *websocket.Conn) { g.Lock() defer g.Unlock() if !testPassed { clean := true for _, intf := range ints { n := g.LookupFirstNode(graph.Metadatas{"Name": intf}) if n != nil { clean = false break } } if clean { testPassed = true ws.Close() } } } testTopology(t, g, cmds, onChange) if !testPassed { t.Error("test not executed or failed") } }
func LookupNodeFromNodePathString(g *graph.Graph, s string) *graph.Node { parts := strings.Split(s, "/") m, err := nodePathPartToMetadata(parts[0]) if err != nil { logging.GetLogger().Errorf("Unable to parse a part of node path string (%s): %s", parts[0], err.Error()) return nil } node := g.LookupFirstNode(m) if node == nil { return nil } for _, part := range parts[1:] { m, err := nodePathPartToMetadata(part) if err != nil { return nil } node = g.LookupFirstChild(node, m) if node == nil { return nil } } return node }