purpleidea / mgmt

Next generation distributed, event-driven, parallel config management!
https://purpleidea.com/tags/mgmtconfig/
GNU General Public License v3.0
3.65k stars 314 forks source link

[LOVE] Add tests to GraphSync #173

Open purpleidea opened 7 years ago

purpleidea commented 7 years ago

This is a project for a first time mgmt contributor. It should be fairly straightforward, but not too easy.

We have a GraphSync function in mgmt:

func (g *Graph) GraphSync(oldGraph *Graph) (*Graph, error) {

https://github.com/purpleidea/mgmt/blob/master/pgraph/pgraph.go#L557 (might move around a bit due to git master changes of course)

We should add some proper golang tests for this in pgraph_test.go

To test it, it might be helpful to have the Exit functions:

v.SendEvent(event.EventExit, nil) // sync
v.Res.WaitGroup().Wait()
oldGraph.DeleteVertex(v)

Be no-op's.

As a result, we could change the function signature to:

func (g *Graph) GraphSync(oldGraph *Graph, stop func(v *Vertex)) (*Graph, error)

This way we could pass in this lambda when calling it from main:

stop := func(v *Vertex) {
    v.SendEvent(event.EventExit, nil) // sync
    v.Res.WaitGroup().Wait()
    oldGraph.DeleteVertex(v)
}

and a noop function when calling it from testing.

The GraphDiff code already present in the pgraph_test.go might help speed this up significantly!

Any questions, just ask! Happy hacking new mgmt hacker!

mrcrilly commented 7 years ago

Acknowledged. Will work this ticket.

purpleidea commented 7 years ago

@mrcrilly thanks movedx !

purpleidea commented 7 years ago

@mrcrilly Any progress on this? Thanks

mrcrilly commented 7 years ago

Hi. Not at this point in time.

I'm writing a whole code base around a product I'm developing, blogging, vastly improving my own copy of the Open AWS Guide, and working... sadly I may not get to this, but I'll try in the week.

nitinprakash96 commented 7 years ago

If this is not solved yet, I'd like to work on this one.

purpleidea commented 7 years ago

@nitinprakash96 Please grab it :)

ahmedsharif865 commented 5 years ago

Is someone still working on this issue?

purpleidea commented 5 years ago

@ahmedsharif865 I don't think so. Grab it if you want.

EloyTolosaDev commented 1 year ago

Hi!

I can see some code in the graphsync_test.go package. Is this PR still open? If so, I've seen that the GraphSync signatura has change a little. Are you still looking for the function signatura to be like this? func (g *Graph) GraphSync(oldGraph *Graph, stop func(v *Vertex)) (*Graph, error) I would love to contribute to this!

purpleidea commented 1 year ago

@EloyTolosaDev

Hey, I'm really sorry I somehow missed your message. Yes issue is still open if you'd like to send a patch.

Thanks!