示例#1
0
func (s *watchStorageAttachmentSuite) SetUpTest(c *gc.C) {
	s.storageTag = names.NewStorageTag("osd-devices/0")
	s.machineTag = names.NewMachineTag("0")
	s.unitTag = names.NewUnitTag("ceph/0")
	s.storageInstance = &fakeStorageInstance{
		tag:   s.storageTag,
		owner: s.machineTag,
		kind:  state.StorageKindBlock,
	}
	s.volume = &fakeVolume{tag: names.NewVolumeTag("0")}
	s.volumeAttachmentWatcher = apiservertesting.NewFakeNotifyWatcher()
	s.volumeAttachmentWatcher.C <- struct{}{}
	s.blockDevicesWatcher = apiservertesting.NewFakeNotifyWatcher()
	s.blockDevicesWatcher.C <- struct{}{}
	s.storageAttachmentWatcher = apiservertesting.NewFakeNotifyWatcher()
	s.storageAttachmentWatcher.C <- struct{}{}
	s.st = &fakeStorage{
		storageInstance: func(tag names.StorageTag) (state.StorageInstance, error) {
			return s.storageInstance, nil
		},
		storageInstanceVolume: func(tag names.StorageTag) (state.Volume, error) {
			return s.volume, nil
		},
		watchVolumeAttachment: func(names.MachineTag, names.VolumeTag) state.NotifyWatcher {
			return s.volumeAttachmentWatcher
		},
		watchBlockDevices: func(names.MachineTag) state.NotifyWatcher {
			return s.blockDevicesWatcher
		},
		watchStorageAttachment: func(names.StorageTag, names.UnitTag) state.NotifyWatcher {
			return s.storageAttachmentWatcher
		},
	}
}
示例#2
0
文件: watch_test.go 项目: bac/juju
func (*multiNotifyWatcherSuite) TestMultiNotifyWatcherStop(c *gc.C) {
	w0 := apiservertesting.NewFakeNotifyWatcher()
	w1 := apiservertesting.NewFakeNotifyWatcher()

	mw := common.NewMultiNotifyWatcher(w0, w1)
	wc := statetesting.NewNotifyWatcherC(c, nopSyncStarter{}, mw)
	wc.AssertOneChange()
	statetesting.AssertCanStopWhenSending(c, mw)
	wc.AssertClosed()
}
示例#3
0
func (s *watcherSuite) TestMigrationNotModelManager(c *gc.C) {
	id := s.resources.Register(apiservertesting.NewFakeNotifyWatcher())
	s.authorizer.EnvironManager = false

	factory, err := common.Facades.GetFactory("MigrationMasterWatcher", 1)
	c.Assert(err, jc.ErrorIsNil)
	_, err = factory(s.st, s.resources, s.authorizer, id)
	c.Assert(err, gc.Equals, common.ErrPerm)
}
示例#4
0
func (s *watcherSuite) TestMigrationStatusWatcherNotAgent(c *gc.C) {
	id := s.resources.Register(apiservertesting.NewFakeNotifyWatcher())
	s.authorizer.Tag = names.NewUserTag("frogdog")

	factory, err := common.Facades.GetFactory("MigrationStatusWatcher", 1)
	c.Assert(err, jc.ErrorIsNil)
	_, err = factory(nil, s.resources, s.authorizer, id)
	c.Assert(err, gc.Equals, common.ErrPerm)
}
示例#5
0
文件: watch_test.go 项目: bac/juju
func (*multiNotifyWatcherSuite) TestMultiNotifyWatcher(c *gc.C) {
	w0 := apiservertesting.NewFakeNotifyWatcher()
	w1 := apiservertesting.NewFakeNotifyWatcher()

	mw := common.NewMultiNotifyWatcher(w0, w1)
	defer statetesting.AssertStop(c, mw)

	wc := statetesting.NewNotifyWatcherC(c, nopSyncStarter{}, mw)
	wc.AssertOneChange()

	w0.C <- struct{}{}
	wc.AssertOneChange()
	w1.C <- struct{}{}
	wc.AssertOneChange()

	w0.C <- struct{}{}
	w1.C <- struct{}{}
	wc.AssertOneChange()
}
示例#6
0
文件: watcher_test.go 项目: bac/juju
func (s *watcherSuite) TestMigrationStatusWatcherNoMigration(c *gc.C) {
	w := apiservertesting.NewFakeNotifyWatcher()
	id := s.resources.Register(w)
	s.authorizer.Tag = names.NewMachineTag("12")
	apiserver.PatchGetMigrationBackend(s, &fakeMigrationBackend{noMigration: true})

	facade := s.getFacade(c, "MigrationStatusWatcher", 1, id).(migrationStatusWatcher)
	defer c.Check(facade.Stop(), jc.ErrorIsNil)
	result, err := facade.Next()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(result, jc.DeepEquals, params.MigrationStatus{
		Phase: "NONE",
	})
}
示例#7
0
func (s *watcherSuite) TestMigrationMasterWatcher(c *gc.C) {
	w := apiservertesting.NewFakeNotifyWatcher()
	id := s.resources.Register(w)
	s.authorizer.EnvironManager = true
	apiserver.PatchMigrationGetter(s, new(fakeModelMigrationGetter))

	w.C <- struct{}{}
	facade := s.getFacade(c, "MigrationMasterWatcher", 1, id).(migrationMasterWatcher)
	result, err := facade.Next()
	c.Assert(err, jc.ErrorIsNil)
	defer c.Check(facade.Stop(), jc.ErrorIsNil)

	c.Assert(result, jc.DeepEquals, params.ModelMigrationTargetInfo{
		ControllerTag: "model-uuid",
		Addrs:         []string{"1.2.3.4:5555"},
		CACert:        "trust me",
		AuthTag:       "user-admin",
		Password:      "******",
	})
}
示例#8
0
文件: watcher_test.go 项目: bac/juju
func (s *watcherSuite) TestMigrationStatusWatcher(c *gc.C) {
	w := apiservertesting.NewFakeNotifyWatcher()
	id := s.resources.Register(w)
	s.authorizer.Tag = names.NewMachineTag("12")
	apiserver.PatchGetMigrationBackend(s, new(fakeMigrationBackend))
	apiserver.PatchGetControllerCACert(s, "no worries")

	facade := s.getFacade(c, "MigrationStatusWatcher", 1, id).(migrationStatusWatcher)
	defer c.Check(facade.Stop(), jc.ErrorIsNil)
	result, err := facade.Next()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(result, jc.DeepEquals, params.MigrationStatus{
		MigrationId:    "id",
		Attempt:        2,
		Phase:          "IMPORT",
		SourceAPIAddrs: []string{"1.2.3.4:5", "2.3.4.5:6", "3.4.5.6:7"},
		SourceCACert:   "no worries",
		TargetAPIAddrs: []string{"1.2.3.4:5555"},
		TargetCACert:   "trust me",
	})
}
示例#9
0
func (b *stubBackend) WatchMigrationStatus() (state.NotifyWatcher, error) {
	if b.watchError != nil {
		return nil, b.watchError
	}
	return apiservertesting.NewFakeNotifyWatcher(), nil
}
示例#10
0
文件: facade_test.go 项目: bac/juju
func (m *stubMigration) WatchMinionReports() (state.NotifyWatcher, error) {
	m.stub.AddCall("ModelMigration.WatchMinionReports")
	return apiservertesting.NewFakeNotifyWatcher(), nil
}
示例#11
0
文件: facade_test.go 项目: bac/juju
func (b *stubBackend) WatchForMigration() state.NotifyWatcher {
	b.stub.AddCall("WatchForMigration")
	return apiservertesting.NewFakeNotifyWatcher()
}
示例#12
0
func (a *fakeAgentEntityWatcher) Watch() state.NotifyWatcher {
	w := apiservertesting.NewFakeNotifyWatcher()
	// Simulate initial event.
	w.C <- struct{}{}
	return w
}
示例#13
0
文件: watch_test.go 项目: bac/juju
func (a *fakeAgentEntityWatcher) Watch() state.NotifyWatcher {
	return apiservertesting.NewFakeNotifyWatcher()
}
示例#14
0
func (*fakeModelAccessor) WatchForModelConfigChanges() state.NotifyWatcher {
	return apiservertesting.NewFakeNotifyWatcher()
}
示例#15
0
func (*fakeModelAccessor) WatchForModelConfigChanges() state.NotifyWatcher {
	w := apiservertesting.NewFakeNotifyWatcher()
	// Simulate initial event.
	w.C <- struct{}{}
	return w
}