Beispiel #1
0
func (s *machineSuite) TestSinglePollWhenInstancInfoUnimplemented(c *gc.C) {
	s.PatchValue(&ShortPoll, 1*time.Millisecond)
	s.PatchValue(&LongPoll, 1*time.Millisecond)
	count := int32(0)
	getInstanceInfo := func(id instance.Id) (instanceInfo, error) {
		c.Check(id, gc.Equals, instance.Id("i1234"))
		atomic.AddInt32(&count, 1)
		return instanceInfo{}, errors.NotImplementedf("instance address")
	}
	context := &testMachineContext{
		getInstanceInfo: getInstanceInfo,
		dyingc:          make(chan struct{}),
	}
	m := &testMachine{
		id:         "99",
		instanceId: "i1234",
		refresh:    func() error { return nil },
		life:       state.Alive,
	}
	died := make(chan machine)

	go runMachine(context, m, nil, died)

	time.Sleep(coretesting.ShortWait)
	killMachineLoop(c, m, context.dyingc, died)
	c.Assert(context.killAllErr, gc.Equals, nil)
	c.Assert(count, gc.Equals, int32(1))
}
Beispiel #2
0
func (s *PrecheckerSuite) TestPrecheckPrecheckerUnimplemented(c *gc.C) {
	var precheckerErr error
	s.policy.getPrechecker = func(*config.Config) (state.Prechecker, error) {
		return nil, precheckerErr
	}
	_, err := s.addOneMachine(c, constraints.Value{}, "placement")
	c.Assert(err, gc.ErrorMatches, "cannot add a new machine: policy returned nil prechecker without an error")
	precheckerErr = errors.NotImplementedf("Prechecker")
	_, err = s.addOneMachine(c, constraints.Value{}, "placement")
	c.Assert(err, gc.IsNil)
}
func (s *EnvironCapabilitySuite) TestEnvironCapabilityUnimplemented(c *gc.C) {
	var capabilityErr error
	s.policy.getEnvironCapability = func(*config.Config) (state.EnvironCapability, error) {
		return nil, capabilityErr
	}
	_, err := s.addOneMachine(c)
	c.Assert(err, gc.ErrorMatches, "cannot add a new machine: policy returned nil EnvironCapability without an error")
	capabilityErr = errors.NotImplementedf("EnvironCapability")
	_, err = s.addOneMachine(c)
	c.Assert(err, gc.IsNil)
}
Beispiel #4
0
func (s *ConfigValidatorSuite) TestConfigValidateUnimplemented(c *gc.C) {
	var configValidatorErr error
	s.policy.getConfigValidator = func(string) (state.ConfigValidator, error) {
		return nil, configValidatorErr
	}

	err := s.updateEnvironConfig(c)
	c.Assert(err, gc.ErrorMatches, "policy returned nil configValidator without an error")
	configValidatorErr = errors.NotImplementedf("Validator")
	err = s.updateEnvironConfig(c)
	c.Assert(err, gc.IsNil)
}
Beispiel #5
0
func (inst *localInstance) Addresses() ([]instance.Address, error) {
	if inst.id == bootstrapInstanceId {
		addrs := []instance.Address{{
			NetworkScope: instance.NetworkPublic,
			Type:         instance.HostName,
			Value:        "localhost",
		}, {
			NetworkScope: instance.NetworkCloudLocal,
			Type:         instance.Ipv4Address,
			Value:        inst.env.bridgeAddress,
		}}
		return addrs, nil
	}
	return nil, errors.NotImplementedf("localInstance.Addresses")
}
Beispiel #6
0
func (lxc *lxcInstance) Addresses() ([]instance.Address, error) {
	return nil, errors.NotImplementedf("lxcInstance.Addresses")
}
Beispiel #7
0
func (p *containerProvisioner) getRetryWatcher() (apiwatcher.NotifyWatcher, error) {
	return nil, errors.NotImplementedf("getRetryWatcher")
}
Beispiel #8
0
func (p *mockPolicy) EnvironCapability(cfg *config.Config) (state.EnvironCapability, error) {
	if p.getEnvironCapability != nil {
		return p.getEnvironCapability(cfg)
	}
	return nil, errors.NotImplementedf("EnvironCapability")
}
Beispiel #9
0
func (p *mockPolicy) ConfigValidator(providerType string) (state.ConfigValidator, error) {
	if p.getConfigValidator != nil {
		return p.getConfigValidator(providerType)
	}
	return nil, errors.NotImplementedf("ConfigValidator")
}
Beispiel #10
0
func (p *mockPolicy) Prechecker(cfg *config.Config) (state.Prechecker, error) {
	if p.getPrechecker != nil {
		return p.getPrechecker(cfg)
	}
	return nil, errors.NotImplementedf("Prechecker")
}