当前位置: 首页>>代码示例>>Golang>>正文


Golang gaudi.Gaudi类代码示例

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


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

示例1: TestEnterContainerShouldUseNsEnter

func (s *GaudiTestSuite) TestEnterContainerShouldUseNsEnter(c *C) {
	os.RemoveAll("/var/tmp/gaudi/")

	// 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 util mock package
	util.MOCK().SetController(ctrl)

	// Disable the util package mock
	util.MOCK().DisableMock("IsDir")
	util.MOCK().DisableMock("IsFile")

	util.EXPECT().PrintGreen("Retrieving templates ...")

	images := make(map[string]string)
	images["jpetazzo/nsenter"] = "123"

	docker.EXPECT().ImageExists(gomock.Any()).Return(true).Times(1)
	docker.EXPECT().HasDocker().Return(true).Times(1)
	docker.EXPECT().GetImages().Return(images, nil).Times(1)
	docker.EXPECT().Enter(gomock.Any()).Times(1)

	g := gaudi.Gaudi{}
	g.Init(`
applications:
    app:
        type: apache
`)
	g.Enter("app")
}
开发者ID:hungld,项目名称:gaudi,代码行数:35,代码来源:gaudi_unit_test.go

示例2: TestExtendsShouldThrowAnErrorWhenTheElementDoesNotExists

func (s *GaudiTestSuite) TestExtendsShouldThrowAnErrorWhenTheElementDoesNotExists(c *C) {
	os.RemoveAll("/var/tmp/gaudi/")

	// Create a gomock controller, and arrange for it's finish to be called
	ctrl := gomock.NewController(c)
	defer ctrl.Finish()
	docker.MOCK().SetController(ctrl)

	util.MOCK().DisableMock("IsDir")
	util.MOCK().DisableMock("IsFile")
	util.MOCK().DisableMock("LogError")

	disableLog()

	g := gaudi.Gaudi{}

	c.Assert(func() {
		g.Init(`
applications:
    a:
        type: apache
    b:
        extends: c
`)
	}, PanicMatches, "b extends a non existing application : c")

	enableLog()
}
开发者ID:nidhisarvaiya,项目名称:gaudi,代码行数:28,代码来源:gaudi_unit_test.go

示例3: TestInitShouldTrowAndErrorOnWrongContent

func (s *GaudiTestSuite) TestInitShouldTrowAndErrorOnWrongContent(c *C) {
	g := gaudi.Gaudi{}

	// Disable the util package mock
	util.MOCK().DisableMock("LogError")

	c.Assert(func() { g.Init("<oldFormat>Skrew you, i'm not yml</oldFormat>") }, Panics, "No application or binary to start. Are you missing a 'applications' or 'binaries' field in your configuration ?")
}
开发者ID:nidhisarvaiya,项目名称:gaudi,代码行数:8,代码来源:gaudi_unit_test.go

示例4: TestCheckRunningContainerShouldUseDockerPs

func (s *GaudiTestSuite) TestCheckRunningContainerShouldUseDockerPs(c *C) {
	os.RemoveAll("/var/tmp/gaudi/templates/")

	// 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 util mock package
	util.MOCK().SetController(ctrl)

	// Disable the util package mock
	util.MOCK().DisableMock("IsDir")
	util.MOCK().DisableMock("IsFile")

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

	util.EXPECT().PrintGreen("Retrieving templates ...").Times(1)

	docker.EXPECT().ImageExists(gomock.Any()).Return(true).Times(1)
	docker.EXPECT().HasDocker().Return(true).Times(1)
	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)

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

	g := gaudi.Gaudi{}
	g.Init(`
applications:
    lb:
        links: [front1]
        type: varnish

    front1:
        type: apache

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

	g.Check()
}
开发者ID:nidhisarvaiya,项目名称:gaudi,代码行数:54,代码来源:gaudi_unit_test.go

示例5: TestInitShouldTrowAndErrorOnMalformedYmlContent

func (s *GaudiTestSuite) TestInitShouldTrowAndErrorOnMalformedYmlContent(c *C) {
	g := gaudi.Gaudi{}

	// Disable the util package mock
	util.MOCK().DisableMock("LogError")

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

示例6: TestExtendsShouldCopyElements

func (s *GaudiTestSuite) TestExtendsShouldCopyElements(c *C) {
	os.RemoveAll("/var/tmp/gaudi/")

	// Create a gomock controller, and arrange for it's finish to be called
	ctrl := gomock.NewController(c)
	defer ctrl.Finish()
	docker.MOCK().SetController(ctrl)

	util.MOCK().DisableMock("IsDir")
	util.MOCK().DisableMock("IsFile")

	disableLog()

	docker.EXPECT().ImageExists(gomock.Any()).Return(true).Times(1)
	docker.EXPECT().HasDocker().Return(true).Times(1)

	g := gaudi.Gaudi{}

	g.Init(`
applications:
    a:
        type: apache
        before_script: echo hello
    b:
        extends: a
    c:
        extends: a
        before_script: echo ok
    d:
        extends: c
        type: mysql
`)

	c.Check(g.Applications["a"].Type, Equals, "apache")
	c.Check(g.Applications["b"].BeforeScript, Equals, "echo hello")

	c.Check(g.Applications["b"].Type, Equals, "apache")
	c.Check(g.Applications["b"].BeforeScript, Equals, "echo hello")

	c.Check(g.Applications["c"].Type, Equals, "apache")
	c.Check(g.Applications["c"].BeforeScript, Equals, "echo ok")

	c.Check(g.Applications["d"].Type, Equals, "mysql")
	c.Check(g.Applications["d"].BeforeScript, Equals, "echo ok")

	enableLog()
}
开发者ID:nidhisarvaiya,项目名称:gaudi,代码行数:47,代码来源:gaudi_unit_test.go

示例7: TestStartApplicationShouldCleanAndBuildThem

func (s *GaudiTestSuite) TestStartApplicationShouldCleanAndBuildThem(c *C) {
	os.RemoveAll("/var/tmp/gaudi/templates/")

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

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

	util.MOCK().DisableMock("IsFile")
	util.MOCK().DisableMock("IsDir")

	// Retrieving templates (1)
	util.EXPECT().PrintGreen(gomock.Any()).Times(1)
	// Killing, Clearing, Building, Starting (3*2)
	util.EXPECT().PrintGreen(gomock.Any(), gomock.Any(), gomock.Any()).Times(6)
	// Started (1*2)
	util.EXPECT().PrintGreen(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Times(2)

	// Setup the docker mock package
	docker.MOCK().SetController(ctrl)
	docker.EXPECT().ImageExists(gomock.Any()).Return(true).Times(1)
	docker.EXPECT().HasDocker().Return(true).Times(1)
	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(), 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(2)

	g := gaudi.Gaudi{}
	g.Init(`
applications:
    app:
        type: php-fpm
        links: [db]
    db:
        type: mysql
        ports:
            3306: 9000
`)

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

	g.StartApplications(true)
	c.Assert(g.GetApplication("db").IsRunning(), Equals, true)
	c.Assert(g.GetApplication("app").IsRunning(), Equals, true)
}
开发者ID:nidhisarvaiya,项目名称:gaudi,代码行数:48,代码来源:gaudi_unit_test.go

示例8: TestUseCustomTemplateShouldUseIt

func (s *GaudiTestSuite) TestUseCustomTemplateShouldUseIt(c *C) {
	os.RemoveAll("/var/tmp/gaudi/")

	// Create a gomock controller, and arrange for it's finish to be called
	ctrl := gomock.NewController(c)
	defer ctrl.Finish()
	docker.MOCK().SetController(ctrl)

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

	util.MOCK().EnableMock("IsDir")
	util.MOCK().EnableMock("IsFile")
	util.MOCK().EnableMock("LogError")

	g := gaudi.Gaudi{}
	g.ApplicationDir = "/vagrant"

	docker.EXPECT().HasDocker().Return(true).Times(1)
	docker.EXPECT().ImageExists(gomock.Any()).Return(true).Times(1)

	util.EXPECT().IsDir("/var/tmp/gaudi/templates/").Return(false)
	util.EXPECT().IsFile("/vagrant/.gaudi/version.txt").Return(false)
	util.EXPECT().PrintGreen("Retrieving templates ...")

	util.EXPECT().IsFile("/vagrant/front/Dockerfile").Return(true).Times(3)
	util.EXPECT().LogError("Application 'custom' is not supported. Check http://gaudi.io/components.html for a list of supported applications.").Times(3)

	g.Init(`
applications:
    app:
        type: custom
        template: ./front/Dockerfile

    app2:
        type: custom
        template: front/Dockerfile

    app3:
        type: custom
        template: /vagrant/front/Dockerfile
`)
}
开发者ID:nidhisarvaiya,项目名称:gaudi,代码行数:43,代码来源:gaudi_unit_test.go

示例9: TestStartBinariesShouldCleanAndBuildThem

func (s *GaudiTestSuite) TestStartBinariesShouldCleanAndBuildThem(c *C) {
	os.RemoveAll("/var/tmp/gaudi/")

	// 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 util mock package
	util.MOCK().SetController(ctrl)

	// Disable the util package mock
	util.MOCK().DisableMock("IsDir")
	util.MOCK().DisableMock("IsFile")

	util.EXPECT().PrintGreen("Retrieving templates ...")

	docker.EXPECT().ImageExists(gomock.Any()).Return(true).Times(1)
	docker.EXPECT().HasDocker().Return(true).Times(1)
	docker.EXPECT().ShouldRebuild(gomock.Any()).Return(true).Times(1)

	util.EXPECT().PrintGreen("Building", "gaudi/npm", "...")
	docker.EXPECT().Build(gomock.Any(), gomock.Any()).Times(1)

	util.EXPECT().PrintGreen("Running", "npm", "update", "...")
	docker.EXPECT().Run(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return().Times(1)

	g := gaudi.Gaudi{}
	g.Init(`
binaries:
    npm:
        type: npm
`)

	c.Assert(len(g.Applications), Equals, 0)
	c.Assert(len(g.Binaries), Equals, 1)

	g.Run("npm", []string{"update"})
}
开发者ID:nidhisarvaiya,项目名称:gaudi,代码行数:41,代码来源:gaudi_unit_test.go

示例10: TestInitShouldCreateApplications

func (s *GaudiTestSuite) TestInitShouldCreateApplications(c *C) {
	os.RemoveAll("/var/tmp/gaudi/")

	// Create a gomock controller, and arrange for it's finish to be called
	ctrl := gomock.NewController(c)
	defer ctrl.Finish()
	docker.MOCK().SetController(ctrl)

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

	// Disable the util package mock
	util.MOCK().DisableMock("IsDir")
	util.MOCK().DisableMock("IsFile")

	util.EXPECT().PrintGreen("Retrieving templates ...")

	docker.EXPECT().ImageExists(gomock.Any()).Return(true).Times(1)
	docker.EXPECT().HasDocker().Return(true).Times(1)
	docker.EXPECT().Inspect(gomock.Any()).Return([]byte("[{\"ID\": \"123\", \"State\":{\"Running\": false}, \"NetworkSettings\": {\"IPAddress\": \"\"}}]"), nil)

	g := gaudi.Gaudi{}
	g.Init(`
applications:
    app:
        type: php-fpm
        links: [db]
    db:
        type: mysql
        ports:
            3306: 9000
`)

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

示例11: TestStartApacheShouldStartedItCorrectly

// Apache
func (s *GaudiTestSuite) TestStartApacheShouldStartedItCorrectly(c *C) {
	g := gaudi.Gaudi{}
	g.Init(`
applications:
    front:
        type: apache
        ports:
            80: 80
`)

	c.Assert(len(g.Applications), Equals, 1)
	g.StartApplications(true)

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

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

示例12: TestStartPhpAndApacheShouldStartedThemCorrectly

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

	g := gaudi.Gaudi{}
	g.Init(`
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(g.Applications), Equals, 2)
	g.StartApplications(true)
	time.Sleep(2 * time.Second)

	// Test apache is running
	resp, err := http.Get("http://" + g.GetApplication("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:hungld,项目名称:gaudi,代码行数:40,代码来源:gaudi_functional_test.go

示例13: TestStartApplicationShouldStartThemByOrderOfDependencies

func (s *GaudiTestSuite) TestStartApplicationShouldStartThemByOrderOfDependencies(c *C) {
	os.RemoveAll("/var/tmp/gaudi/templates/")

	// 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 util mock package
	util.MOCK().SetController(ctrl)

	// Disable the util package mock
	util.MOCK().DisableMock("IsDir")
	util.MOCK().DisableMock("IsFile")
	util.MOCK().EnableMock("PrintGreen")

	// Retrieving templates (1)
	util.EXPECT().PrintGreen(gomock.Any()).Times(1)
	// Killing, Clearing, Building, Starting (3*5)
	util.EXPECT().PrintGreen(gomock.Any(), gomock.Any(), gomock.Any()).Times(15)
	// Started (1*5)
	util.EXPECT().PrintGreen(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Times(5)

	docker.EXPECT().ImageExists(gomock.Any()).Return(true).Times(1)
	docker.EXPECT().HasDocker().Return(true).Times(1)
	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().Start("db", gomock.Any(), 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().Start("app", gomock.Any(), 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().Start("front1", gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return("102"),

		docker.EXPECT().Start("front2", gomock.Any(), 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().Start("lb", gomock.Any(), 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),
	)

	g := gaudi.Gaudi{}
	g.Init(`
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
`)

	g.StartApplications(true)
	c.Assert(len(g.Applications), Equals, 5)
}
开发者ID:nidhisarvaiya,项目名称:gaudi,代码行数:75,代码来源:gaudi_unit_test.go

示例14: main

func main() {
	flag.Parse()

	if *flagVersion {
		fmt.Println(gaudi.VERSION)
		return
	}

	rebuild := len(flag.Args()) > 0 && flag.Args()[0] == "rebuild"
	g := gaudi.Gaudi{}
	g.InitFromFile(retrieveConfigPath(*config))

	if len(flag.Args()) == 0 || rebuild {
		// Start all applications
		g.StartApplications(rebuild)
	} else {
		switch os.Args[1] {
		case "run":
			// Run a specific command
			g.Run(os.Args[2], os.Args[3:])
			break
		case "enter":
			// Enter in a specific container
			g.Enter(os.Args[2])
			break
		case "stop":
			// Stop all applications
			g.StopApplications()
			break
		case "check":
			// Check if all applications are running
			g.Check()
			break
		case "clean":
			// Clean application containers
			g.Clean()
			break
		default:
			util.LogError("Argument " + os.Args[1] + " was not found")
			break
		}
	}
}
开发者ID:hungld,项目名称:gaudi,代码行数:43,代码来源:main.go


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