示例#1
0
func (s *Suite) TestCheckKillTimeout(c *gc.C) {
	w := workertest.NewForeverWorker(nil)
	defer w.ReallyKill()

	err := workertest.CheckKill(c, w)
	s.CheckFailed(c)
	c.Check(err, gc.ErrorMatches, "workertest: worker not stopping")
}
示例#2
0
func (s *Suite) TestCheckKillSuccess(c *gc.C) {
	expect := errors.New("fledbon")
	w := workertest.NewErrorWorker(expect)
	defer workertest.DirtyKill(c, w)

	err := workertest.CheckKill(c, w)
	c.Check(err, gc.Equals, expect)
}
示例#3
0
文件: socket_test.go 项目: bac/juju
func (s *suite) TestStartStop(c *gc.C) {
	if runtime.GOOS != "linux" {
		c.Skip("introspection worker not supported on non-linux")
	}

	w, err := introspection.NewWorker(introspection.Config{
		SocketName: "introspection-test",
	})
	c.Assert(err, jc.ErrorIsNil)
	workertest.CheckKill(c, w)
}
示例#4
0
文件: socket_test.go 项目: bac/juju
func (s *introspectionSuite) startWorker(c *gc.C) {
	s.name = fmt.Sprintf("introspection-test-%d", os.Getpid())
	w, err := introspection.NewWorker(introspection.Config{
		SocketName: s.name,
		Reporter:   s.reporter,
	})
	c.Assert(err, jc.ErrorIsNil)
	s.worker = w
	s.AddCleanup(func(c *gc.C) {
		workertest.CheckKill(c, w)
	})
}
示例#5
0
func (s *LogForwarderSuite) checkClose(c *gc.C, lf worker.Worker, expected error) {
	go func() {
		s.sender.waitBeforeClose(c)
	}()
	var err error
	if expected == nil {
		workertest.CleanKill(c, lf)
	} else {
		err = workertest.CheckKill(c, lf)
	}
	c.Check(errors.Cause(err), gc.Equals, expected)
	s.stub.CheckCallNames(c, "Close")
}
示例#6
0
文件: socket_test.go 项目: bac/juju
func (s *introspectionSuite) TestEngineReporter(c *gc.C) {
	// We need to make sure the existing worker is shut down
	// so we can connect to the socket.
	workertest.CheckKill(c, s.worker)
	s.reporter = &reporter{
		values: map[string]interface{}{
			"working": true,
		},
	}
	s.startWorker(c)
	buf := s.call(c, "/depengine/")

	matches(c, buf, "200 OK")
	matches(c, buf, "working: true")
}
示例#7
0
文件: dumb_test.go 项目: bac/juju
func (*DumbWorkersSuite) TestLeadershipManagerFails(c *gc.C) {
	fix := BasicFixture()
	fix.LW_errors = []error{errors.New("zap")}
	fix.RunDumb(c, func(ctx Context, dw *workers.DumbWorkers) {
		w := NextWorker(c, ctx.LWs())
		c.Assert(w, gc.NotNil)
		AssertWorker(c, dw.LeadershipManager(), w)

		w.Kill()
		workertest.CheckAlive(c, dw)
		AssertWorker(c, dw.LeadershipManager(), w)

		err := workertest.CheckKill(c, dw)
		c.Check(err, gc.ErrorMatches, "error stopping leadership lease manager: zap")
	})
}
示例#8
0
文件: dumb_test.go 项目: bac/juju
func (*DumbWorkersSuite) TestTxnLogWatcherFails(c *gc.C) {
	fix := BasicFixture()
	fix.TLW_errors = []error{errors.New("zap")}
	fix.RunDumb(c, func(ctx Context, dw *workers.DumbWorkers) {
		w := NextWorker(c, ctx.TLWs())
		c.Assert(w, gc.NotNil)
		AssertWorker(c, dw.TxnLogWatcher(), w)

		w.Kill()
		workertest.CheckAlive(c, dw)
		AssertWorker(c, dw.TxnLogWatcher(), w)

		err := workertest.CheckKill(c, dw)
		c.Check(err, gc.ErrorMatches, "error stopping transaction log watcher: zap")
	})
}
示例#9
0
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)
}
示例#10
0
func (*RestartWorkersSuite) TestLeadershipManagerDelay(c *gc.C) {
	fix := BasicFixture()
	fix.LW_errors = []error{errors.New("oof")}
	fix.RunRestart(c, func(ctx Context, rw *workers.RestartWorkers) {
		w := NextWorker(c, ctx.LWs())
		c.Assert(w, gc.NotNil)
		AssertWorker(c, rw.LeadershipManager(), w)
		w.Kill()

		clock := ctx.Clock()
		WaitAlarms(c, clock, 1)
		clock.Advance(almostFiveSeconds)
		AssertWorker(c, rw.LeadershipManager(), w)

		err := workertest.CheckKill(c, rw)
		c.Check(err, gc.ErrorMatches, "error stopping leadership lease manager: oof")
	})
}
示例#11
0
文件: dumb_test.go 项目: bac/juju
func (*DumbWorkersSuite) TestEverythingFails(c *gc.C) {
	fix := Fixture{
		LW_errors:  []error{errors.New("zot")},
		SW_errors:  []error{errors.New("bif")},
		TLW_errors: []error{errors.New("pow")},
		PW_errors:  []error{errors.New("arg")},
	}
	fix.RunDumb(c, func(ctx Context, dw *workers.DumbWorkers) {
		for _, ch := range []<-chan worker.Worker{
			ctx.LWs(), ctx.SWs(), ctx.TLWs(), ctx.PWs(),
		} {
			w := NextWorker(c, ch)
			c.Assert(w, gc.NotNil)
			w.Kill()
		}

		workertest.CheckAlive(c, dw)
		err := workertest.CheckKill(c, dw)
		c.Check(err, gc.ErrorMatches, "error stopping transaction log watcher: pow")
	})
}