Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(433)

Unified Diff: state/apiserver/provisioner/provisioner_test.go

Issue 28890043: Use single watcher for containr setup (Closed)
Patch Set: Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: state/apiserver/provisioner/provisioner_test.go
=== modified file 'state/apiserver/provisioner/provisioner_test.go'
--- state/apiserver/provisioner/provisioner_test.go 2013-11-14 23:58:18 +0000
+++ state/apiserver/provisioner/provisioner_test.go 2013-11-19 06:49:10 +0000
@@ -411,6 +411,43 @@
wc1.AssertNoChange()
}
+func (s *provisionerSuite) TestWatchAllContainers(c *gc.C) {
+ c.Assert(s.resources.Count(), gc.Equals, 0)
+
+ args := params.WatchContainers{Params: []params.WatchContainer{
+ {MachineTag: s.machines[0].Tag()},
+ {MachineTag: s.machines[1].Tag()},
+ {MachineTag: "machine-42"},
+ {MachineTag: "unit-foo-0"},
+ {MachineTag: "service-bar"},
+ }}
+ result, err := s.provisioner.WatchAllContainers(args)
+ c.Assert(err, gc.IsNil)
+ c.Assert(result, gc.DeepEquals, params.StringsWatchResults{
+ Results: []params.StringsWatchResult{
+ {StringsWatcherId: "1", Changes: []string{}},
+ {StringsWatcherId: "2", Changes: []string{}},
+ {Error: apiservertesting.NotFoundError("machine 42")},
+ {Error: apiservertesting.ErrUnauthorized},
+ {Error: apiservertesting.ErrUnauthorized},
+ },
+ })
+
+ // Verify the resources were registered and stop them when done.
+ c.Assert(s.resources.Count(), gc.Equals, 2)
+ m0Watcher := s.resources.Get("1")
+ defer statetesting.AssertStop(c, m0Watcher)
+ m1Watcher := s.resources.Get("2")
+ defer statetesting.AssertStop(c, m1Watcher)
+
+ // Check that the Watch has consumed the initial event ("returned"
+ // in the Watch call)
+ wc0 := statetesting.NewStringsWatcherC(c, s.State, m0Watcher.(state.StringsWatcher))
+ wc0.AssertNoChange()
+ wc1 := statetesting.NewStringsWatcherC(c, s.State, m1Watcher.(state.StringsWatcher))
+ wc1.AssertNoChange()
+}
+
func (s *provisionerSuite) TestWatchForEnvironConfigChanges(c *gc.C) {
c.Assert(s.resources.Count(), gc.Equals, 0)

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b