func (tracker *modelTracker) Manifolds(config model.ManifoldsConfig) dependency.Manifolds { const trackerName = "TEST-TRACKER" raw := model.Manifolds(config) uuid := config.Agent.CurrentConfig().Model().Id() names := make([]string, 0, len(raw)) for name := range raw { if name == trackerName { tracker.c.Errorf("manifold tracker used repeatedly") return raw } else { names = append(names, name) } } tracker.mu.Lock() defer tracker.mu.Unlock() if _, exists := tracker.current[uuid]; exists { tracker.c.Errorf("model %s started repeatedly", uuid) return raw } raw[trackerName] = tracker.manifold(uuid, names) return raw }
func (s *ManifoldsSuite) TestFlagDependencies(c *gc.C) { exclusions := set.NewStrings( "agent", "api-caller", "api-config-watcher", "clock", "spaces-imported-gate", "is-responsible-flag", "not-alive-flag", "not-dead-flag", ) manifolds := model.Manifolds(model.ManifoldsConfig{ Agent: &mockAgent{}, }) for name, manifold := range manifolds { c.Logf("checking %s", name) if exclusions.Contains(name) { continue } inputs := set.NewStrings(manifold.Inputs...) if !inputs.Contains("is-responsible-flag") { c.Check(inputs.Contains("migration-fortress"), jc.IsTrue) c.Check(inputs.Contains("migration-inactive-flag"), jc.IsTrue) } } }
func (s *ManifoldsSuite) TestStateCleanerIgnoresLifeFlags(c *gc.C) { manifolds := model.Manifolds(model.ManifoldsConfig{ Agent: &mockAgent{}, }) manifold, found := manifolds["state-cleaner"] c.Assert(found, jc.IsTrue) inputs := set.NewStrings(manifold.Inputs...) c.Check(inputs.Contains("not-alive-flag"), jc.IsFalse) c.Check(inputs.Contains("not-dead-flag"), jc.IsFalse) }
func (s *ManifoldsSuite) TestClockWrapper(c *gc.C) { expectClock := &fakeClock{} manifolds := model.Manifolds(model.ManifoldsConfig{ Agent: &mockAgent{}, Clock: expectClock, }) manifold, ok := manifolds["clock"] c.Assert(ok, jc.IsTrue) worker, err := manifold.Start(nil) c.Assert(err, jc.ErrorIsNil) defer workertest.CheckKill(c, worker) var clock clock.Clock err = manifold.Output(worker, &clock) c.Assert(err, jc.ErrorIsNil) c.Check(clock, gc.Equals, expectClock) }
func (s *ManifoldsSuite) TestResponsibleFlagDependencies(c *gc.C) { exclusions := set.NewStrings( "agent", "api-caller", "clock", "discover-spaces-check-gate", "is-responsible-flag", "not-dead-flag", "not-alive-flag", ) manifolds := model.Manifolds(model.ManifoldsConfig{ Agent: &mockAgent{}, }) for name, manifold := range manifolds { c.Logf("checking %s", name) if exclusions.Contains(name) { continue } inputs := set.NewStrings(manifold.Inputs...) c.Check(inputs.Contains("is-responsible-flag"), jc.IsTrue) } }
func (s *ManifoldsSuite) TestNames(c *gc.C) { actual := set.NewStrings() manifolds := model.Manifolds(model.ManifoldsConfig{ Agent: &mockAgent{}, }) for name := range manifolds { actual.Add(name) } // NOTE: if this test failed, the cmd/jujud/agent tests will // also fail. Search for 'ModelWorkers' to find affected vars. c.Check(actual.Values(), jc.SameContents, []string{ "agent", "clock", "api-caller", "discover-spaces-check-gate", "is-responsible-flag", "not-dead-flag", "not-alive-flag", "environ-tracker", "undertaker", "discover-spaces", "storage-provisioner", "compute-provisioner", "firewaller", "unit-assigner", "service-scaler", "instance-poller", "charm-revision-updater", "metric-worker", "state-cleaner", "address-cleaner", "status-history-pruner", }) }
func (s *ManifoldsSuite) TestNames(c *gc.C) { actual := set.NewStrings() manifolds := model.Manifolds(model.ManifoldsConfig{ Agent: &mockAgent{}, }) for name := range manifolds { actual.Add(name) } // NOTE: if this test failed, the cmd/jujud/agent tests will // also fail. Search for 'ModelWorkers' to find affected vars. c.Check(actual.SortedValues(), jc.DeepEquals, []string{ "agent", "api-caller", "api-config-watcher", "application-scaler", "charm-revision-updater", "clock", "compute-provisioner", "environ-tracker", "firewaller", "instance-poller", "is-responsible-flag", "machine-undertaker", "metric-worker", "migration-fortress", "migration-inactive-flag", "migration-master", "not-alive-flag", "not-dead-flag", "space-importer", "spaces-imported-gate", "state-cleaner", "status-history-pruner", "storage-provisioner", "undertaker", "unit-assigner", }) }