Ejemplo n.º 1
0
func (s *providerSuite) TestPrepareForCreateEnvironment(c *gc.C) {
	testConfig, err := config.New(config.UseDefaults, manual.MinimalConfigValues())
	c.Assert(err, jc.ErrorIsNil)
	cfg, err := manual.ProviderInstance.PrepareForCreateEnvironment(testConfig)
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(cfg, gc.Equals, testConfig)
}
Ejemplo n.º 2
0
func (s *providerSuite) TestPrepareForBootstrap(c *gc.C) {
	minimal := manual.MinimalConfigValues()
	minimal["use-sshstorage"] = true
	testConfig, err := config.New(config.UseDefaults, minimal)
	c.Assert(err, jc.ErrorIsNil)
	_, err = manual.ProviderInstance.PrepareForBootstrap(envtesting.BootstrapContext(c), testConfig)
	c.Assert(err, jc.ErrorIsNil)
}
Ejemplo n.º 3
0
func (s *providerSuite) TestPrepareSetsUseSSHStorage(c *gc.C) {
	attrs := manual.MinimalConfigValues()
	delete(attrs, "use-sshstorage")
	testConfig, err := config.New(config.UseDefaults, attrs)
	c.Assert(err, jc.ErrorIsNil)

	env, err := manual.ProviderInstance.PrepareForBootstrap(envtesting.BootstrapContext(c), testConfig)
	c.Assert(err, jc.ErrorIsNil)
	cfg := env.Config()
	value := cfg.AllAttrs()["use-sshstorage"]
	c.Assert(value, jc.IsTrue)
}
Ejemplo n.º 4
0
func (s *providerSuite) TestPrepare(c *gc.C) {
	minimal := manual.MinimalConfigValues()
	minimal["use-sshstorage"] = true
	delete(minimal, "storage-auth-key")
	testConfig, err := config.New(config.UseDefaults, minimal)
	c.Assert(err, gc.IsNil)
	env, err := manual.ProviderInstance.Prepare(coretesting.Context(c), testConfig)
	c.Assert(err, gc.IsNil)
	cfg := env.Config()
	key, _ := cfg.UnknownAttrs()["storage-auth-key"].(string)
	c.Assert(key, jc.Satisfies, utils.IsValidUUIDString)
}
Ejemplo n.º 5
0
func (s *providerSuite) TestOpenDoesntSetUseSSHStorage(c *gc.C) {
	attrs := manual.MinimalConfigValues()
	delete(attrs, "use-sshstorage")
	testConfig, err := config.New(config.UseDefaults, attrs)
	c.Assert(err, jc.ErrorIsNil)

	env, err := manual.ProviderInstance.Open(testConfig)
	c.Assert(err, jc.ErrorIsNil)
	cfg := env.Config()
	_, ok := cfg.AllAttrs()["use-sshstorage"]
	c.Assert(ok, jc.IsFalse)
	ok = manual.EnvironUseSSHStorage(env)
	c.Assert(ok, jc.IsFalse)
}
Ejemplo n.º 6
0
func (s *providerSuite) testPrepareForBootstrap(c *gc.C, endpoint, region string) (environs.BootstrapContext, error) {
	minimal := manual.MinimalConfigValues()
	testConfig, err := config.New(config.UseDefaults, minimal)
	c.Assert(err, jc.ErrorIsNil)
	testConfig, err = manual.ProviderInstance.BootstrapConfig(environs.BootstrapConfigParams{
		Config:        testConfig,
		CloudEndpoint: endpoint,
		CloudRegion:   region,
	})
	if err != nil {
		return nil, err
	}
	ctx := envtesting.BootstrapContext(c)
	_, err = manual.ProviderInstance.PrepareForBootstrap(ctx, testConfig)
	return ctx, err
}
Ejemplo n.º 7
0
func (s *providerSuite) TestDefaultsCanBeOverriden(c *gc.C) {
	p, err := environs.Provider("manual")
	c.Assert(err, jc.ErrorIsNil)

	attrs := manual.MinimalConfigValues()
	attrs["enable-os-refresh-update"] = true
	attrs["enable-os-upgrade"] = true

	testConfig, err := config.New(config.UseDefaults, attrs)
	c.Assert(err, jc.ErrorIsNil)
	validCfg, err := p.Validate(testConfig, nil)
	c.Assert(err, jc.ErrorIsNil)

	// Our preferences should not have been overwritten.
	c.Check(validCfg.EnableOSRefreshUpdate(), jc.IsTrue)
	c.Check(validCfg.EnableOSUpgrade(), jc.IsTrue)
}
Ejemplo n.º 8
0
func (s *providerSuite) TestPrepareUseSSHStorage(c *gc.C) {
	minimal := manual.MinimalConfigValues()
	minimal["use-sshstorage"] = false
	testConfig, err := config.New(config.UseDefaults, minimal)
	c.Assert(err, gc.IsNil)
	_, err = manual.ProviderInstance.Prepare(coretesting.Context(c), testConfig)
	c.Assert(err, gc.ErrorMatches, "use-sshstorage must not be specified")

	s.PatchValue(manual.NewSSHStorage, func(sshHost, storageDir, storageTmpdir string) (storage.Storage, error) {
		return nil, fmt.Errorf("newSSHStorage failed")
	})
	minimal["use-sshstorage"] = true
	testConfig, err = config.New(config.UseDefaults, minimal)
	c.Assert(err, gc.IsNil)
	_, err = manual.ProviderInstance.Prepare(coretesting.Context(c), testConfig)
	c.Assert(err, gc.ErrorMatches, "initialising SSH storage failed: newSSHStorage failed")
}
Ejemplo n.º 9
0
func (s *providerSuite) TestDisablesUpdatesByDefault(c *gc.C) {
	p, err := environs.Provider("manual")
	c.Assert(err, jc.ErrorIsNil)

	attrs := manual.MinimalConfigValues()
	testConfig, err := config.New(config.UseDefaults, attrs)
	c.Assert(err, jc.ErrorIsNil)
	c.Check(testConfig.EnableOSRefreshUpdate(), jc.IsTrue)
	c.Check(testConfig.EnableOSUpgrade(), jc.IsTrue)

	validCfg, err := p.Validate(testConfig, nil)
	c.Assert(err, jc.ErrorIsNil)

	// Unless specified, update should default to true,
	// upgrade to false.
	c.Check(validCfg.EnableOSRefreshUpdate(), jc.IsTrue)
	c.Check(validCfg.EnableOSUpgrade(), jc.IsFalse)
}