Пример #1
0
func (s *verifyStorageSuite) TestVerifyStorageFails(c *C) {
	defer testing.MakeFakeHome(c, existingEnv, "existing").Restore()

	environ, err := environs.NewFromName("test")
	c.Assert(err, IsNil)
	storage := environ.Storage()
	someError := errors.Unauthorizedf("you shall not pass")
	dummy.Poison(storage, "bootstrap-verify", someError)
	err = environs.VerifyStorage(storage)
	c.Assert(err, Equals, environs.VerifyStorageError)
}
Пример #2
0
func (s *UpgraderSuite) TestUpgraderRetryAndChanged(c *gc.C) {
	oldTools := s.primeTools(c, version.MustParseBinary("5.4.3-foo-bar"))
	newTools := s.uploadTools(c, version.MustParseBinary("5.4.5-foo-bar"))

	err := statetesting.SetAgentVersion(s.State, newTools.Version.Number)
	c.Assert(err, gc.IsNil)

	retryc := make(chan time.Time)
	*upgrader.RetryAfter = func() <-chan time.Time {
		c.Logf("replacement retry after")
		return retryc
	}
	dummy.Poison(s.Conn.Environ.Storage(), tools.StorageName(newTools.Version), fmt.Errorf("a non-fatal dose"))
	u := upgrader.New(s.state.Upgrader(), s.machine.Tag(), s.DataDir())
	defer u.Stop()

	for i := 0; i < 3; i++ {
		select {
		case retryc <- time.Now():
		case <-time.After(coretesting.LongWait):
			c.Fatalf("upgrader did not retry (attempt %d)", i)
		}
	}

	// Make it upgrade to some newer tools that can be
	// downloaded ok; it should stop retrying, download
	// the newer tools and exit.
	newerTools := s.uploadTools(c, version.MustParseBinary("5.4.6-foo-bar"))
	err = statetesting.SetAgentVersion(s.State, newerTools.Version.Number)
	c.Assert(err, gc.IsNil)

	s.BackingState.Sync()
	done := make(chan error)
	go func() {
		done <- u.Wait()
	}()
	select {
	case err := <-done:
		c.Assert(err, gc.DeepEquals, &upgrader.UpgradeReadyError{
			AgentName: s.machine.Tag(),
			OldTools:  oldTools,
			NewTools:  newerTools,
			DataDir:   s.DataDir(),
		})
	case <-time.After(coretesting.LongWait):
		c.Fatalf("upgrader did not quit after upgrading")
	}
}
Пример #3
0
func (s *checkEnvironmentSuite) TestCheckEnvironmentGetFails(c *C) {
	defer testing.MakeFakeHome(c, checkEnv, "existing").Restore()

	environ, err := environs.NewFromName("test")
	c.Assert(err, IsNil)

	// VerifyStorage is sufficient for our tests and much simpler
	// than Bootstrap which calls it.
	storage := environ.Storage()
	err = environs.VerifyStorage(storage)
	c.Assert(err, IsNil)

	// When fetching the verification file from storage fails,
	// we get an InvalidEnvironmentError.
	someError := errors.Unauthorizedf("you shall not pass")
	dummy.Poison(storage, "bootstrap-verify", someError)
	err = environs.CheckEnvironment(environ)
	c.Assert(err, Equals, someError)
}
Пример #4
0
func (s *UpgraderSuite) poisonVersion(vers version.Binary) {
	path := environs.ToolsStoragePath(vers)
	dummy.Poison(s.Conn.Environ.Storage(), path, fmt.Errorf("poisoned file"))
}
Пример #5
0
func (s *UpgraderSuite) poisonVersion(vers version.Binary) {
	name := tools.StorageName(vers)
	dummy.Poison(s.Conn.Environ.Storage(), name, fmt.Errorf("poisoned file"))
}