Esempio n. 1
0
func (s *SourcePrecheckSuite) TestControllerAgentVersionError(c *gc.C) {
	backend := newFakeBackend()
	backend.controllerBackend.agentVersionErr = errors.New("boom")
	err := migration.SourcePrecheck(backend)
	c.Assert(err, gc.ErrorMatches, "controller: retrieving model version: boom")

}
Esempio n. 2
0
func (s *SourcePrecheckSuite) TestDyingControllerMachine(c *gc.C) {
	backend := &fakeBackend{
		controllerBackend: newBackendWithDyingMachine(),
	}
	err := migration.SourcePrecheck(backend)
	c.Assert(err, gc.ErrorMatches, "controller: machine 0 is dying")
}
Esempio n. 3
0
func (s *SourcePrecheckSuite) TestProvisioningControllerMachine(c *gc.C) {
	backend := &fakeBackend{
		controllerBackend: newBackendWithProvisioningMachine(),
	}
	err := migration.SourcePrecheck(backend)
	c.Assert(err.Error(), gc.Equals, "controller: machine 0 not running (allocating)")
}
Esempio n. 4
0
func (s *SourcePrecheckSuite) TestNonStartedControllerMachine(c *gc.C) {
	backend := &fakeBackend{
		controllerBackend: newBackendWithDownMachine(),
	}
	err := migration.SourcePrecheck(backend)
	c.Assert(err.Error(), gc.Equals, "controller: machine 0 agent not functioning at this time (down)")
}
Esempio n. 5
0
func (s *SourcePrecheckSuite) TestDyingApplication(c *gc.C) {
	backend := &fakeBackend{
		apps: []migration.PrecheckApplication{
			&fakeApp{
				name: "foo",
				life: state.Dying,
			},
		},
	}
	err := migration.SourcePrecheck(backend)
	c.Assert(err.Error(), gc.Equals, "application foo is dying")
}
Esempio n. 6
0
func (s *SourcePrecheckSuite) TestWithPendingMinUnits(c *gc.C) {
	backend := &fakeBackend{
		apps: []migration.PrecheckApplication{
			&fakeApp{
				name:     "foo",
				minunits: 2,
				units:    []migration.PrecheckUnit{&fakeUnit{name: "foo/0"}},
			},
		},
	}
	err := migration.SourcePrecheck(backend)
	c.Assert(err.Error(), gc.Equals, "application foo is below its minimum units threshold")
}
Esempio n. 7
0
func (s *SourcePrecheckSuite) TestUnitLost(c *gc.C) {
	backend := &fakeBackend{
		apps: []migration.PrecheckApplication{
			&fakeApp{
				name: "foo",
				units: []migration.PrecheckUnit{
					&fakeUnit{name: "foo/0", lost: true},
				},
			},
		},
	}
	err := migration.SourcePrecheck(backend)
	c.Assert(err.Error(), gc.Equals, "unit foo/0 not idle (lost)")
}
Esempio n. 8
0
func (s *SourcePrecheckSuite) TestUnitNotIdle(c *gc.C) {
	backend := &fakeBackend{
		apps: []migration.PrecheckApplication{
			&fakeApp{
				name: "foo",
				units: []migration.PrecheckUnit{
					&fakeUnit{name: "foo/0", agentStatus: status.Failed},
				},
			},
		},
	}
	err := migration.SourcePrecheck(backend)
	c.Assert(err.Error(), gc.Equals, "unit foo/0 not idle (failed)")
}
Esempio n. 9
0
func (s *SourcePrecheckSuite) TestDeadUnit(c *gc.C) {
	backend := &fakeBackend{
		apps: []migration.PrecheckApplication{
			&fakeApp{
				name: "foo",
				units: []migration.PrecheckUnit{
					&fakeUnit{name: "foo/0", life: state.Dead},
				},
			},
		},
	}
	err := migration.SourcePrecheck(backend)
	c.Assert(err.Error(), gc.Equals, "unit foo/0 is dead")
}
Esempio n. 10
0
func (*SourcePrecheckSuite) TestCharmUpgrades(c *gc.C) {
	backend := &fakeBackend{
		apps: []migration.PrecheckApplication{
			&fakeApp{
				name:     "spanner",
				charmURL: "cs:spanner-3",
				units: []migration.PrecheckUnit{
					&fakeUnit{name: "spanner/0", charmURL: "cs:spanner-3"},
					&fakeUnit{name: "spanner/1", charmURL: "cs:spanner-2"},
				},
			},
		},
	}
	err := migration.SourcePrecheck(backend)
	c.Assert(err, gc.ErrorMatches, "unit spanner/1 is upgrading")
}
Esempio n. 11
0
func (s *SourcePrecheckSuite) TestUnitVersionsDontMatch(c *gc.C) {
	backend := &fakeBackend{
		apps: []migration.PrecheckApplication{
			&fakeApp{
				name:  "foo",
				units: []migration.PrecheckUnit{&fakeUnit{name: "foo/0"}},
			},
			&fakeApp{
				name: "bar",
				units: []migration.PrecheckUnit{
					&fakeUnit{name: "bar/0"},
					&fakeUnit{name: "bar/1", version: version.MustParseBinary("1.2.4-trusty-ppc64")},
				},
			},
		},
	}
	err := migration.SourcePrecheck(backend)
	c.Assert(err.Error(), gc.Equals, "unit bar/1 tools don't match model (1.2.4 != 1.2.3)")
}
Esempio n. 12
0
func sourcePrecheck(backend migration.PrecheckBackend) error {
	return migration.SourcePrecheck(backend)
}
Esempio n. 13
0
func (s *SourcePrecheckSuite) TestNonStartedMachine(c *gc.C) {
	backend := newBackendWithDownMachine()
	err := migration.SourcePrecheck(backend)
	c.Assert(err.Error(), gc.Equals, "machine 0 agent not functioning at this time (down)")
}
Esempio n. 14
0
File: facade.go Progetto: bac/juju
// Prechecks performs pre-migration checks on the model and
// (source) controller.
func (api *API) Prechecks() error {
	return migration.SourcePrecheck(api.precheckBackend)
}
Esempio n. 15
0
func (s *SourcePrecheckSuite) TestDownMachineAgent(c *gc.C) {
	err := migration.SourcePrecheck(newBackendWithDownMachineAgent())
	c.Assert(err.Error(), gc.Equals, "machine 1 agent not functioning at this time (down)")
}
Esempio n. 16
0
func (*SourcePrecheckSuite) TestSuccess(c *gc.C) {
	backend := newHappyBackend()
	backend.controllerBackend = newHappyBackend()
	err := migration.SourcePrecheck(backend)
	c.Assert(err, jc.ErrorIsNil)
}
Esempio n. 17
0
func (*SourcePrecheckSuite) TestCleanupsError(c *gc.C) {
	backend := newFakeBackend()
	backend.cleanupErr = errors.New("boom")
	err := migration.SourcePrecheck(backend)
	c.Assert(err, gc.ErrorMatches, "checking cleanups: boom")
}
Esempio n. 18
0
func (*SourcePrecheckSuite) TestDyingModel(c *gc.C) {
	backend := newFakeBackend()
	backend.model.life = state.Dying
	err := migration.SourcePrecheck(backend)
	c.Assert(err, gc.ErrorMatches, "model is dying")
}
Esempio n. 19
0
func (s *SourcePrecheckSuite) TestIsUpgradingError(c *gc.C) {
	backend := newFakeBackend()
	backend.controllerBackend.isUpgradingErr = errors.New("boom")
	err := migration.SourcePrecheck(backend)
	c.Assert(err, gc.ErrorMatches, "controller: checking for upgrades: boom")
}
Esempio n. 20
0
func (*SourcePrecheckSuite) TestImportingModel(c *gc.C) {
	backend := newFakeBackend()
	backend.model.migrationMode = state.MigrationModeImporting
	err := migration.SourcePrecheck(backend)
	c.Assert(err, gc.ErrorMatches, "model is being imported as part of another migration")
}
Esempio n. 21
0
func (s *SourcePrecheckSuite) TestProvisioningMachine(c *gc.C) {
	err := migration.SourcePrecheck(newBackendWithProvisioningMachine())
	c.Assert(err.Error(), gc.Equals, "machine 0 not running (allocating)")
}
Esempio n. 22
0
func (*SourcePrecheckSuite) TestCleanupsNeeded(c *gc.C) {
	backend := newFakeBackend()
	backend.cleanupNeeded = true
	err := migration.SourcePrecheck(backend)
	c.Assert(err, gc.ErrorMatches, "cleanup needed")
}
Esempio n. 23
0
func (s *SourcePrecheckSuite) TestControllerMachineVersionsDontMatch(c *gc.C) {
	backend := newFakeBackend()
	backend.controllerBackend = newBackendWithMismatchingTools()
	err := migration.SourcePrecheck(backend)
	c.Assert(err, gc.ErrorMatches, "controller: machine . tools don't match model.+")
}
Esempio n. 24
0
func (s *SourcePrecheckSuite) TestIsUpgrading(c *gc.C) {
	backend := newFakeBackend()
	backend.controllerBackend.isUpgrading = true
	err := migration.SourcePrecheck(backend)
	c.Assert(err, gc.ErrorMatches, "controller: upgrade in progress")
}
Esempio n. 25
0
func (s *SourcePrecheckSuite) TestControllerMachineRequiresReboot(c *gc.C) {
	backend := newFakeBackend()
	backend.controllerBackend = newBackendWithRebootingMachine()
	err := migration.SourcePrecheck(backend)
	c.Assert(err, gc.ErrorMatches, "controller: machine 0 is scheduled to reboot")
}
Esempio n. 26
0
		targetUserTag, err := names.ParseUserTag(arg.UserTag)
		if err != nil {
			result.Results[i].Error = common.ServerError(errors.Annotate(err, "could not modify controller access"))
			continue
		}

		result.Results[i].Error = common.ServerError(
			ChangeControllerAccess(c.state, c.apiUser, targetUserTag, arg.Action, controllerAccess))
	}
	return result, nil
}

var runMigrationPrechecks = func(st *state.State, targetInfo coremigration.TargetInfo) error {
	// Check model and source controller.
	if err := migration.SourcePrecheck(migration.PrecheckShim(st)); err != nil {
		return errors.Annotate(err, "source prechecks failed")
	}

	// Check target controller.
	conn, err := api.Open(targetToAPIInfo(targetInfo), migration.ControllerDialOpts())
	if err != nil {
		return errors.Annotate(err, "connect to target controller")
	}
	defer conn.Close()
	modelInfo, err := makeModelInfo(st)
	if err != nil {
		return errors.Trace(err)
	}
	err = migrationtarget.NewClient(conn).Prechecks(modelInfo)
	return errors.Annotate(err, "target prechecks failed")
Esempio n. 27
0
func (s *SourcePrecheckSuite) TestDyingMachine(c *gc.C) {
	backend := newBackendWithDyingMachine()
	err := migration.SourcePrecheck(backend)
	c.Assert(err, gc.ErrorMatches, "machine 0 is dying")
}