Esempio n. 1
0
func (s *TargetPrecheckSuite) TestIsUpgradingError(c *gc.C) {
	backend := &fakeBackend{
		isUpgradingErr: errors.New("boom"),
	}
	err := migration.TargetPrecheck(backend, s.modelInfo)
	c.Assert(err, gc.ErrorMatches, "checking for upgrades: boom")
}
Esempio n. 2
0
func (s *TargetPrecheckSuite) TestIsUpgrading(c *gc.C) {
	backend := &fakeBackend{
		isUpgrading: true,
	}
	err := migration.TargetPrecheck(backend, s.modelInfo)
	c.Assert(err, gc.ErrorMatches, "upgrade in progress")
}
Esempio n. 3
0
func (s *TargetPrecheckSuite) TestVersionLessThanSource(c *gc.C) {
	backend := newFakeBackend()
	s.modelInfo.AgentVersion = version.MustParse("1.2.4")
	err := migration.TargetPrecheck(backend, s.modelInfo)
	c.Assert(err.Error(), gc.Equals,
		`model has higher version than target controller (1.2.4 > 1.2.3)`)
}
Esempio n. 4
0
func (s *TargetPrecheckSuite) TestUUIDAlreadyExists(c *gc.C) {
	backend := newFakeBackend()
	backend.models = []migration.PrecheckModel{
		&fakeModel{uuid: modelUUID},
	}
	err := migration.TargetPrecheck(backend, s.modelInfo)
	c.Assert(err.Error(), gc.Equals, "model with same UUID already exists (model-uuid)")
}
Esempio n. 5
0
func (s *TargetPrecheckSuite) TestModelNameOverlapOkForDifferentOwner(c *gc.C) {
	backend := newFakeBackend()
	backend.models = []migration.PrecheckModel{
		&fakeModel{name: modelName, owner: names.NewUserTag("someone.else")},
	}
	err := migration.TargetPrecheck(backend, s.modelInfo)
	c.Assert(err, jc.ErrorIsNil)
}
Esempio n. 6
0
func (s *TargetPrecheckSuite) TestUUIDAlreadyExistsButImporting(c *gc.C) {
	backend := newFakeBackend()
	backend.models = []migration.PrecheckModel{
		&fakeModel{
			uuid:          modelUUID,
			migrationMode: state.MigrationModeImporting,
		},
	}
	err := migration.TargetPrecheck(backend, s.modelInfo)
	c.Assert(err, jc.ErrorIsNil)
}
Esempio n. 7
0
func (s *TargetPrecheckSuite) TestModelNameAlreadyInUse(c *gc.C) {
	backend := newFakeBackend()
	backend.models = []migration.PrecheckModel{
		&fakeModel{
			name:  modelName,
			owner: modelOwner,
		},
	}
	err := migration.TargetPrecheck(backend, s.modelInfo)
	c.Assert(err, gc.ErrorMatches, "model named \"model-name\" already exists")
}
Esempio n. 8
0
// Prechecks ensure that the target controller is ready to accept a
// model migration.
func (api *API) Prechecks(model params.MigrationModelInfo) error {
	ownerTag, err := names.ParseUserTag(model.OwnerTag)
	if err != nil {
		return errors.Trace(err)
	}
	return migration.TargetPrecheck(
		migration.PrecheckShim(api.state),
		coremigration.ModelInfo{
			UUID:         model.UUID,
			Name:         model.Name,
			Owner:        ownerTag,
			AgentVersion: model.AgentVersion,
		},
	)
}
Esempio n. 9
0
func (s *TargetPrecheckSuite) TestDownMachineAgent(c *gc.C) {
	backend := newBackendWithDownMachineAgent()
	err := migration.TargetPrecheck(backend, s.modelInfo)
	c.Assert(err.Error(), gc.Equals, "machine 1 agent not functioning at this time (down)")
}
Esempio n. 10
0
func (s *TargetPrecheckSuite) TestProvisioningMachine(c *gc.C) {
	backend := newBackendWithProvisioningMachine()
	err := migration.TargetPrecheck(backend, s.modelInfo)
	c.Assert(err.Error(), gc.Equals, "machine 0 not running (allocating)")
}
Esempio n. 11
0
func (s *TargetPrecheckSuite) TestDyingMachine(c *gc.C) {
	backend := newBackendWithDyingMachine()
	err := migration.TargetPrecheck(backend, s.modelInfo)
	c.Assert(err, gc.ErrorMatches, "machine 0 is dying")
}
Esempio n. 12
0
func (s *TargetPrecheckSuite) TestIsMigrationActive(c *gc.C) {
	backend := &fakeBackend{migrationActive: true}
	err := migration.TargetPrecheck(backend, s.modelInfo)
	c.Assert(err, gc.ErrorMatches, "model is being migrated out of target controller")
}
Esempio n. 13
0
func (s *TargetPrecheckSuite) TestIsMigrationActiveError(c *gc.C) {
	backend := &fakeBackend{migrationActiveErr: errors.New("boom")}
	err := migration.TargetPrecheck(backend, s.modelInfo)
	c.Assert(err, gc.ErrorMatches, "checking for active migration: boom")
}
Esempio n. 14
0
func (s *TargetPrecheckSuite) TestDying(c *gc.C) {
	backend := newFakeBackend()
	backend.model.life = state.Dying
	err := migration.TargetPrecheck(backend, s.modelInfo)
	c.Assert(err, gc.ErrorMatches, "model is dying")
}
Esempio n. 15
0
func (s *TargetPrecheckSuite) TestSuccess(c *gc.C) {
	err := migration.TargetPrecheck(newHappyBackend(), s.modelInfo)
	c.Assert(err, jc.ErrorIsNil)
}
Esempio n. 16
0
func (s *TargetPrecheckSuite) runPrecheck(backend migration.PrecheckBackend) error {
	return migration.TargetPrecheck(backend, s.modelInfo)
}