Example #1
0
func (s *syncSuite) tearDownTest(c *gc.C) {
	c.Assert(s.storage.Stop(), gc.IsNil)
	sync.DefaultToolsLocation = s.origLocation
	dummy.Reset()
	s.home.Restore()
	version.Current = s.origVersion
	s.LoggingSuite.TearDownTest(c)
}
Example #2
0
// makeEmptyFakeHome creates a faked home without tools.
func makeEmptyFakeHome(c *gc.C) (environs.Environ, *coretesting.FakeHome) {
	fake := coretesting.MakeFakeHome(c, envConfig)
	dummy.Reset()
	env, err := environs.NewFromName("peckham")
	c.Assert(err, gc.IsNil)
	envtesting.RemoveAllTools(c, env)
	return env, fake
}
Example #3
0
func (s *ConnSuite) TearDownTest(c *C) {
	if s.conn == nil {
		return
	}
	err := s.conn.State.SetAdminMongoPassword("")
	c.Assert(err, IsNil)
	err = s.conn.Environ.Destroy(nil)
	c.Check(err, IsNil)
	s.conn.Close()
	s.conn = nil
	dummy.Reset()
	s.MgoSuite.TearDownTest(c)
	s.LoggingSuite.TearDownTest(c)
}
Example #4
0
func (s *JujuConnSuite) tearDownConn(c *C) {
	// Bootstrap will set the admin password, and render non-authorized use
	// impossible. s.State may still hold the right password, so try to reset
	// the password so that the MgoSuite soft-resetting works. If that fails,
	// it will still work, but it will take a while since it has to kill the
	// whole database and start over.
	if err := s.State.SetAdminMongoPassword(""); err != nil {
		c.Logf("cannot reset admin password: %v", err)
	}
	c.Assert(s.Conn.Close(), IsNil)
	dummy.Reset()
	s.Conn = nil
	s.State = nil
	os.Setenv("HOME", s.oldHome)
	s.oldHome = ""
	s.RootDir = ""
}
Example #5
0
func (s *ToolsSuite) Reset(c *C, attrs map[string]interface{}) {
	version.Current = s.origCurrentVersion
	dummy.Reset()
	final := map[string]interface{}{
		"name":            "test",
		"type":            "dummy",
		"state-server":    false,
		"authorized-keys": "i-am-a-key",
		"ca-cert":         testing.CACert,
		"ca-private-key":  "",
	}
	for k, v := range attrs {
		final[k] = v
	}
	env, err := environs.NewFromAttrs(final)
	c.Assert(err, IsNil)
	s.env = env
	envtesting.RemoveAllTools(c, s.env)
}
Example #6
0
func runCommand(com cmd.Command, args ...string) (opc chan dummy.Operation, errc chan error) {
	errc = make(chan error, 1)
	opc = make(chan dummy.Operation, 200)
	dummy.Reset()
	dummy.Listen(opc)
	go func() {
		// signal that we're done with this ops channel.
		defer dummy.Listen(nil)

		err := com.Init(newFlagSet(), args)
		if err != nil {
			errc <- err
			return
		}

		err = com.Run(cmd.DefaultContext())
		errc <- err
	}()
	return
}
Example #7
0
func (s *StorageSuite) TearDownTest(c *gc.C) {
	dummy.Reset()
	s.LoggingSuite.TearDownTest(c)
}
Example #8
0
func (cs *NewConnSuite) TearDownTest(c *C) {
	dummy.Reset()
	cs.LoggingSuite.TearDownTest(c)
}
Example #9
0
func (OpenSuite) TearDownTest(c *C) {
	dummy.Reset()
}
Example #10
0
func (s *ToolsSuite) TearDownTest(c *C) {
	dummy.Reset()
	version.Current = s.origCurrentVersion
	s.LoggingSuite.TearDownTest(c)
}
Example #11
0
func (s *verifyStorageSuite) TearDownTest(c *C) {
	dummy.Reset()
}
Example #12
0
func (t *MongoToolsSuite) TearDownTest(c *C) {
	dummy.Reset()
	t.LoggingSuite.TearDownTest(c)
}
Example #13
0
func (s *checkEnvironmentSuite) TearDownTest(c *C) {
	dummy.Reset()
}
Example #14
0
func (s *syncToolsSuite) TearDownTest(c *gc.C) {
	syncTools = s.origSyncTools
	dummy.Reset()
	s.home.Restore()
	s.LoggingSuite.TearDownTest(c)
}
Example #15
0
func (s *BootstrapSuite) TearDownTest(c *C) {
	s.MgoSuite.TearDownTest(c)
	s.LoggingSuite.TearDownTest(c)
	dummy.Reset()
}
func (test bootstrapTest) run(c *C) {
	defer testing.MakeFakeHome(c, envConfig).Restore()
	dummy.Reset()
	env, err := environs.NewFromName("peckham")
	c.Assert(err, IsNil)
	envtesting.RemoveAllTools(c, env)

	if test.version != "" {
		origVersion := version.Current
		version.Current = version.MustParseBinary(test.version)
		defer func() { version.Current = origVersion }()
	}
	uploadCount := len(test.uploads)
	if uploadCount == 0 {
		usefulVersion := version.Current
		usefulVersion.Series = env.Config().DefaultSeries()
		envtesting.UploadFakeToolsVersion(c, env.Storage(), usefulVersion)
	}

	// Run command and check for uploads.
	opc, errc := runCommand(new(BootstrapCommand), test.args...)
	if uploadCount > 0 {
		for i := 0; i < uploadCount; i++ {
			c.Check((<-opc).(dummy.OpPutFile).Env, Equals, "peckham")
		}
		list, err := environs.FindAvailableTools(env, version.Current.Major)
		c.Check(err, IsNil)
		c.Logf("found: " + list.String())
		urls := list.URLs()
		c.Check(urls, HasLen, len(test.uploads))
		for _, v := range test.uploads {
			c.Logf("seeking: " + v)
			vers := version.MustParseBinary(v)
			_, found := urls[vers]
			c.Check(found, Equals, true)
		}
	}

	// Check for remaining operations/errors.
	if test.err != "" {
		c.Check(<-errc, ErrorMatches, test.err)
		return
	}
	if !c.Check(<-errc, IsNil) {
		return
	}
	opPutBootstrapVerifyFile := (<-opc).(dummy.OpPutFile)
	c.Check(opPutBootstrapVerifyFile.Env, Equals, "peckham")
	c.Check(opPutBootstrapVerifyFile.FileName, Equals, "bootstrap-verify")

	opBootstrap := (<-opc).(dummy.OpBootstrap)
	c.Check(opBootstrap.Env, Equals, "peckham")
	c.Check(opBootstrap.Constraints, DeepEquals, test.constraints)

	// Check a CA cert/key was generated by reloading the environment.
	env, err = environs.NewFromName("peckham")
	c.Assert(err, IsNil)
	_, hasCert := env.Config().CACert()
	c.Check(hasCert, Equals, true)
	_, hasKey := env.Config().CAPrivateKey()
	c.Check(hasKey, Equals, true)
}
Example #17
0
func (suite) TearDownTest(c *C) {
	dummy.Reset()
}