Esempio n. 1
1
func (s *SelfSuite) TestOutputReporter(c *gc.C) {
	manifold := dependency.SelfManifold(s.engine)
	var reporter dependency.Reporter
	err := manifold.Output(s.engine, &reporter)
	c.Check(err, jc.ErrorIsNil)
	c.Check(reporter, gc.Equals, s.engine)
}
Esempio n. 2
0
func (s *SelfSuite) TestActuallyWorks(c *gc.C) {

	// Create and install a manifold with an unsatisfied dependency.
	mh1 := newManifoldHarness("self")
	err := s.engine.Install("dependent", mh1.Manifold())
	c.Assert(err, jc.ErrorIsNil)
	mh1.AssertNoStart(c)

	// Install an engine inside itself; once it's "started", dependent will
	// be restarted.
	manifold := dependency.SelfManifold(s.engine)
	err = s.engine.Install("self", manifold)
	c.Assert(err, jc.ErrorIsNil)
	mh1.AssertOneStart(c)

	// Check we can still stop it (with a timeout -- injudicious
	// implementation changes could induce deadlocks).
	done := make(chan struct{})
	go func() {
		err := worker.Stop(s.engine)
		c.Check(err, jc.ErrorIsNil)
		close(done)
	}()
	select {
	case <-done:
	case <-time.After(coretesting.LongWait):
		c.Fatalf("timed out")
	}
}
Esempio n. 3
0
func (s *SelfSuite) TestOutputInstaller(c *gc.C) {
	manifold := dependency.SelfManifold(s.engine)
	var installer dependency.Installer
	err := manifold.Output(s.engine, &installer)
	c.Check(err, jc.ErrorIsNil)
	c.Check(installer, gc.Equals, s.engine)
}
Esempio n. 4
0
func (s *SelfSuite) TestOutputBadOutput(c *gc.C) {
	manifold := dependency.SelfManifold(s.engine)
	var unknown interface{}
	err := manifold.Output(s.engine, &unknown)
	c.Check(err, gc.ErrorMatches, "out should be a \\*Installer or a \\*Reporter; is .*")
	c.Check(unknown, gc.IsNil)
}
Esempio n. 5
0
func (s *SelfSuite) TestOutputBadInput(c *gc.C) {
	s.fix.run(c, func(engine dependency.Engine) {
		manifold := dependency.SelfManifold(engine)
		var input dependency.Engine
		err := manifold.Output(input, nil)
		c.Check(err, gc.ErrorMatches, "unexpected input worker")
	})
}
Esempio n. 6
0
func (s *SelfSuite) TestStart(c *gc.C) {
	s.fix.run(c, func(engine dependency.Engine) {
		manifold := dependency.SelfManifold(engine)
		actual, err := manifold.Start(nil)
		c.Check(err, jc.ErrorIsNil)
		c.Check(actual, gc.Equals, engine)
	})
}
Esempio n. 7
0
func (s *SelfSuite) TestOutputInstaller(c *gc.C) {
	s.fix.run(c, func(engine dependency.Engine) {
		manifold := dependency.SelfManifold(engine)
		var installer dependency.Installer
		err := manifold.Output(engine, &installer)
		c.Check(err, jc.ErrorIsNil)
		c.Check(installer, gc.Equals, engine)
	})
}
Esempio n. 8
0
func (s *SelfSuite) TestOutputReporter(c *gc.C) {
	s.fix.run(c, func(engine *dependency.Engine) {
		manifold := dependency.SelfManifold(engine)
		var reporter dependency.Reporter
		err := manifold.Output(engine, &reporter)
		c.Check(err, jc.ErrorIsNil)
		c.Check(reporter, gc.Equals, engine)
	})
}
Esempio n. 9
0
func (s *SelfSuite) TestStress(c *gc.C) {
	s.fix.run(c, func(engine dependency.Engine) {

		// Repeatedly install a manifold inside itself.
		manifold := dependency.SelfManifold(engine)
		for i := 0; i < 100; i++ {
			go engine.Install(fmt.Sprintf("self-%d", i), manifold)
		}

		// Give it a moment to screw up if it's going to
		// (injudicious implementation could induce deadlock)
		// then let the fixture worry about a clean kill.
		workertest.CheckAlive(c, engine)
	})
}
Esempio n. 10
0
func (s *SelfSuite) TestActuallyWorks(c *gc.C) {

	// Install an engine inside itself.
	manifold := dependency.SelfManifold(s.engine)
	err := s.engine.Install("self", manifold)
	c.Assert(err, jc.ErrorIsNil)

	// Check we can still stop it (with a timeout -- injudicious
	// implementation changes could induce deadlocks).
	done := make(chan struct{})
	go func() {
		err := worker.Stop(s.engine)
		c.Check(err, jc.ErrorIsNil)
		close(done)
	}()
	select {
	case <-done:
	case <-time.After(coretesting.LongWait):
		c.Fatalf("timed out")
	}
}
Esempio n. 11
0
func (s *SelfSuite) TestStress(c *gc.C) {

	// Repeatedly install a manifold inside itself.
	manifold := dependency.SelfManifold(s.engine)
	for i := 0; i < 100; i++ {
		go s.engine.Install(fmt.Sprintf("self-%d", i), manifold)
	}

	// Check we can still stop it (with a timeout -- injudicious
	// implementation changes could induce deadlocks).
	done := make(chan struct{})
	go func() {
		err := worker.Stop(s.engine)
		c.Check(err, jc.ErrorIsNil)
		close(done)
	}()
	select {
	case <-done:
	case <-time.After(coretesting.LongWait):
		c.Fatalf("timed out")
	}
}
Esempio n. 12
0
func (s *SelfSuite) TestActuallyWorks(c *gc.C) {
	s.fix.run(c, func(engine dependency.Engine) {

		// Create and install a manifold with an unsatisfied dependency.
		mh1 := newManifoldHarness("self")
		err := engine.Install("dependent", mh1.Manifold())
		c.Assert(err, jc.ErrorIsNil)
		mh1.AssertNoStart(c)

		// Install an engine inside itself; once it's "started", dependent will
		// be restarted.
		manifold := dependency.SelfManifold(engine)
		err = engine.Install("self", manifold)
		c.Assert(err, jc.ErrorIsNil)
		mh1.AssertOneStart(c)

		// Give it a moment to screw up if it's going to
		// (injudicious implementation could induce deadlock)
		// then let the fixture worry about a clean kill.
		workertest.CheckAlive(c, engine)
	})
}
Esempio n. 13
0
func (s *SelfSuite) TestStart(c *gc.C) {
	manifold := dependency.SelfManifold(s.engine)
	engine, err := manifold.Start(nil)
	c.Check(err, jc.ErrorIsNil)
	c.Check(engine, gc.Equals, s.engine)
}
Esempio n. 14
0
func (s *SelfSuite) TestInputs(c *gc.C) {
	manifold := dependency.SelfManifold(s.engine)
	c.Check(manifold.Inputs, gc.HasLen, 0)
}
Esempio n. 15
0
func (s *SelfSuite) TestInputs(c *gc.C) {
	s.fix.run(c, func(engine dependency.Engine) {
		manifold := dependency.SelfManifold(engine)
		c.Check(manifold.Inputs, gc.HasLen, 0)
	})
}