Skip to content
This repository was archived by the owner on Jan 21, 2020. It is now read-only.

Conversation

chungers
Copy link
Contributor

@chungers chungers commented Nov 17, 2016

Closes #298

Changes

  • New mocks
  • New tests to verify behavior of two ensembles -- each with its own manager and group plugins -- for the cases
    • neither one of the ensembles is the leader
    • one of the ensembles become leader
    • one ensemble was leader then leadership is transferred / fail-overed to another

There are a bunch of unsigned merge commits which Gordon seems to get confused and complains about. We use squash merge so these should be ok.

@GordonTheTurtle
Copy link

Please sign your commits following these rules:
https://github.com/docker/docker/blob/master/CONTRIBUTING.md#sign-your-work
The easiest way to do this is to amend the last commit:

$ git clone -b "manager-tests" git@github.com:chungers/infrakit.git somewhere
$ cd somewhere
$ git rebase -i HEAD~842354169992
editor opens
change each 'pick' to 'edit'
save the file and quit
$ git commit --amend -s --no-edit
$ git rebase --continue # and repeat the amend for each commit
$ git push -f

Amending updates the existing PR. You DO NOT need to open a new one.

@codecov-io
Copy link

codecov-io commented Nov 17, 2016

Current coverage is 68.97% (diff: 100%)

Merging #306 into master will decrease coverage by 2.01%

@@             master       #306   diff @@
==========================================
  Files            25         27     +2   
  Lines          1241       1441   +200   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits            881        994   +113   
- Misses          285        355    +70   
- Partials         75         92    +17   

Powered by Codecov. Last update 06ab6e7...7115ffb

@wfarner wfarner changed the title Manager tests Add tests for the Manager plugin Nov 17, 2016
group_rpc "github.com/docker/infrakit/pkg/rpc/group"
"github.com/docker/infrakit/pkg/rpc/server"
"github.com/docker/infrakit/pkg/spi/group"
_ "github.com/docker/infrakit/pkg/store"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of the underscore import? If it remains, can you leave a comment so it's clear why it needs to be here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed anonymous import

manager1.Start()
manager2.Start()

time.Sleep(1 * time.Second)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline, if you use a custom leader detector for test, you should be able to eliminate (or at least more tightly control) the leadership delay. A nice outcome for this will be to remove all the calls to time.Sleep().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see updates

leader chan string,
ctrl *gomock.Controller,
configStore func(*store_mock.MockSnapshot),
configureGroup func(*group_mock.MockPlugin)) (Backend, server.Stoppable) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a big fan of function that starts to take on a ton of parameters.
Anyway for us to clean this up via struct or split this until smaller functions?

Perfect example in Kubernetes:
https://github.com/kubernetes/kubernetes/blob/973f2fcd86ef3c3e69f455aaf88553f0906b48bd/pkg/kubelet/kubelet.go#L171

Now refactored to:
https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/kubelet.go#L272

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're referring to the long list of parameters in the function NewManager in manager.go?

This function uses parameters that are of complex type (e.g. discoverry.Plugin, leader.Detector) instead of simple types like strings and bools (seen in the k8s you referenced), so while the function arg list is long, it's hard to mess things up without the compiler complaining.

I could look into doing something with embedding / composition with a struct like a manager.Config; however, my concern is that the fields would be public/exported and can be mutated after a manager instance is initialized. Having the dependencies passed in as function params allow the manager's dependencies (as struct fields) to be unexported and immutable after initialization.

Copy link
Contributor

@wfarner wfarner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Much easier for me to follow with the direct leader control.


defer close(checkpoint2)

t.Log("m2 leading")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove debug log statement


defer close(checkpoint3)

t.Log("m1 releasing")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove debug log statement

Signed-off-by: David Chung <david.chung@docker.com>
@chungers chungers merged commit 61b254a into docker-archive:master Nov 18, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants