コード例 #1
0
ファイル: git_test.go プロジェクト: rpeterson/tsuru
func (s *S) TestDeployLogsActions(c *gocheck.C) {
	h := &testing.TestHandler{}
	gandalfServer := testing.StartGandalfTestServer(h)
	defer gandalfServer.Close()
	provisioner := testing.NewFakeProvisioner()
	provisioner.PrepareOutput([]byte(""))
	provisioner.PrepareOutput([]byte("updated"))
	app := testing.NewFakeApp("cribcaged", "python", 1)
	provisioner.Provision(app)
	w := &bytes.Buffer{}
	err := Git(provisioner, app, "5734f0042844fdeb5bbc1b72b18f2dc1779cade7", w)
	c.Assert(err, gocheck.IsNil)
	logs := w.String()
	expected := `
 ---> Tsuru receiving push

 ---> Replicating the application repository across units

 ---> Installing dependencies

 ---> Restarting application
Restarting app...
 ---> Deploy done!

`
	c.Assert(logs, gocheck.Equals, expected)
}
コード例 #2
0
ファイル: suite_test.go プロジェクト: bardusco/tsuru
func (s *S) SetUpSuite(c *gocheck.C) {
	var err error
	config.Set("database:url", "127.0.0.1:27017")
	config.Set("database:name", "tsuru_collector_test")
	s.conn, err = db.Conn()
	c.Assert(err, gocheck.IsNil)
	s.provisioner = ttesting.NewFakeProvisioner()
	app.Provisioner = s.provisioner
	config.Set("queue-server", "127.0.0.1:0")
}
コード例 #3
0
ファイル: suite_test.go プロジェクト: JoeyFan/tsuru
func (s *S) SetUpSuite(c *C) {
	var err error
	db.Session, err = db.Open("127.0.0.1:27017", "tsuru_collector_test")
	c.Assert(err, IsNil)
	s.provisioner = ttesting.NewFakeProvisioner()
	app.Provisioner = s.provisioner
	err = config.ReadConfigFile("../etc/tsuru.conf")
	c.Assert(err, IsNil)
	config.Set("queue-server", "127.0.0.1:0")
}
コード例 #4
0
ファイル: git_test.go プロジェクト: rpeterson/tsuru
func (s *S) TestCheckoutFailure(c *gocheck.C) {
	p := testing.NewFakeProvisioner()
	p.PrepareOutput([]byte("failed to update"))
	p.PrepareFailure("ExecuteCommand", errors.New("exit status 128"))
	app := testing.NewFakeApp("moon", "python", 1)
	out, err := checkout(p, app, "5734f0042844fdeb5bbc1b72b18f2dc1779cade7")
	c.Assert(err, gocheck.NotNil)
	c.Assert(err.Error(), gocheck.Equals, "exit status 128")
	c.Assert(string(out), gocheck.Equals, "failed to update")
}
コード例 #5
0
ファイル: git_test.go プロジェクト: rpeterson/tsuru
func (s *S) TestCheckout(c *gocheck.C) {
	p := testing.NewFakeProvisioner()
	p.PrepareOutput([]byte("updated"))
	app := testing.NewFakeApp("moon", "python", 1)
	out, err := checkout(p, app, "5734f0042844fdeb5bbc1b72b18f2dc1779cade7")
	c.Assert(err, gocheck.IsNil)
	c.Assert(out, gocheck.IsNil)
	path, _ := repository.GetPath()
	expectedCommand := fmt.Sprintf("cd %s && git checkout 5734f0042844fdeb5bbc1b72b18f2dc1779cade7", path)
	c.Assert(p.GetCmds(expectedCommand, app), gocheck.HasLen, 1)
}
コード例 #6
0
ファイル: main_test.go プロジェクト: rpeterson/tsuru
func (s *S) TestShouldRegisterAllCommandsFromProvisioners(c *gocheck.C) {
	fp := testing.NewFakeProvisioner()
	p := testing.CommandableProvisioner{FakeProvisioner: *fp}
	provision.Register("comm", &p)
	manager := buildManager()
	fake, ok := manager.Commands["fake"]
	c.Assert(ok, gocheck.Equals, true)
	tsrFake, ok := fake.(*tsrCommand)
	c.Assert(ok, gocheck.Equals, true)
	c.Assert(tsrFake.Command, gocheck.FitsTypeOf, &testing.FakeCommand{})
}
コード例 #7
0
ファイル: suite_test.go プロジェクト: nedmax/tsuru
func (s *S) SetUpSuite(c *gocheck.C) {
	err := config.ReadConfigFile("testdata/config.yaml")
	s.conn, err = db.Conn()
	c.Assert(err, gocheck.IsNil)
	s.createUserAndTeam(c)
	s.t = &tsuruTesting.T{}
	s.t.StartAmzS3AndIAM(c)
	s.t.SetGitConfs(c)
	s.provisioner = tsuruTesting.NewFakeProvisioner()
	app.Provisioner = s.provisioner
}
コード例 #8
0
ファイル: git_test.go プロジェクト: rpeterson/tsuru
func (s *S) TestPullRepository(c *gocheck.C) {
	p := testing.NewFakeProvisioner()
	p.PrepareOutput([]byte("pulled"))
	app := testing.NewFakeApp("your", "python", 1)
	out, err := fetch(p, app)
	c.Assert(err, gocheck.IsNil)
	c.Assert(string(out), gocheck.Equals, "pulled")
	path, _ := repository.GetPath()
	expectedCommand := fmt.Sprintf("cd %s && git fetch origin", path)
	c.Assert(p.GetCmds(expectedCommand, app), gocheck.HasLen, 1)
}
コード例 #9
0
ファイル: git_test.go プロジェクト: richardjoo/tsuru
func (s *S) TestCloneRepository(c *gocheck.C) {
	p := testing.NewFakeProvisioner()
	p.PrepareOutput([]byte("something"))
	app := testing.NewFakeApp("your", "python", 1)
	out, err := clone(p, app)
	c.Assert(err, gocheck.IsNil)
	c.Assert(string(out), gocheck.Equals, "something")
	url := repository.ReadOnlyURL(app.GetName())
	path, _ := repository.GetPath()
	expectedCommand := fmt.Sprintf("git clone %s %s --depth 1", url, path)
	c.Assert(p.GetCmds(expectedCommand, app), gocheck.HasLen, 1)
}
コード例 #10
0
ファイル: git_test.go プロジェクト: richardjoo/tsuru
func (s *S) TestDeploy(c *gocheck.C) {
	provisioner := testing.NewFakeProvisioner()
	provisioner.PrepareOutput([]byte("cloned"))
	app := testing.NewFakeApp("cribcaged", "python", 1)
	w := &bytes.Buffer{}
	err := Git(provisioner, app, w)
	c.Assert(err, gocheck.IsNil)
	c.Assert(app.Commands, gocheck.DeepEquals, []string{"restart"})
	c.Assert(provisioner.InstalledDeps(app), gocheck.Equals, 1)
	cloneCommand := "git clone git://tsuruhost.com/cribcaged.git test/dir --depth 1"
	c.Assert(provisioner.GetCmds(cloneCommand, app), gocheck.HasLen, 1)
}
コード例 #11
0
ファイル: bind_test.go プロジェクト: nkts/golang-devops-stuff
func (s *S) SetUpSuite(c *gocheck.C) {
	var err error
	config.Set("database:url", "127.0.0.1:27017")
	config.Set("database:name", "tsuru_service_bind_test")
	config.Set("auth:salt", "test_salt")
	s.conn, err = db.Conn()
	c.Assert(err, gocheck.IsNil)
	s.user = auth.User{Email: "*****@*****.**"}
	s.user.Create()
	s.team = auth.Team{Name: "metallica", Users: []string{s.user.Email}}
	s.conn.Teams().Insert(s.team)
	app.Provisioner = ttesting.NewFakeProvisioner()
}
コード例 #12
0
func (s *S) SetUpSuite(c *gocheck.C) {
	err := config.ReadConfigFile("testdata/config.yaml")
	c.Assert(err, gocheck.IsNil)
	s.conn, err = db.Conn()
	c.Assert(err, gocheck.IsNil)
	s.t = &ttesting.T{}
	s.createUserAndTeam(c)
	s.t.StartAmzS3AndIAM(c)
	s.t.SetGitConfs(c)
	s.provisioner = ttesting.NewFakeProvisioner()
	Provisioner = s.provisioner
	platform := Platform{Name: "python"}
	s.conn.Platforms().Insert(platform)
}
コード例 #13
0
ファイル: router_test.go プロジェクト: rif/golang-stuff
func (s *S) SetUpSuite(c *gocheck.C) {
	var err error
	s.server, err = elbtest.NewServer()
	c.Assert(err, gocheck.IsNil)
	config.Set("juju:elb-endpoint", s.server.URL())
	config.Set("juju:use-elb", true)
	region := aws.SAEast
	region.ELBEndpoint = s.server.URL()
	s.client = elb.New(aws.Auth{AccessKey: "some", SecretKey: "thing"}, region)
	c.Assert(err, gocheck.IsNil)
	config.Set("juju:elb-avail-zones", []interface{}{"my-zone-1a", "my-zone-1b"})
	config.Set("aws:access-key-id", "access")
	config.Set("aws:secret-access-key", "s3cr3t")
	s.provisioner = testing.NewFakeProvisioner()
	app.Provisioner = s.provisioner
}
コード例 #14
0
ファイル: bench_test.go プロジェクト: rpeterson/tsuru
func BenchmarkUpdate(b *testing.B) {
	b.StopTimer()
	config.Set("database:url", "127.0.0.1:27017")
	config.Set("database:name", "collector-benchmark")
	conn, err := db.Conn()
	if err != nil {
		panic(err)
	}
	defer conn.Apps().Database.DropDatabase()
	_, names := getFakeApps(conn)
	app.Provisioner = ttesting.NewFakeProvisioner()
	fakeUnits := getFakeUnits(names)
	b.StartTimer()
	for i := 0; i < b.N; i++ {
		update(fakeUnits)
	}
}
コード例 #15
0
ファイル: suite_test.go プロジェクト: nedmax/tsuru
func (s *S) SetUpSuite(c *gocheck.C) {
	err := config.ReadConfigFile("testdata/config.yaml")
	c.Assert(err, gocheck.IsNil)
	s.conn, err = db.Conn()
	c.Assert(err, gocheck.IsNil)
	s.rfs = &ftesting.RecordingFs{}
	file, err := s.rfs.Create("/dev/urandom")
	c.Assert(err, gocheck.IsNil)
	file.Write([]byte{16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31})
	fsystem = s.rfs
	s.t = &ttesting.T{}
	s.createUserAndTeam(c)
	s.t.StartAmzS3AndIAM(c)
	s.t.SetGitConfs(c)
	s.provisioner = ttesting.NewFakeProvisioner()
	Provisioner = s.provisioner
}
コード例 #16
0
ファイル: git_test.go プロジェクト: johnvilsack/golang-stuff
func (s *S) TestDeploy(c *gocheck.C) {
	provisioner := testing.NewFakeProvisioner()
	provisioner.PrepareOutput([]byte("cloned"))
	provisioner.PrepareOutput([]byte("updated"))
	app := testing.NewFakeApp("cribcaged", "python", 1)
	provisioner.Provision(app)
	w := &bytes.Buffer{}
	err := Git(provisioner, app, "5734f0042844fdeb5bbc1b72b18f2dc1779cade7", w)
	c.Assert(err, gocheck.IsNil)
	c.Assert(app.Commands, gocheck.DeepEquals, []string{"restart"})
	c.Assert(provisioner.InstalledDeps(app), gocheck.Equals, 1)
	cloneCommand := "git clone git://tsuruhost.com/cribcaged.git test/dir --depth 1"
	c.Assert(provisioner.GetCmds(cloneCommand, app), gocheck.HasLen, 1)
	path, _ := repository.GetPath()
	checkoutCommand := fmt.Sprintf("cd %s && git checkout 5734f0042844fdeb5bbc1b72b18f2dc1779cade7", path)
	c.Assert(provisioner.GetCmds(checkoutCommand, app), gocheck.HasLen, 1)
}
コード例 #17
0
ファイル: suite_test.go プロジェクト: JoeyFan/tsuru
func (s *S) SetUpSuite(c *C) {
	var err error
	err = config.ReadConfigFile("../etc/tsuru.conf")
	c.Assert(err, IsNil)
	db.Session, err = db.Open("127.0.0.1:27017", "tsuru_app_test")
	c.Assert(err, IsNil)
	s.rfs = &fsTesting.RecordingFs{}
	file, err := s.rfs.Open("/dev/urandom")
	c.Assert(err, IsNil)
	file.Write([]byte{16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31})
	fsystem = s.rfs
	s.t = &tsuruTesting.T{}
	s.createUserAndTeam(c)
	s.t.StartAmzS3AndIAM(c)
	s.t.SetGitConfs(c)
	s.provisioner = tsuruTesting.NewFakeProvisioner()
	Provisioner = s.provisioner
}
コード例 #18
0
ファイル: git_test.go プロジェクト: richardjoo/tsuru
func (s *S) TestDeployLogsActions(c *gocheck.C) {
	provisioner := testing.NewFakeProvisioner()
	provisioner.PrepareOutput([]byte(""))
	app := testing.NewFakeApp("cribcaged", "python", 1)
	w := &bytes.Buffer{}
	err := Git(provisioner, app, w)
	c.Assert(err, gocheck.IsNil)
	logs := w.String()
	expected := `
 ---> Tsuru receiving push

 ---> Replicating the application repository across units

 ---> Installing dependencies

 ---> Restarting application

 ---> Deploy done!

`
	c.Assert(logs, gocheck.Equals, expected)
}
コード例 #19
0
ファイル: elb_test.go プロジェクト: kaiquewdev/tsuru
func (s *ELBSuite) SetUpSuite(c *gocheck.C) {
	var err error
	config.Set("database:url", "127.0.0.1:27017")
	config.Set("database:name", "juju_elb_tests")
	s.conn, err = db.Conn()
	s.server, err = elbtest.NewServer()
	c.Assert(err, gocheck.IsNil)
	config.Set("juju:elb-endpoint", s.server.URL())
	config.Set("juju:use-elb", true)
	region := aws.SAEast
	region.ELBEndpoint = s.server.URL()
	s.client = elb.New(aws.Auth{AccessKey: "some", SecretKey: "thing"}, region)
	c.Assert(err, gocheck.IsNil)
	s.cName = "juju_test_elbs"
	config.Set("juju:elb-collection", s.cName)
	config.Set("juju:elb-avail-zones", []interface{}{"my-zone-1a", "my-zone-1b"})
	config.Set("aws:access-key-id", "access")
	config.Set("aws:secret-access-key", "s3cr3t")
	config.Set("git:host", "git.tsuru.io")
	config.Set("queue", "fake")
	config.Set("juju:units-collection", "juju_units_test_elb")
	s.provisioner = testing.NewFakeProvisioner()
	app.Provisioner = s.provisioner
}