Ejemplo 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")
}
Ejemplo 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")
}
Ejemplo 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)`)
}
Ejemplo 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)")
}
Ejemplo 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)
}
Ejemplo 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)
}
Ejemplo 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")
}
Ejemplo 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,
		},
	)
}
Ejemplo 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)")
}
Ejemplo 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)")
}
Ejemplo 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")
}
Ejemplo 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")
}
Ejemplo 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")
}
Ejemplo 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")
}
Ejemplo n.º 15
0
func (s *TargetPrecheckSuite) TestSuccess(c *gc.C) {
	err := migration.TargetPrecheck(newHappyBackend(), s.modelInfo)
	c.Assert(err, jc.ErrorIsNil)
}
Ejemplo n.º 16
0
func (s *TargetPrecheckSuite) runPrecheck(backend migration.PrecheckBackend) error {
	return migration.TargetPrecheck(backend, s.modelInfo)
}