本文整理匯總了Golang中github.com/marmelab/gaudi/maestro.Maestro.GetContainer方法的典型用法代碼示例。如果您正苦於以下問題:Golang Maestro.GetContainer方法的具體用法?Golang Maestro.GetContainer怎麽用?Golang Maestro.GetContainer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/marmelab/gaudi/maestro.Maestro
的用法示例。
在下文中一共展示了Maestro.GetContainer方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: 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)
}
示例2: 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)
}
示例3: 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)
}
示例4: 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")
}