• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang maestro.Maestro类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/marmelab/gaudi/maestro.Maestro的典型用法代码示例。如果您正苦于以下问题:Golang Maestro类的具体用法?Golang Maestro怎么用?Golang Maestro使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Maestro类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: TestInitFromStringShouldCreateAMaestro

func (s *MaestroTestSuite) TestInitFromStringShouldCreateAMaestro(c *C) {
	m := maestro.Maestro{}
	m.InitFromString(`
applications:
    app:
        type: php-fpm
        links: [db]
    db:
        type: mysql
        ports:
            3306: 9000
`, "")

	// Create a gomock controller, and arrange for it's finish to be called
	ctrl := gomock.NewController(c)
	defer ctrl.Finish()
	docker.MOCK().SetController(ctrl)
	docker.EXPECT().Inspect(gomock.Any()).Return([]byte("[{\"ID\": \"123\", \"State\":{\"Running\": false}, \"NetworkSettings\": {\"IPAddress\": \"\"}}]"), nil)

	c.Assert(len(m.Applications), Equals, 2)
	c.Assert(m.GetContainer("app").Name, Equals, "app")
	c.Assert(m.GetContainer("app").Type, Equals, "php-fpm")
	c.Assert(m.GetContainer("app").Dependencies[0].Name, Equals, "db")
	c.Assert(m.GetContainer("db").GetFirstPort(), Equals, "3306")
	c.Assert(m.GetContainer("db").IsRunning(), Equals, false)
}
开发者ID:pborreli,项目名称:gaudi,代码行数:26,代码来源:maestro_unit_test.go


示例2: TestStartApplicationShouldCleanAndBuildThem

func (s *MaestroTestSuite) TestStartApplicationShouldCleanAndBuildThem(c *C) {
	// Create a gomock controller, and arrange for it's finish to be called
	ctrl := gomock.NewController(c)
	defer ctrl.Finish()

	// Setup the docker mock package
	docker.MOCK().SetController(ctrl)
	docker.EXPECT().Kill(gomock.Any()).Return().Times(2)
	docker.EXPECT().Remove(gomock.Any()).Return().Times(2)
	docker.EXPECT().Build(gomock.Any(), gomock.Any()).Return().Times(2)
	docker.EXPECT().Start(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return("123").Times(2)
	docker.EXPECT().Inspect(gomock.Any()).Return([]byte("[{\"ID\": \"123\", \"State\":{\"Running\": false}, \"NetworkSettings\": {\"IPAddress\": \"172.17.0.10\"}}]"), nil).Times(4)

	m := maestro.Maestro{}
	m.InitFromString(`
applications:
    app:
        type: php-fpm
        links: [db]
    db:
        type: mysql
        ports:
            3306: 9000
`, "")

	c.Assert(len(m.Applications), Equals, 2)

	m.Start()
	c.Assert(m.GetContainer("db").IsRunning(), Equals, true)
	c.Assert(m.GetContainer("app").IsRunning(), Equals, true)
}
开发者ID:pborreli,项目名称:gaudi,代码行数:31,代码来源:maestro_unit_test.go


示例3: TestInitFromStringShouldTrowAndErrorOnMalformedYmlContent

func (s *MaestroTestSuite) TestInitFromStringShouldTrowAndErrorOnMalformedYmlContent(c *C) {
	m := maestro.Maestro{}

	c.Assert(func() {
		m.InitFromString(`
		applications:
			tabulated:
				type: varnish
`, "")
	}, PanicMatches, "YAML error: line 1: found character that cannot start any token")
}
开发者ID:pborreli,项目名称:gaudi,代码行数:11,代码来源:maestro_unit_test.go


示例4: main

func main() {
	flag.Parse()

	m := maestro.Maestro{}
	m.InitFromFile(retrieveConfigPath(*config))

	if *check {
		m.Check()
	} else if *stop {
		m.Stop()
	} else {
		m.Start()
	}
}
开发者ID:jpetitcolas,项目名称:gaudi,代码行数:14,代码来源:main.go


示例5: TestCheckRunningContainerShouldUseDockerPs

func (s *MaestroTestSuite) TestCheckRunningContainerShouldUseDockerPs(c *C) {
	// Create a gomock controller, and arrange for it's finish to be called
	ctrl := gomock.NewController(c)
	defer ctrl.Finish()

	// Setup the docker mock package
	docker.MOCK().SetController(ctrl)

	// Setup the mockfmt mock package
	mockfmt.MOCK().SetController(ctrl)

	psResult := make(map[string]string)
	psResult["gaudi/lb"] = "123"
	psResult["gaudi/front1"] = "124"
	psResult["gaudi/db"] = "125"

	docker.EXPECT().SnapshotProcesses().Return(psResult, nil)
	docker.EXPECT().Inspect("123").Return([]byte("[{\"ID\": \"123\", \"State\":{\"Running\": true}, \"NetworkSettings\": {\"IPAddress\": \"123.124.125.126\"}}]"), nil)
	docker.EXPECT().Inspect("124").Return([]byte("[{\"ID\": \"123\", \"State\":{\"Running\": true}, \"NetworkSettings\": {\"IPAddress\": \"123.124.125.127\"}}]"), nil)
	docker.EXPECT().Inspect("125").Return([]byte("[{\"ID\": \"123\", \"State\":{\"Running\": true}, \"NetworkSettings\": {\"IPAddress\": \"123.124.125.128\"}}]"), nil)

	mockfmt.EXPECT().Println("Application", "lb", "is running", "(123.124.125.126:)")
	mockfmt.EXPECT().Println("Application", "front1", "is running", "(123.124.125.127:)")
	mockfmt.EXPECT().Println("Application", "db", "is running", "(123.124.125.128:3306)")

	m := maestro.Maestro{}
	m.InitFromString(`
applications:
    lb:
        links: [front1]
        type: varnish

    front1:
        type: apache

    db:
        type: mysql
        ports:
            3306: 9000
`, "")

	m.Check()
}
开发者ID:jpetitcolas,项目名称:gaudi,代码行数:43,代码来源:maestro_unit_test.go


示例6: TestStartApacheShouldStartedItCorrectly

// Apache
func (s *MaestroTestSuite) TestStartApacheShouldStartedItCorrectly(c *C) {
	m := maestro.Maestro{}
	m.InitFromString(`
applications:
    front:
        type: apache
        ports:
            80: 80
`, "")

	c.Assert(len(m.Applications), Equals, 1)
	m.Start()

	// Test apache is running
	resp, err := http.Get("http://" + m.GetContainer("front").Ip)
	defer resp.Body.Close()

	c.Check(err, Equals, nil)
	c.Check(resp.StatusCode, Equals, 200)
}
开发者ID:jpetitcolas,项目名称:gaudi,代码行数:21,代码来源:maestro_functional_test.go


示例7: TestStartPhpAndApacheShouldStartedThemCorrectly

// Apache + php-fpm
func (s *MaestroTestSuite) TestStartPhpAndApacheShouldStartedThemCorrectly(c *C) {
	err := os.MkdirAll("/tmp/php", 0775)
	ioutil.WriteFile("/tmp/php/ok.php", []byte("<?php echo 'ok';"), 0775)

	m := maestro.Maestro{}
	m.InitFromString(`
applications:
    front:
        type: apache
        links: [app]
        ports:
            80: 80
        volumes:
            /tmp/php: /var/www
        custom:
            fastCgi: app

    app:
        type: php-fpm
        ports:
            9000: 9000
        volumes:
            /tmp/php: /var/www
`, "")

	c.Assert(len(m.Applications), Equals, 2)
	m.Start()
	time.Sleep(2 * time.Second)

	// Test apache is running
	resp, err := http.Get("http://" + m.GetContainer("front").Ip + "/ok.php")
	defer resp.Body.Close()

	content, _ := ioutil.ReadAll(resp.Body)

	c.Check(err, Equals, nil)
	c.Check(resp.StatusCode, Equals, 200)
	c.Check(string(content), Equals, "ok")
}
开发者ID:jpetitcolas,项目名称:gaudi,代码行数:40,代码来源:maestro_functional_test.go


示例8: TestStartApplicationShouldStartThemByOrderOfDependencies

func (s *MaestroTestSuite) TestStartApplicationShouldStartThemByOrderOfDependencies(c *C) {
	// Create a gomock controller, and arrange for it's finish to be called
	ctrl := gomock.NewController(c)
	defer ctrl.Finish()

	// Setup the docker mock package
	docker.MOCK().SetController(ctrl)

	m := maestro.Maestro{}
	m.InitFromString(`
applications:
    lb:
        links: [front1, front2]
        type: varnish

    front1:
        links: [app]
        type: apache

    front2:
        links: [app]
        type: apache

    app:
        links: [db]
        type: php-fpm

    db:
      type: mysql
`, "")

	c.Assert(len(m.Applications), Equals, 5)

	docker.EXPECT().Kill(gomock.Any()).Return().Times(5)
	docker.EXPECT().Remove(gomock.Any()).Return().Times(5)
	docker.EXPECT().Build(gomock.Any(), gomock.Any()).Return().Times(5)

	gomock.InOrder(
		docker.EXPECT().Inspect("db").Return([]byte("[{\"ID\": \"100\", \"State\":{\"Running\": false}, \"NetworkSettings\": {\"IPAddress\": \"172.17.0.10\"}}]"), nil),
		docker.EXPECT().Start("db", gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return("100"),
		docker.EXPECT().Inspect("100").Return([]byte("[{\"ID\": \"100\", \"State\":{\"Running\": true}, \"NetworkSettings\": {\"IPAddress\": \"172.17.0.10\"}}]"), nil),

		docker.EXPECT().Inspect("app").Return([]byte("[{\"ID\": \"101\", \"State\":{\"Running\": false}, \"NetworkSettings\": {\"IPAddress\": \"172.17.0.10\"}}]"), nil),
		docker.EXPECT().Start("app", gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return("101"),
		docker.EXPECT().Inspect("101").Return([]byte("[{\"ID\": \"101\", \"State\":{\"Running\": true}, \"NetworkSettings\": {\"IPAddress\": \"172.17.0.10\"}}]"), nil),

		docker.EXPECT().Inspect("front1").Return([]byte("[{\"ID\": \"102\", \"State\":{\"Running\": false}, \"NetworkSettings\": {\"IPAddress\": \"172.17.0.10\"}}]"), nil),
		docker.EXPECT().Start("front1", gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return("102"),

		docker.EXPECT().Inspect("front2").Return([]byte("[{\"ID\": \"103\", \"State\":{\"Running\": false}, \"NetworkSettings\": {\"IPAddress\": \"172.17.0.10\"}}]"), nil),
		docker.EXPECT().Start("front2", gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return("103"),

		docker.EXPECT().Inspect("102").Return([]byte("[{\"ID\": \"102\", \"State\":{\"Running\": true}, \"NetworkSettings\": {\"IPAddress\": \"172.17.0.10\"}}]"), nil),
		docker.EXPECT().Inspect("103").Return([]byte("[{\"ID\": \"103\", \"State\":{\"Running\": true}, \"NetworkSettings\": {\"IPAddress\": \"172.17.0.10\"}}]"), nil),

		docker.EXPECT().Inspect("lb").Return([]byte("[{\"ID\": \"104\", \"State\":{\"Running\": false}, \"NetworkSettings\": {\"IPAddress\": \"172.17.0.10\"}}]"), nil),
		docker.EXPECT().Start("lb", gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return("104"),
		docker.EXPECT().Inspect("104").Return([]byte("[{\"ID\": \"104\", \"State\":{\"Running\": true}, \"NetworkSettings\": {\"IPAddress\": \"172.17.0.10\"}}]"), nil),
	)

	m.Start()
}
开发者ID:pborreli,项目名称:gaudi,代码行数:62,代码来源:maestro_unit_test.go


示例9: TestInitFromStringShouldTrowAndErrorOnWrongContent

func (s *MaestroTestSuite) TestInitFromStringShouldTrowAndErrorOnWrongContent(c *C) {
	m := maestro.Maestro{}

	c.Assert(func() { m.InitFromString("<oldFormat>Skrew you, i'm not yml</oldFormat>", "") }, PanicMatches, "No application to start")
}
开发者ID:pborreli,项目名称:gaudi,代码行数:5,代码来源:maestro_unit_test.go



注:本文中的github.com/marmelab/gaudi/maestro.Maestro类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang util.LogError函数代码示例发布时间:2022-05-23
下一篇:
Golang gaudi.Gaudi类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap