Esempio n. 1
0
func (s *controllerSuite) TestInitiateModelMigration(c *gc.C) {
	st := s.Factory.MakeModel(c, nil)
	defer st.Close()

	_, err := st.GetModelMigration()
	c.Assert(errors.IsNotFound(err), jc.IsTrue)

	spec := controller.ModelMigrationSpec{
		ModelUUID:            st.ModelUUID(),
		TargetControllerUUID: randomUUID(),
		TargetAddrs:          []string{"1.2.3.4:5"},
		TargetCACert:         "cert",
		TargetUser:           "******",
		TargetPassword:       "******",
	}

	controller := s.OpenAPI(c)
	id, err := controller.InitiateModelMigration(spec)
	c.Assert(err, jc.ErrorIsNil)
	expectedId := st.ModelUUID() + ":0"
	c.Check(id, gc.Equals, expectedId)

	// Check database.
	mig, err := st.GetModelMigration()
	c.Assert(err, jc.ErrorIsNil)
	c.Check(mig.Id(), gc.Equals, expectedId)
}
Esempio n. 2
0
func (s *controllerSuite) TestInitiateModelMigrationError(c *gc.C) {
	spec := controller.ModelMigrationSpec{
		ModelUUID:            randomUUID(), // Model doesn't exist.
		TargetControllerUUID: randomUUID(),
		TargetAddrs:          []string{"1.2.3.4:5"},
		TargetCACert:         "cert",
		TargetUser:           "******",
		TargetPassword:       "******",
	}

	controller := s.OpenAPI(c)
	id, err := controller.InitiateModelMigration(spec)
	c.Check(id, gc.Equals, "")
	c.Check(err, gc.ErrorMatches, "unable to read model: .+")
}