Debian Codegraph @

engine/graph/autogroup/autogroup_test.go

raw symbols SCIP
1 // Mgmt
2 // Copyright (C) 2013-2024+ James Shubin and the project contributors
3 // Written by James Shubin <[email protected]> and the project contributors
4 //
5 // This program is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program. If not, see <https://www.gnu.org/licenses/>.
17 //
18 // Additional permission under GNU GPL version 3 section 7
19 //
20 // If you modify this program, or any covered work, by linking or combining it
21 // with embedded mcl code and modules (and that the embedded mcl code and
22 // modules which link with this program, contain a copy of their source code in
23 // the authoritative form) containing parts covered by the terms of any other
24 // license, the licensors of this program grant you additional permission to
25 // convey the resulting work. Furthermore, the licensors of this program grant
26 // the original author, James Shubin, additional permission to update this
27 // additional permission if he deems it necessary to achieve the goals of this
28 // additional permission.
29
30 //go:build !root
31
32 package autogroupscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/
33
34 import (
35 "contextscip-go gomod github.com/golang/go/src go1.21 context/"
36 "fmtscip-go gomod github.com/golang/go/src go1.21 fmt/"
37 "reflectscip-go gomod github.com/golang/go/src go1.21 reflect/"
38 "sortscip-go gomod github.com/golang/go/src go1.21 sort/"
39 "stringsscip-go gomod github.com/golang/go/src go1.21 strings/"
40 "testingscip-go gomod github.com/golang/go/src go1.21 testing/"
41 "timescip-go gomod github.com/golang/go/src go1.21 time/"
42
43 "github.com/purpleidea/mgmt/enginescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/"
44 "github.com/purpleidea/mgmt/engine/traitsscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/traits`/"
45 "github.com/purpleidea/mgmt/pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/"
46 "github.com/purpleidea/mgmt/utilscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/util`/"
47 "github.com/purpleidea/mgmt/util/errwrapscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/util/errwrap`/"
48 )
49
50 func initscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/init().() {
51 enginescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/.RegisterResourcescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/RegisterResource().("nooptest", func() enginescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/.Resscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/Res# { return &NoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NoopResTest#{} })
52 }
53
54 // NoopResTest is a no-op resource that groups strangely.
55 type NoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NoopResTest# struct {
56 traitsscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/traits`/.Basescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NoopResTest#Base. // add the base methods without re-implementation
57 traitsscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/traits`/.Groupablescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NoopResTest#Groupable.
58
59 initscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NoopResTest#init. *enginescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/.Initscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/Init#
60
61 Commentscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NoopResTest#Comment. string
62 }
63
64 func (obj *NoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NoopResTest#) Defaultscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NoopResTest#Default().() enginescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/.Resscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/Res# {
65 return &NoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NoopResTest#{}
66 }
67
68 func (obj *NoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NoopResTest#) Validatescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NoopResTest#Validate().() error {
69 return nil
70 }
71
72 func (obj *NoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NoopResTest#) Initscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NoopResTest#Init().(init *enginescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/.Initscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/Init#) error {
73 obj.initscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NoopResTest#init. = init // save for later
74
75 return nil
76 }
77
78 func (obj *NoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NoopResTest#) Cleanupscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NoopResTest#Cleanup().() error {
79 return nil
80 }
81
82 func (obj *NoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NoopResTest#) Watchscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NoopResTest#Watch().(contextscip-go gomod github.com/golang/go/src go1.21 context/.Contextscip-go gomod github.com/golang/go/src go1.21 context/Context#) error {
83 return nil // not needed
84 }
85
86 func (obj *NoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NoopResTest#) CheckApplyscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NoopResTest#CheckApply().(ctx contextscip-go gomod github.com/golang/go/src go1.21 context/.Contextscip-go gomod github.com/golang/go/src go1.21 context/Context#, apply bool) (checkOK bool, err error) {
87 return true, nil // state is always okay
88 }
89
90 func (obj *NoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NoopResTest#) Cmpscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NoopResTest#Cmp().(r enginescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/.Resscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/Res#) error {
91 // we can only compare NoopRes to others of the same resource kind
92 res, ok := r.(*NoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NoopResTest#)
93 if !ok {
94 return fmtscip-go gomod github.com/golang/go/src go1.21 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.21 fmt/Errorf().("not a %s", obj.Kindscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/traits`/Kinded#Kind().())
95 }
96
97 if obj.Commentscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NoopResTest#Comment. != res.Commentscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NoopResTest#Comment. {
98 return fmtscip-go gomod github.com/golang/go/src go1.21 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.21 fmt/Errorf().("comment differs")
99 }
100
101 return nil
102 }
103
104 func (obj *NoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NoopResTest#) GroupCmpscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NoopResTest#GroupCmp().(r enginescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/.GroupableResscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/GroupableRes#) error {
105 res, ok := r.(*NoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NoopResTest#)
106 if !ok {
107 return fmtscip-go gomod github.com/golang/go/src go1.21 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.21 fmt/Errorf().("resource is not the same kind")
108 }
109
110 // TODO: implement this in vertexCmp for *testGrouper instead?
111 if stringsscip-go gomod github.com/golang/go/src go1.21 strings/.Containsscip-go gomod github.com/golang/go/src go1.21 strings/Contains().(res.Namescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/traits`/Named#Name().(), ",") { // HACK
112 return fmtscip-go gomod github.com/golang/go/src go1.21 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.21 fmt/Errorf().("already grouped") // element to be grouped is already grouped!
113 }
114
115 // group if they start with the same letter! (helpful hack for testing)
116 if obj.Namescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/traits`/Named#Name().()[0] != res.Namescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/traits`/Named#Name().()[0] {
117 return fmtscip-go gomod github.com/golang/go/src go1.21 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.21 fmt/Errorf().("different starting letter")
118 }
119 return nil
120 }
121
122 func NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().(name string) *NoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NoopResTest# {
123 n, err := enginescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/.NewNamedResourcescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/NewNamedResource().("nooptest", name)
124 if err != nil {
125 panic(fmtscip-go gomod github.com/golang/go/src go1.21 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.21 fmt/Sprintf().("unexpected error: %+v", err))
126 }
127
128 //x := n.(*resources.NoopRes)
129 g, ok := n.(enginescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/.GroupableResscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/GroupableRes#)
130 if !ok {
131 panic("not a GroupableRes")
132 }
133 g.AutoGroupMetascip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/GroupableRes#AutoGroupMeta.().Disabledscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/AutoGroupMeta#Disabled. = false // always autogroup
134
135 //x := g.(*NoopResTest)
136 x := n.(*NoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NoopResTest#)
137
138 return x
139 }
140
141 func NewNoopResTestSemascip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTestSema().(name string, semas []string) *NoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NoopResTest# {
142 n := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().(name)
143 n.MetaParamsscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/traits`/Meta#MetaParams().().Semascip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/MetaParams#Sema. = semas
144 return n
145 }
146
147 // NE is a helper function to make testing easier. It creates a new noop edge.
148 func NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().(s string) pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.Edgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Edge# {
149 obj := &enginescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/.Edgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/Edge#{Namescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/Edge#Name.: s}
150 return obj
151 }
152
153 type testGrouperscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/testGrouper# struct {
154 // TODO: this algorithm may not be correct in all cases. replace if needed!
155 NonReachabilityGrouperscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/testGrouper#NonReachabilityGrouper. // "inherit" what we want, and reimplement the rest
156 }
157
158 func (obj *testGrouperscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/testGrouper#) Namescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/testGrouper#Name().() string {
159 return "testGrouper"
160 }
161
162 func (obj *testGrouperscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/testGrouper#) VertexCmpscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/testGrouper#VertexCmp().(v1, v2 pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.Vertexscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Vertex#) error {
163 // call existing vertexCmp first
164 if err := obj.NonReachabilityGrouperscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/testGrouper#NonReachabilityGrouper..VertexCmpscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/baseGrouper#VertexCmp().(v1, v2); err != nil {
165 return err
166 }
167
168 r1, ok := v1.(enginescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/.GroupableResscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/GroupableRes#)
169 if !ok {
170 return fmtscip-go gomod github.com/golang/go/src go1.21 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.21 fmt/Errorf().("v1 is not a GroupableRes")
171 }
172 r2, ok := v2.(enginescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/.GroupableResscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/GroupableRes#)
173 if !ok {
174 return fmtscip-go gomod github.com/golang/go/src go1.21 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.21 fmt/Errorf().("v2 is not a GroupableRes")
175 }
176
177 if r1.Kindscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/KindedRes#Kind.() != r2.Kindscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/KindedRes#Kind.() { // we must group similar kinds
178 // TODO: maybe future resources won't need this limitation?
179 return fmtscip-go gomod github.com/golang/go/src go1.21 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.21 fmt/Errorf().("the two resources aren't the same kind")
180 }
181 // someone doesn't want to group!
182 if r1.AutoGroupMetascip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/GroupableRes#AutoGroupMeta.().Disabledscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/AutoGroupMeta#Disabled. || r2.AutoGroupMetascip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/GroupableRes#AutoGroupMeta.().Disabledscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/AutoGroupMeta#Disabled. {
183 return fmtscip-go gomod github.com/golang/go/src go1.21 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.21 fmt/Errorf().("one of the autogroup flags is false")
184 }
185
186 if r1.IsGroupedscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/GroupableRes#IsGrouped.() { // already grouped!
187 return fmtscip-go gomod github.com/golang/go/src go1.21 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.21 fmt/Errorf().("already grouped")
188 }
189 if len(r2.GetGroupscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/GroupableRes#GetGroup.()) > 0 { // already has children grouped!
190 return fmtscip-go gomod github.com/golang/go/src go1.21 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.21 fmt/Errorf().("already has groups")
191 }
192 if err := r1.GroupCmpscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/GroupableRes#GroupCmp.(r2); err != nil { // resource groupcmp failed!
193 return errwrapscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/util/errwrap`/.Wrapfscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/util/errwrap`/Wrapf().(err, "the GroupCmp failed")
194 }
195
196 return nil
197 }
198
199 func (obj *testGrouperscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/testGrouper#) VertexMergescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/testGrouper#VertexMerge().(v1, v2 pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.Vertexscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Vertex#) (v pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.Vertexscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Vertex#, err error) {
200 r1 := v1.(enginescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/.GroupableResscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/GroupableRes#)
201 r2 := v2.(enginescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/.GroupableResscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/GroupableRes#)
202 if err := r1.GroupResscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/GroupableRes#GroupRes.(r2); err != nil { // group them first
203 return nil, err
204 }
205 r2.SetParentscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/GroupableRes#SetParent.(r1) // store who my parent is
206
207 // HACK: update the name so it matches full list of self+grouped
208 res := v1.(enginescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/.GroupableResscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/GroupableRes#)
209 names := stringsscip-go gomod github.com/golang/go/src go1.21 strings/.Splitscip-go gomod github.com/golang/go/src go1.21 strings/Split().(res.Namescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/NamedRes#Name.(), ",") // load in stored names
210 for _, n := range res.GetGroupscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/GroupableRes#GetGroup.() {
211 names = append(names, n.Namescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/NamedRes#Name.()) // add my contents
212 }
213 names = utilscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/util`/.StrRemoveDuplicatesInListscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/util`/StrRemoveDuplicatesInList().(names) // remove duplicates
214 sortscip-go gomod github.com/golang/go/src go1.21 sort/.Stringsscip-go gomod github.com/golang/go/src go1.21 sort/Strings().(names)
215 res.SetNamescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/NamedRes#SetName.(stringsscip-go gomod github.com/golang/go/src go1.21 strings/.Joinscip-go gomod github.com/golang/go/src go1.21 strings/Join().(names, ","))
216
217 // TODO: copied from autogroup.go, so try and build a better test...
218 // merging two resources into one should yield the sum of their semas
219 if semas := r2.MetaParamsscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/MetaRes#MetaParams.().Semascip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/MetaParams#Sema.; len(semas) > 0 {
220 r1.MetaParamsscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/MetaRes#MetaParams.().Semascip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/MetaParams#Sema. = append(r1.MetaParamsscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/MetaRes#MetaParams.().Semascip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/MetaParams#Sema., semas...)
221 r1.MetaParamsscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/MetaRes#MetaParams.().Semascip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/MetaParams#Sema. = utilscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/util`/.StrRemoveDuplicatesInListscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/util`/StrRemoveDuplicatesInList().(r1.MetaParamsscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/MetaRes#MetaParams.().Semascip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/MetaParams#Sema.)
222 }
223
224 return // success or fail, and no need to merge the actual vertices!
225 }
226
227 func (obj *testGrouperscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/testGrouper#) EdgeMergescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/testGrouper#EdgeMerge().(e1, e2 pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.Edgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Edge#) pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.Edgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Edge# {
228 edge1 := e1.(*enginescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/.Edgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/Edge#) // panic if wrong
229 edge2 := e2.(*enginescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/.Edgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/Edge#) // panic if wrong
230 // HACK: update the name so it makes a union of both names
231 n1 := stringsscip-go gomod github.com/golang/go/src go1.21 strings/.Splitscip-go gomod github.com/golang/go/src go1.21 strings/Split().(edge1.Namescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/Edge#Name., ",") // load
232 n2 := stringsscip-go gomod github.com/golang/go/src go1.21 strings/.Splitscip-go gomod github.com/golang/go/src go1.21 strings/Split().(edge2.Namescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/Edge#Name., ",") // load
233 names := append(n1, n2...)
234 names = utilscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/util`/.StrRemoveDuplicatesInListscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/util`/StrRemoveDuplicatesInList().(names) // remove duplicates
235 sortscip-go gomod github.com/golang/go/src go1.21 sort/.Stringsscip-go gomod github.com/golang/go/src go1.21 sort/Strings().(names)
236 return &enginescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/.Edgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/Edge#{Namescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/Edge#Name.: stringsscip-go gomod github.com/golang/go/src go1.21 strings/.Joinscip-go gomod github.com/golang/go/src go1.21 strings/Join().(names, ",")}
237 }
238
239 // helper function
240 func runGraphCmpscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/runGraphCmp().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#, g1, g2 *pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.Graphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#) {
241 debug := testingscip-go gomod github.com/golang/go/src go1.21 testing/.Verbosescip-go gomod github.com/golang/go/src go1.21 testing/Verbose().() // set via the -test.v flag to `go test`
242 logf := func(format string, v ...interface{}) {
243 t.Logfscip-go gomod github.com/golang/go/src go1.21 testing/common#Logf().("test: "+format, v...)
244 }
245
246 if err := AutoGroupscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/AutoGroup().(&testGrouperscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/testGrouper#{}, g1, debug, logf); err != nil { // edits the graph
247 t.Errorfscip-go gomod github.com/golang/go/src go1.21 testing/common#Errorf().("%v", err)
248 return
249 }
250 err := GraphCmpscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/GraphCmp().(g1, g2)
251 if err != nil {
252 t.Logfscip-go gomod github.com/golang/go/src go1.21 testing/common#Logf().(" actual (g1): %v%v", g1, fullPrintscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/fullPrint().(g1))
253 t.Logfscip-go gomod github.com/golang/go/src go1.21 testing/common#Logf().("expected (g2): %v%v", g2, fullPrintscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/fullPrint().(g2))
254 t.Logfscip-go gomod github.com/golang/go/src go1.21 testing/common#Logf().("Cmp error:")
255 t.Errorfscip-go gomod github.com/golang/go/src go1.21 testing/common#Errorf().("%v", err)
256 }
257 }
258
259 // GraphCmp compares the topology of two graphs and returns nil if they're
260 // equal. It also compares if grouped element groups are identical.
261 // TODO: port this to use the pgraph.GraphCmp function instead.
262 func GraphCmpscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/GraphCmp().(g1, g2 *pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.Graphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#) error {
263 if n1, n2 := g1.NumVerticesscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#NumVertices().(), g2.NumVerticesscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#NumVertices().(); n1 != n2 {
264 return fmtscip-go gomod github.com/golang/go/src go1.21 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.21 fmt/Errorf().("graph g1 has %d vertices, while g2 has %d", n1, n2)
265 }
266 if e1, e2 := g1.NumEdgesscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#NumEdges().(), g2.NumEdgesscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#NumEdges().(); e1 != e2 {
267 return fmtscip-go gomod github.com/golang/go/src go1.21 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.21 fmt/Errorf().("graph g1 has %d edges, while g2 has %d", e1, e2)
268 }
269
270 var m = make(map[pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.Vertexscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Vertex#]pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.Vertexscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Vertex#) // g1 to g2 vertex correspondence
271 Loop:
272 // check vertices
273 for v1 := range g1.Adjacencyscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#Adjacency().() { // for each vertex in g1
274 r1 := v1.(enginescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/.GroupableResscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/GroupableRes#)
275 l1 := stringsscip-go gomod github.com/golang/go/src go1.21 strings/.Splitscip-go gomod github.com/golang/go/src go1.21 strings/Split().(r1.Namescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/NamedRes#Name.(), ",") // make list of everyone's names...
276 for _, x1 := range r1.GetGroupscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/GroupableRes#GetGroup.() {
277 l1 = append(l1, x1.Namescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/NamedRes#Name.()) // add my contents
278 }
279 l1 = utilscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/util`/.StrRemoveDuplicatesInListscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/util`/StrRemoveDuplicatesInList().(l1) // remove duplicates
280 sortscip-go gomod github.com/golang/go/src go1.21 sort/.Stringsscip-go gomod github.com/golang/go/src go1.21 sort/Strings().(l1)
281
282 // inner loop
283 for v2 := range g2.Adjacencyscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#Adjacency().() { // does it match in g2 ?
284 r2 := v2.(enginescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/.GroupableResscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/GroupableRes#)
285 l2 := stringsscip-go gomod github.com/golang/go/src go1.21 strings/.Splitscip-go gomod github.com/golang/go/src go1.21 strings/Split().(r2.Namescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/NamedRes#Name.(), ",")
286 for _, x2 := range r2.GetGroupscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/GroupableRes#GetGroup.() {
287 l2 = append(l2, x2.Namescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/NamedRes#Name.())
288 }
289 l2 = utilscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/util`/.StrRemoveDuplicatesInListscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/util`/StrRemoveDuplicatesInList().(l2) // remove duplicates
290 sortscip-go gomod github.com/golang/go/src go1.21 sort/.Stringsscip-go gomod github.com/golang/go/src go1.21 sort/Strings().(l2)
291
292 // does l1 match l2 ?
293 if ListStrCmpscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/ListStrCmp().(l1, l2) { // cmp!
294 m[v1] = v2
295 continue Loop
296 }
297 }
298 return fmtscip-go gomod github.com/golang/go/src go1.21 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.21 fmt/Errorf().("graph g1, has no match in g2 for: %v", r1.Namescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/NamedRes#Name.())
299 }
300 // vertices (and groups) match :)
301
302 // check edges
303 for v1 := range g1.Adjacencyscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#Adjacency().() { // for each vertex in g1
304 v2 := m[v1] // lookup in map to get correspondance
305 // g1.Adjacency()[v1] corresponds to g2.Adjacency()[v2]
306 if e1, e2 := len(g1.Adjacencyscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#Adjacency().()[v1]), len(g2.Adjacencyscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#Adjacency().()[v2]); e1 != e2 {
307 r1 := v1.(enginescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/.Resscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/Res#)
308 r2 := v2.(enginescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/.Resscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/Res#)
309 return fmtscip-go gomod github.com/golang/go/src go1.21 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.21 fmt/Errorf().("graph g1, vertex(%v) has %d edges, while g2, vertex(%v) has %d", r1.Namescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/NamedRes#Name.(), e1, r2.Namescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/NamedRes#Name.(), e2)
310 }
311
312 for vv1, ee1 := range g1.Adjacencyscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#Adjacency().()[v1] {
313 vv2 := m[vv1]
314 ee1 := ee1.(*enginescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/.Edgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/Edge#)
315 ee2 := g2.Adjacencyscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#Adjacency().()[v2][vv2].(*enginescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/.Edgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/Edge#)
316
317 // these are edges from v1 -> vv1 via ee1 (graph 1)
318 // to cmp to edges from v2 -> vv2 via ee2 (graph 2)
319
320 // check: (1) vv1 == vv2 ? (we've already checked this!)
321 rr1 := vv1.(enginescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/.GroupableResscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/GroupableRes#)
322 rr2 := vv2.(enginescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/.GroupableResscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/GroupableRes#)
323
324 l1 := stringsscip-go gomod github.com/golang/go/src go1.21 strings/.Splitscip-go gomod github.com/golang/go/src go1.21 strings/Split().(rr1.Namescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/NamedRes#Name.(), ",") // make list of everyone's names...
325 for _, x1 := range rr1.GetGroupscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/GroupableRes#GetGroup.() {
326 l1 = append(l1, x1.Namescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/NamedRes#Name.()) // add my contents
327 }
328 l1 = utilscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/util`/.StrRemoveDuplicatesInListscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/util`/StrRemoveDuplicatesInList().(l1) // remove duplicates
329 sortscip-go gomod github.com/golang/go/src go1.21 sort/.Stringsscip-go gomod github.com/golang/go/src go1.21 sort/Strings().(l1)
330
331 l2 := stringsscip-go gomod github.com/golang/go/src go1.21 strings/.Splitscip-go gomod github.com/golang/go/src go1.21 strings/Split().(rr2.Namescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/NamedRes#Name.(), ",")
332 for _, x2 := range rr2.GetGroupscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/GroupableRes#GetGroup.() {
333 l2 = append(l2, x2.Namescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/NamedRes#Name.())
334 }
335 l2 = utilscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/util`/.StrRemoveDuplicatesInListscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/util`/StrRemoveDuplicatesInList().(l2) // remove duplicates
336 sortscip-go gomod github.com/golang/go/src go1.21 sort/.Stringsscip-go gomod github.com/golang/go/src go1.21 sort/Strings().(l2)
337
338 // does l1 match l2 ?
339 if !ListStrCmpscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/ListStrCmp().(l1, l2) { // cmp!
340 return fmtscip-go gomod github.com/golang/go/src go1.21 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.21 fmt/Errorf().("graph g1 and g2 don't agree on: %v and %v", rr1.Namescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/NamedRes#Name.(), rr2.Namescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/NamedRes#Name.())
341 }
342
343 // check: (2) ee1 == ee2
344 if ee1.Namescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/Edge#Name. != ee2.Namescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/Edge#Name. {
345 return fmtscip-go gomod github.com/golang/go/src go1.21 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.21 fmt/Errorf().("graph g1 edge(%v) doesn't match g2 edge(%v)", ee1.Namescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/Edge#Name., ee2.Namescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/Edge#Name.)
346 }
347 }
348 }
349
350 // check meta parameters
351 for v1 := range g1.Adjacencyscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#Adjacency().() { // for each vertex in g1
352 for v2 := range g2.Adjacencyscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#Adjacency().() { // does it match in g2 ?
353 r1 := v1.(enginescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/.Resscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/Res#)
354 r2 := v2.(enginescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/.Resscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/Res#)
355 s1, s2 := r1.MetaParamsscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/MetaRes#MetaParams.().Semascip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/MetaParams#Sema., r2.MetaParamsscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/MetaRes#MetaParams.().Semascip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/MetaParams#Sema.
356 sortscip-go gomod github.com/golang/go/src go1.21 sort/.Stringsscip-go gomod github.com/golang/go/src go1.21 sort/Strings().(s1)
357 sortscip-go gomod github.com/golang/go/src go1.21 sort/.Stringsscip-go gomod github.com/golang/go/src go1.21 sort/Strings().(s2)
358 if !reflectscip-go gomod github.com/golang/go/src go1.21 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.21 reflect/DeepEqual().(s1, s2) {
359 return fmtscip-go gomod github.com/golang/go/src go1.21 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.21 fmt/Errorf().("vertex %s and vertex %s have different semaphores", r1.Namescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/NamedRes#Name.(), r2.Namescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/NamedRes#Name.())
360 }
361 }
362 }
363
364 return nil // success!
365 }
366
367 // ListStrCmp compares two lists of strings
368 func ListStrCmpscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/ListStrCmp().(a, b []string) bool {
369 //fmt.Printf("CMP: %v with %v\n", a, b) // debugging
370 if a == nil && b == nil {
371 return true
372 }
373 if a == nil || b == nil {
374 return false
375 }
376 if len(a) != len(b) {
377 return false
378 }
379 for i := range a {
380 if a[i] != b[i] {
381 return false
382 }
383 }
384 return true
385 }
386
387 func fullPrintscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/fullPrint().(g *pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.Graphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#) (str string) {
388 str += "\n"
389 for v := range g.Adjacencyscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#Adjacency().() {
390 r := v.(enginescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/.Resscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/Res#)
391 if semas := r.MetaParamsscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/MetaRes#MetaParams.().Semascip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/MetaParams#Sema.; len(semas) > 0 {
392 str += fmtscip-go gomod github.com/golang/go/src go1.21 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.21 fmt/Sprintf().("* v: %v; sema: %v\n", r.Namescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/NamedRes#Name.(), semas)
393 } else {
394 str += fmtscip-go gomod github.com/golang/go/src go1.21 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.21 fmt/Sprintf().("* v: %v\n", r.Namescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/NamedRes#Name.())
395 }
396 // TODO: add explicit grouping data?
397 }
398 for v1 := range g.Adjacencyscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#Adjacency().() {
399 for v2, e := range g.Adjacencyscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#Adjacency().()[v1] {
400 r1 := v1.(enginescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/.Resscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/Res#)
401 r2 := v2.(enginescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/.Resscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/Res#)
402 edge := e.(*enginescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/.Edgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/Edge#)
403 str += fmtscip-go gomod github.com/golang/go/src go1.21 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.21 fmt/Sprintf().("* e: %v -> %v # %v\n", r1.Namescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/NamedRes#Name.(), r2.Namescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/NamedRes#Name.(), edge.Namescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine`/Edge#Name.)
404 }
405 }
406 return
407 }
408
409 func TestDurationAssumptionsscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/TestDurationAssumptions().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
410 var d timescip-go gomod github.com/golang/go/src go1.21 time/.Durationscip-go gomod github.com/golang/go/src go1.21 time/Duration#
411 if (d == 0) != true {
412 t.Errorfscip-go gomod github.com/golang/go/src go1.21 testing/common#Errorf().("empty time.Duration is no longer equal to zero")
413 }
414 if (d > 0) != false {
415 t.Errorfscip-go gomod github.com/golang/go/src go1.21 testing/common#Errorf().("empty time.Duration is now greater than zero")
416 }
417 }
418
419 // all of the following test cases are laid out with the following semantics:
420 // * vertices which start with the same single letter are considered "like"
421 // * "like" elements should be merged
422 // * vertices can have any integer after their single letter "family" type
423 // * grouped vertices should have a name with a comma separated list of names
424 // * edges follow the same conventions about grouping
425
426 // empty graph
427 func TestPgraphGrouping1scip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/TestPgraphGrouping1().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
428 g1, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g1") // original graph
429 g2, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g2") // expected result
430 runGraphCmpscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/runGraphCmp().(t, g1, g2)
431 }
432
433 // single vertex
434 func TestPgraphGrouping2scip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/TestPgraphGrouping2().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
435 g1, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g1") // original graph
436 { // grouping to limit variable scope
437 a1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a1")
438 g1.AddVertexscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddVertex().(a1)
439 }
440 g2, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g2") // expected result
441 {
442 a1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a1")
443 g2.AddVertexscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddVertex().(a1)
444 }
445 runGraphCmpscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/runGraphCmp().(t, g1, g2)
446 }
447
448 // two vertices
449 func TestPgraphGrouping3scip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/TestPgraphGrouping3().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
450 g1, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g1") // original graph
451 {
452 a1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a1")
453 b1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("b1")
454 g1.AddVertexscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddVertex().(a1, b1)
455 }
456 g2, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g2") // expected result
457 {
458 a1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a1")
459 b1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("b1")
460 g2.AddVertexscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddVertex().(a1, b1)
461 }
462 runGraphCmpscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/runGraphCmp().(t, g1, g2)
463 }
464
465 // two vertices merge
466 func TestPgraphGrouping4scip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/TestPgraphGrouping4().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
467 g1, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g1") // original graph
468 {
469 a1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a1")
470 a2 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a2")
471 g1.AddVertexscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddVertex().(a1, a2)
472 }
473 g2, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g2") // expected result
474 {
475 a := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a1,a2")
476 g2.AddVertexscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddVertex().(a)
477 }
478 runGraphCmpscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/runGraphCmp().(t, g1, g2)
479 }
480
481 // three vertices merge
482 func TestPgraphGrouping5scip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/TestPgraphGrouping5().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
483 g1, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g1") // original graph
484 {
485 a1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a1")
486 a2 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a2")
487 a3 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a3")
488 g1.AddVertexscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddVertex().(a1, a2, a3)
489 }
490 g2, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g2") // expected result
491 {
492 a := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a1,a2,a3")
493 g2.AddVertexscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddVertex().(a)
494 }
495 runGraphCmpscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/runGraphCmp().(t, g1, g2)
496 }
497
498 // three vertices, two merge
499 func TestPgraphGrouping6scip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/TestPgraphGrouping6().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
500 g1, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g1") // original graph
501 {
502 a1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a1")
503 a2 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a2")
504 b1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("b1")
505 g1.AddVertexscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddVertex().(a1, a2, b1)
506 }
507 g2, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g2") // expected result
508 {
509 a := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a1,a2")
510 b1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("b1")
511 g2.AddVertexscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddVertex().(a, b1)
512 }
513 runGraphCmpscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/runGraphCmp().(t, g1, g2)
514 }
515
516 // four vertices, three merge
517 func TestPgraphGrouping7scip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/TestPgraphGrouping7().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
518 g1, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g1") // original graph
519 {
520 a1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a1")
521 a2 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a2")
522 a3 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a3")
523 b1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("b1")
524 g1.AddVertexscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddVertex().(a1, a2, a3, b1)
525 }
526 g2, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g2") // expected result
527 {
528 a := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a1,a2,a3")
529 b1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("b1")
530 g2.AddVertexscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddVertex().(a, b1)
531 }
532 runGraphCmpscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/runGraphCmp().(t, g1, g2)
533 }
534
535 // four vertices, two&two merge
536 func TestPgraphGrouping8scip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/TestPgraphGrouping8().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
537 g1, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g1") // original graph
538 {
539 a1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a1")
540 a2 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a2")
541 b1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("b1")
542 b2 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("b2")
543 g1.AddVertexscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddVertex().(a1, a2, b1, b2)
544 }
545 g2, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g2") // expected result
546 {
547 a := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a1,a2")
548 b := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("b1,b2")
549 g2.AddVertexscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddVertex().(a, b)
550 }
551 runGraphCmpscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/runGraphCmp().(t, g1, g2)
552 }
553
554 // five vertices, two&three merge
555 func TestPgraphGrouping9scip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/TestPgraphGrouping9().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
556 g1, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g1") // original graph
557 {
558 a1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a1")
559 a2 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a2")
560 b1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("b1")
561 b2 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("b2")
562 b3 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("b3")
563 g1.AddVertexscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddVertex().(a1, a2, b1, b2, b3)
564 }
565 g2, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g2") // expected result
566 {
567 a := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a1,a2")
568 b := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("b1,b2,b3")
569 g2.AddVertexscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddVertex().(a, b)
570 }
571 runGraphCmpscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/runGraphCmp().(t, g1, g2)
572 }
573
574 // three unique vertices
575 func TestPgraphGrouping10scip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/TestPgraphGrouping10().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
576 g1, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g1") // original graph
577 {
578 a1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a1")
579 b1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("b1")
580 c1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("c1")
581 g1.AddVertexscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddVertex().(a1, b1, c1)
582 }
583 g2, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g2") // expected result
584 {
585 a1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a1")
586 b1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("b1")
587 c1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("c1")
588 g2.AddVertexscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddVertex().(a1, b1, c1)
589 }
590 runGraphCmpscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/runGraphCmp().(t, g1, g2)
591 }
592
593 // three unique vertices, two merge
594 func TestPgraphGrouping11scip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/TestPgraphGrouping11().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
595 g1, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g1") // original graph
596 {
597 a1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a1")
598 b1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("b1")
599 b2 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("b2")
600 c1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("c1")
601 g1.AddVertexscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddVertex().(a1, b1, b2, c1)
602 }
603 g2, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g2") // expected result
604 {
605 a1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a1")
606 b := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("b1,b2")
607 c1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("c1")
608 g2.AddVertexscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddVertex().(a1, b, c1)
609 }
610 runGraphCmpscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/runGraphCmp().(t, g1, g2)
611 }
612
613 /*
614 // simple merge 1
615 // a1 a2 a1,a2
616 // \ / >>> | (arrows point downwards)
617 // b b
618 */
619 func TestPgraphGrouping12scip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/TestPgraphGrouping12().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
620 g1, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g1") // original graph
621 {
622 a1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a1")
623 a2 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a2")
624 b1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("b1")
625 e1 := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e1")
626 e2 := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e2")
627 g1.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(a1, b1, e1)
628 g1.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(a2, b1, e2)
629 }
630 g2, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g2") // expected result
631 {
632 a := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a1,a2")
633 b1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("b1")
634 e := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e1,e2")
635 g2.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(a, b1, e)
636 }
637 runGraphCmpscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/runGraphCmp().(t, g1, g2)
638 }
639
640 /*
641 // simple merge 2
642 // b b
643 // / \ >>> | (arrows point downwards)
644 // a1 a2 a1,a2
645 */
646 func TestPgraphGrouping13scip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/TestPgraphGrouping13().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
647 g1, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g1") // original graph
648 {
649 a1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a1")
650 a2 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a2")
651 b1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("b1")
652 e1 := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e1")
653 e2 := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e2")
654 g1.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(b1, a1, e1)
655 g1.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(b1, a2, e2)
656 }
657 g2, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g2") // expected result
658 {
659 a := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a1,a2")
660 b1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("b1")
661 e := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e1,e2")
662 g2.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(b1, a, e)
663 }
664 runGraphCmpscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/runGraphCmp().(t, g1, g2)
665 }
666
667 /*
668 // triple merge
669 // a1 a2 a3 a1,a2,a3
670 // \ | / >>> | (arrows point downwards)
671 // b b
672 */
673 func TestPgraphGrouping14scip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/TestPgraphGrouping14().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
674 g1, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g1") // original graph
675 {
676 a1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a1")
677 a2 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a2")
678 a3 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a3")
679 b1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("b1")
680 e1 := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e1")
681 e2 := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e2")
682 e3 := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e3")
683 g1.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(a1, b1, e1)
684 g1.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(a2, b1, e2)
685 g1.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(a3, b1, e3)
686 }
687 g2, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g2") // expected result
688 {
689 a := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a1,a2,a3")
690 b1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("b1")
691 e := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e1,e2,e3")
692 g2.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(a, b1, e)
693 }
694 runGraphCmpscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/runGraphCmp().(t, g1, g2)
695 }
696
697 /*
698 // chain merge
699 // a1 a1
700 // / \ |
701 // b1 b2 >>> b1,b2 (arrows point downwards)
702 // \ / |
703 // c1 c1
704 */
705 func TestPgraphGrouping15scip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/TestPgraphGrouping15().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
706 g1, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g1") // original graph
707 {
708 a1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a1")
709 b1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("b1")
710 b2 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("b2")
711 c1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("c1")
712 e1 := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e1")
713 e2 := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e2")
714 e3 := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e3")
715 e4 := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e4")
716 g1.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(a1, b1, e1)
717 g1.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(a1, b2, e2)
718 g1.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(b1, c1, e3)
719 g1.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(b2, c1, e4)
720 }
721 g2, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g2") // expected result
722 {
723 a1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a1")
724 b := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("b1,b2")
725 c1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("c1")
726 e1 := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e1,e2")
727 e2 := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e3,e4")
728 g2.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(a1, b, e1)
729 g2.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(b, c1, e2)
730 }
731 runGraphCmpscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/runGraphCmp().(t, g1, g2)
732 }
733
734 /*
735 // re-attach 1 (outer)
736 // technically the second possibility is valid too, depending on which order we
737 // merge edges in, and if we don't filter out any unnecessary edges afterwards!
738 // a1 a2 a1,a2 a1,a2
739 // | / | | \
740 // b1 / >>> b1 OR b1 / (arrows point downwards)
741 // | / | | /
742 // c1 c1 c1
743 */
744 func TestPgraphGrouping16scip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/TestPgraphGrouping16().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
745 g1, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g1") // original graph
746 {
747 a1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a1")
748 a2 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a2")
749 b1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("b1")
750 c1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("c1")
751 e1 := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e1")
752 e2 := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e2")
753 e3 := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e3")
754 g1.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(a1, b1, e1)
755 g1.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(b1, c1, e2)
756 g1.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(a2, c1, e3)
757 }
758 //g2, _ := pgraph.NewGraph("g2") // expected result
759 //{
760 // a := NewNoopResTest("a1,a2")
761 // b1 := NewNoopResTest("b1")
762 // c1 := NewNoopResTest("c1")
763 // e1 := NE("e1,e3")
764 // e2 := NE("e2,e3") // e3 gets "merged through" to BOTH edges!
765 // g2.AddEdge(a, b1, e1)
766 // g2.AddEdge(b1, c1, e2)
767 //}
768 //runGraphCmp(t, g1, g2)
769 g3, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g3") // alternative expected result
770 {
771 a := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a1,a2")
772 b1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("b1")
773 c1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("c1")
774 e1 := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e1")
775 e2 := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e2")
776 e3 := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e3")
777 g3.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(a, b1, e1)
778 g3.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(b1, c1, e2)
779 g3.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(a, c1, e3)
780 }
781 runGraphCmpscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/runGraphCmp().(t, g1, g3)
782 }
783
784 /*
785 // re-attach 2 (inner)
786 // a1 b2 a1
787 // | / |
788 // b1 / >>> b1,b2 (arrows point downwards)
789 // | / |
790 // c1 c1
791 */
792 func TestPgraphGrouping17scip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/TestPgraphGrouping17().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
793 g1, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g1") // original graph
794 {
795 a1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a1")
796 b1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("b1")
797 b2 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("b2")
798 c1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("c1")
799 e1 := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e1")
800 e2 := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e2")
801 e3 := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e3")
802 g1.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(a1, b1, e1)
803 g1.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(b1, c1, e2)
804 g1.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(b2, c1, e3)
805 }
806 g2, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g2") // expected result
807 {
808 a1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a1")
809 b := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("b1,b2")
810 c1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("c1")
811 e1 := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e1")
812 e2 := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e2,e3")
813 g2.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(a1, b, e1)
814 g2.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(b, c1, e2)
815 }
816 runGraphCmpscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/runGraphCmp().(t, g1, g2)
817 }
818
819 /*
820 // re-attach 3 (double)
821 // similar to "re-attach 1", technically there is a second possibility for this
822 // TODO: verify this second possibility manually
823 // a2 a1 b2 a1,a2 a1,a2
824 // \ | / | | \
825 // \ b1 / >>> b1,b2 OR b1,b2 / (arrows point downwards)
826 // \ | / | | /
827 // c1 c1 c1
828 */
829 func TestPgraphGrouping18scip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/TestPgraphGrouping18().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
830 g1, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g1") // original graph
831 {
832 a1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a1")
833 a2 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a2")
834 b1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("b1")
835 b2 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("b2")
836 c1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("c1")
837 e1 := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e1")
838 e2 := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e2")
839 e3 := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e3")
840 e4 := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e4")
841 g1.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(a1, b1, e1)
842 g1.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(b1, c1, e2)
843 g1.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(a2, c1, e3)
844 g1.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(b2, c1, e4)
845 }
846 //g2, _ := pgraph.NewGraph("g2") // expected result
847 //{
848 // a := NewNoopResTest("a1,a2")
849 // b := NewNoopResTest("b1,b2")
850 // c1 := NewNoopResTest("c1")
851 // e1 := NE("e1,e3")
852 // e2 := NE("e2,e3,e4") // e3 gets "merged through" to BOTH edges!
853 // g2.AddEdge(a, b, e1)
854 // g2.AddEdge(b, c1, e2)
855 //}
856 //runGraphCmp(t, g1, g2)
857 g3, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g3") // alternative expected result
858 {
859 a := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a1,a2")
860 b := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("b1,b2")
861 c1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("c1")
862 e1 := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e1")
863 e2 := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e2,e4")
864 e3 := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e3")
865 g3.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(a, b, e1)
866 g3.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(b, c1, e2)
867 g3.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(a, c1, e3)
868 }
869 runGraphCmpscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/runGraphCmp().(t, g1, g3)
870 }
871
872 /*
873 // connected merge 0, (no change!)
874 // a1 a1
875 // \ >>> \ (arrows point downwards)
876 // a2 a2
877 */
878 func TestPgraphGroupingConnected0scip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/TestPgraphGroupingConnected0().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
879 g1, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g1") // original graph
880 {
881 a1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a1")
882 a2 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a2")
883 e1 := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e1")
884 g1.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(a1, a2, e1)
885 }
886 g2, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g2") // expected result ?
887 {
888 a1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a1")
889 a2 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a2")
890 e1 := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e1")
891 g2.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(a1, a2, e1)
892 }
893 runGraphCmpscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/runGraphCmp().(t, g1, g2)
894 }
895
896 /*
897 // connected merge 1, (no change!)
898 // a1 a1
899 // \ \
900 // b >>> b (arrows point downwards)
901 // \ \
902 // a2 a2
903 */
904 func TestPgraphGroupingConnected1scip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/TestPgraphGroupingConnected1().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
905 g1, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g1") // original graph
906 {
907 a1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a1")
908 b := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("b")
909 a2 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a2")
910 e1 := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e1")
911 e2 := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e2")
912 g1.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(a1, b, e1)
913 g1.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(b, a2, e2)
914 }
915 g2, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g2") // expected result ?
916 {
917 a1 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a1")
918 b := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("b")
919 a2 := NewNoopResTestscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTest().("a2")
920 e1 := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e1")
921 e2 := NEscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NE().("e2")
922 g2.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(a1, b, e1)
923 g2.AddEdgescip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddEdge().(b, a2, e2)
924 }
925 runGraphCmpscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/runGraphCmp().(t, g1, g2)
926 }
927
928 func TestPgraphSemaphoreGrouping1scip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/TestPgraphSemaphoreGrouping1().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
929 g1, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g1") // original graph
930 {
931 a1 := NewNoopResTestSemascip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTestSema().("a1", []string{"s:1"})
932 a2 := NewNoopResTestSemascip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTestSema().("a2", []string{"s:2"})
933 a3 := NewNoopResTestSemascip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTestSema().("a3", []string{"s:3"})
934 g1.AddVertexscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddVertex().(a1)
935 g1.AddVertexscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddVertex().(a2)
936 g1.AddVertexscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddVertex().(a3)
937 }
938 g2, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g2") // expected result
939 {
940 a123 := NewNoopResTestSemascip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTestSema().("a1,a2,a3", []string{"s:1", "s:2", "s:3"})
941 g2.AddVertexscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddVertex().(a123)
942 }
943 runGraphCmpscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/runGraphCmp().(t, g1, g2)
944 }
945
946 func TestPgraphSemaphoreGrouping2scip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/TestPgraphSemaphoreGrouping2().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
947 g1, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g1") // original graph
948 {
949 a1 := NewNoopResTestSemascip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTestSema().("a1", []string{"s:10", "s:11"})
950 a2 := NewNoopResTestSemascip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTestSema().("a2", []string{"s:2"})
951 a3 := NewNoopResTestSemascip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTestSema().("a3", []string{"s:3"})
952 g1.AddVertexscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddVertex().(a1)
953 g1.AddVertexscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddVertex().(a2)
954 g1.AddVertexscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddVertex().(a3)
955 }
956 g2, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g2") // expected result
957 {
958 a123 := NewNoopResTestSemascip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTestSema().("a1,a2,a3", []string{"s:10", "s:11", "s:2", "s:3"})
959 g2.AddVertexscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddVertex().(a123)
960 }
961 runGraphCmpscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/runGraphCmp().(t, g1, g2)
962 }
963
964 func TestPgraphSemaphoreGrouping3scip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/TestPgraphSemaphoreGrouping3().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
965 g1, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g1") // original graph
966 {
967 a1 := NewNoopResTestSemascip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTestSema().("a1", []string{"s:1", "s:2"})
968 a2 := NewNoopResTestSemascip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTestSema().("a2", []string{"s:2"})
969 a3 := NewNoopResTestSemascip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTestSema().("a3", []string{"s:3"})
970 g1.AddVertexscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddVertex().(a1)
971 g1.AddVertexscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddVertex().(a2)
972 g1.AddVertexscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddVertex().(a3)
973 }
974 g2, _ := pgraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/.NewGraphscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/NewGraph().("g2") // expected result
975 {
976 a123 := NewNoopResTestSemascip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/NewNoopResTestSema().("a1,a2,a3", []string{"s:1", "s:2", "s:3"})
977 g2.AddVertexscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/pgraph`/Graph#AddVertex().(a123)
978 }
979 runGraphCmpscip-go gomod github.com/purpleidea/mgmt . `github.com/purpleidea/mgmt/engine/graph/autogroup`/runGraphCmp().(t, g1, g2)
980 }