當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Housing.Start方法代碼示例

本文整理匯總了Golang中github.com/juju/juju/cmd/jujud/agent/util.Housing.Start方法的典型用法代碼示例。如果您正苦於以下問題:Golang Housing.Start方法的具體用法?Golang Housing.Start怎麽用?Golang Housing.Start使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/juju/juju/cmd/jujud/agent/util.Housing的用法示例。


在下文中一共展示了Housing.Start方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TestOccupyLocked

func (*HousingSuite) TestOccupyLocked(c *gc.C) {
	manifold := util.Housing{
		Occupy: "fortress",
	}.Decorate(dependency.Manifold{})
	abort := make(chan struct{})
	context := dt.StubContext(abort, map[string]interface{}{
		"fortress": newGuest(false),
	})

	// start the start func
	started := make(chan struct{})
	go func() {
		defer close(started)
		worker, err := manifold.Start(context)
		c.Check(worker, gc.IsNil)
		c.Check(errors.Cause(err), gc.Equals, fortress.ErrAborted)
	}()

	// check it's blocked...
	select {
	case <-time.After(coretesting.ShortWait):
	case <-started:
		c.Errorf("Start finished early")
	}

	// ...until the context is aborted.
	close(abort)
	select {
	case <-started:
	case <-time.After(coretesting.LongWait):
		c.Fatalf("timed out")
	}
}
開發者ID:makyo,項目名稱:juju,代碼行數:33,代碼來源:housing_test.go

示例2: TestOccupyBadType

func (*HousingSuite) TestOccupyBadType(c *gc.C) {
	manifold := util.Housing{
		Occupy: "fortress",
	}.Decorate(dependency.Manifold{})
	context := dt.StubContext(nil, map[string]interface{}{
		"fortress": false,
	})

	worker, err := manifold.Start(context)
	c.Check(worker, gc.IsNil)
	c.Check(err, gc.ErrorMatches, "cannot set false into .*")
}
開發者ID:makyo,項目名稱:juju,代碼行數:12,代碼來源:housing_test.go

示例3: TestOccupyMissing

func (*HousingSuite) TestOccupyMissing(c *gc.C) {
	manifold := util.Housing{
		Occupy: "fortress",
	}.Decorate(dependency.Manifold{})
	context := dt.StubContext(nil, map[string]interface{}{
		"fortress": dependency.ErrMissing,
	})

	worker, err := manifold.Start(context)
	c.Check(worker, gc.IsNil)
	c.Check(errors.Cause(err), gc.Equals, dependency.ErrMissing)
}
開發者ID:makyo,項目名稱:juju,代碼行數:12,代碼來源:housing_test.go

示例4: TestFlagBadValue

func (*HousingSuite) TestFlagBadValue(c *gc.C) {
	manifold := util.Housing{
		Flags: []string{"flag"},
	}.Decorate(dependency.Manifold{})
	context := dt.StubContext(nil, map[string]interface{}{
		"flag": flag{false},
	})

	worker, err := manifold.Start(context)
	c.Check(worker, gc.IsNil)
	c.Check(errors.Cause(err), gc.Equals, dependency.ErrMissing)
}
開發者ID:makyo,項目名稱:juju,代碼行數:12,代碼來源:housing_test.go

示例5: TestFlagBlocksOccupy

func (*HousingSuite) TestFlagBlocksOccupy(c *gc.C) {
	manifold := util.Housing{
		Flags:  []string{"flag"},
		Occupy: "fortress",
	}.Decorate(dependency.Manifold{})
	context := dt.StubContext(nil, map[string]interface{}{
		"flag":     dependency.ErrMissing,
		"fortress": errors.New("never happen"),
	})

	worker, err := manifold.Start(context)
	c.Check(worker, gc.IsNil)
	c.Check(errors.Cause(err), gc.Equals, dependency.ErrMissing)
}
開發者ID:makyo,項目名稱:juju,代碼行數:14,代碼來源:housing_test.go

示例6: TestOccupySuccess

func (*HousingSuite) TestOccupySuccess(c *gc.C) {
	expectWorker := workertest.NewErrorWorker(errors.New("ignored"))
	defer workertest.DirtyKill(c, expectWorker)
	manifold := util.Housing{
		Occupy: "fortress",
	}.Decorate(dependency.Manifold{
		Start: func(dependency.Context) (worker.Worker, error) {
			return expectWorker, nil
		},
	})
	guest := newGuest(true)
	context := dt.StubContext(nil, map[string]interface{}{
		"fortress": guest,
	})

	// wait for the start func to complete
	started := make(chan struct{})
	go func() {
		defer close(started)
		worker, err := manifold.Start(context)
		c.Check(worker, gc.Equals, expectWorker)
		c.Check(err, jc.ErrorIsNil)
	}()
	select {
	case <-started:
	case <-time.After(coretesting.LongWait):
		c.Fatalf("timed out")
	}

	// check the worker's alive
	workertest.CheckAlive(c, expectWorker)

	// check the visit keeps running...
	select {
	case <-time.After(coretesting.ShortWait):
	case <-guest.done:
		c.Fatalf("visit finished early")
	}

	// ...until the worker stops
	expectWorker.Kill()
	select {
	case <-guest.done:
	case <-time.After(coretesting.LongWait):
		c.Fatalf("timed out")
	}
}
開發者ID:makyo,項目名稱:juju,代碼行數:47,代碼來源:housing_test.go

示例7: TestFlagSuccess

func (*HousingSuite) TestFlagSuccess(c *gc.C) {
	expectWorker := &struct{ worker.Worker }{}
	manifold := util.Housing{
		Flags: []string{"flag"},
	}.Decorate(dependency.Manifold{
		Start: func(dependency.Context) (worker.Worker, error) {
			return expectWorker, nil
		},
	})
	context := dt.StubContext(nil, map[string]interface{}{
		"flag": flag{true},
	})

	worker, err := manifold.Start(context)
	c.Check(worker, gc.Equals, expectWorker)
	c.Check(err, jc.ErrorIsNil)
}
開發者ID:makyo,項目名稱:juju,代碼行數:17,代碼來源:housing_test.go

示例8: TestEmptyHousingPopulatedManifold

func (*HousingSuite) TestEmptyHousingPopulatedManifold(c *gc.C) {
	manifold := util.Housing{}.Decorate(dependency.Manifold{
		Inputs: []string{"x", "y", "z"},
		Start:  panicStart,
		Output: panicOutput,
		Filter: panicFilter,
	})

	c.Check(manifold.Inputs, jc.DeepEquals, []string{"x", "y", "z"})
	c.Check(func() {
		manifold.Start(nil)
	}, gc.PanicMatches, "panicStart")
	c.Check(func() {
		manifold.Output(nil, nil)
	}, gc.PanicMatches, "panicOutput")
	c.Check(func() {
		manifold.Filter(nil)
	}, gc.PanicMatches, "panicFilter")
}
開發者ID:makyo,項目名稱:juju,代碼行數:19,代碼來源:housing_test.go


注:本文中的github.com/juju/juju/cmd/jujud/agent/util.Housing.Start方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。