Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
state: Multple interfaces can be added to machines; more tests/methods. #4481
Conversation
dooferlad
reviewed
Feb 22, 2016
| +} | ||
| + | ||
| +func (s *interfacesStateSuite) TestInterfaceRefreshUpdatesStaleDocData(c *gc.C) { | ||
| + fooInterface := s.addSimpleInterface(c) |
dooferlad
Feb 22, 2016
Contributor
This test is unclear. Please add a comment telling us how fooInterface.Refresh() is able to change hardware address. It seems that fooInterface.Refresh is looking up some details by interface name.
dimitern
Feb 23, 2016
Contributor
Indeed, now looking at it seems so. What it's trying to test is 2 copies of state.Interface with the same docID can hold different field values and Refresh() updates the doc and values. Unfortunately, there's no way to change anything of an interface - only add and remove. Other similar tests in state do things like: get original, copy with the same docID, copy.EnsureDead(), check original.Life() == Alive && copy.Life() == Dead, original.Refresh() && original.Life() == Dead. So this test "cheats" by removing the doc and adding a new one with the same docID but set hardware address and relies on Refresh() to get the new doc by ID. Too many assumptions, will simplify or just drop perhaps.
EDIT: Decided to drop Interface.Refresh() entirely along with its tests, as since nothing can change yet on the doc, there's no need for Refresh()ing.
dooferlad
reviewed
Feb 22, 2016
| + case successfulArgs <- testArgs: | ||
| + default: | ||
| + // successfulArgs is buffered, so if we can't send there was | ||
| + // more than once success. |
dooferlad
reviewed
Feb 22, 2016
| + default: | ||
| + // successfulArgs is buffered, so if we can't send there was | ||
| + // more than once success. | ||
| + c.Fatalf("unexpected more than one success for args %+v", testArgs) |
|
Thanks for the detailed reviews! I'll start replying shortly in order. |
added some commits
Feb 19, 2016
|
@frobware @dooferlad Updated as described and rebased onto maas-spaces2 tip, please have another look and see if it's good to land. |
|
LGTM |
|
$$merge$$ |
|
Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju |
dimitern commentedFeb 19, 2016
Replaced singular Machine.AddInterface() by bulk Machine.AddInterfaces() method, which adds
multiple interfaces to the same machine, in a single transaction. Test coverage now is as good as
it can reasonably get, without resorting to ugly patching. Added jujutxn.TestHook tests and a speculative highly concurrent test for AddInterfaces.
New methods added and tested for all corner cases:
Defined two new concrete error types:
Still left to do in follow-ups: