Exemplo n.º 1
0
func (s *BootstrapSuite) TestAutoSyncLocalSource(c *gc.C) {
	sourceDir := createToolsSource(c, vAll)
	s.PatchValue(&jujuversion.Current, version.MustParse("1.2.0"))
	series.SetLatestLtsForTesting("trusty")
	resetJujuXDGDataHome(c)

	// Bootstrap the controller with the valid source.
	// The bootstrapping has to show no error, because the tools
	// are automatically synchronized.
	_, err := coretesting.RunCommand(
		c, s.newBootstrapCommand(), "--metadata-source", sourceDir,
		"devcontroller", "dummy-cloud/region-1",
	)
	c.Assert(err, jc.ErrorIsNil)

	p, err := environs.Provider("dummy")
	c.Assert(err, jc.ErrorIsNil)
	cfg, err := modelcmd.NewGetBootstrapConfigFunc(s.store)("devcontroller")
	c.Assert(err, jc.ErrorIsNil)
	env, err := p.PrepareForBootstrap(envtesting.BootstrapContext(c), cfg)
	c.Assert(err, jc.ErrorIsNil)

	// Now check the available tools which are the 1.2.0 envtools.
	checkTools(c, env, v120All)
}
Exemplo n.º 2
0
func (s *BaseSuite) SetUpSuite(c *gc.C) {
	wrench.SetEnabled(false)
	s.CleanupSuite.SetUpSuite(c)
	s.LoggingSuite.SetUpSuite(c)
	// JujuOSEnvSuite does not have a suite setup.
	s.PatchValue(&utils.OutgoingAccessAllowed, false)
	// LTS-dependent requires new entry upon new LTS release.
	s.oldLtsForTesting = series.SetLatestLtsForTesting("xenial")
}
Exemplo n.º 3
0
func (s *supportedSeriesSuite) TestSetLatestLtsForTesting(c *gc.C) {
	table := []struct {
		value, want string
	}{
		{"1", "xenial"}, {"2", "1"}, {"3", "2"}, {"4", "3"},
	}
	for _, test := range table {
		got := series.SetLatestLtsForTesting(test.value)
		c.Assert(got, gc.Equals, test.want)
	}
}
Exemplo n.º 4
0
func (s *supportedSeriesSuite) TestLatestLts(c *gc.C) {
	table := []struct {
		latest, want string
	}{
		{"testseries", "testseries"},
		{"", "xenial"},
	}
	for _, test := range table {
		series.SetLatestLtsForTesting(test.latest)
		got := series.LatestLts()
		c.Assert(got, gc.Equals, test.want)
	}
}
Exemplo n.º 5
0
func (s *BaseSuite) TearDownSuite(c *gc.C) {
	// JujuOSEnvSuite does not have a suite teardown.
	_ = series.SetLatestLtsForTesting(s.oldLtsForTesting)
	s.LoggingSuite.TearDownSuite(c)
	s.CleanupSuite.TearDownSuite(c)
}
Exemplo n.º 6
0
func (s *SeriesSelectorSuite) TestCharmSeries(c *gc.C) {
	deploySeriesTests := []struct {
		title string

		seriesSelector

		ltsSeries      string
		expectedSeries string
		message        string
		err            string
	}{{
		title: "use charm default, e.g. juju deploy ubuntu",
		seriesSelector: seriesSelector{
			supportedSeries: []string{"trusty", "precise"},
			conf:            defaultSeries{"wily", true},
		},
		ltsSeries:      "precise",
		expectedSeries: "trusty",
		message:        "with the default charm metadata series %q",
	}, {
		title: "use supported requested, e.g. juju deploy ubuntu --series trusty",
		seriesSelector: seriesSelector{
			seriesFlag:      "trusty",
			supportedSeries: []string{"trusty"},
			conf:            defaultSeries{},
		},
		expectedSeries: "trusty",
		message:        "with the user specified series %q",
	}, {
		title: "unsupported requested, e.g. juju deploy ubuntu --series quantal",
		seriesSelector: seriesSelector{
			seriesFlag:      "quantal",
			supportedSeries: []string{"trusty", "precise"},
			conf:            defaultSeries{},
		},
		err: `series "quantal" not supported by charm, supported series are: trusty,precise`,
	}, {
		title: "charm without series specified or requested, with --force",
		seriesSelector: seriesSelector{
			force: true,
			conf:  defaultSeries{},
		},
		ltsSeries:      "quantal",
		expectedSeries: "quantal",
		message:        "with the latest LTS series %q",
	}, {
		title: "charm without series specified or requested, without --force",
		seriesSelector: seriesSelector{
			conf: defaultSeries{},
		},
		ltsSeries:      "quantal",
		expectedSeries: "quantal",
		err:            `series "quantal" not supported by charm, supported series are: <none defined>`,
	}, {
		title: "charm without series specified, series requested, without --force",
		seriesSelector: seriesSelector{
			seriesFlag: "xenial",
			conf:       defaultSeries{},
		},
		ltsSeries:      "quantal",
		expectedSeries: "quantal",
		err:            `series "xenial" not supported by charm, supported series are: <none defined>`,
	}, {
		title: "charm without series specified, series requested, with --force",
		seriesSelector: seriesSelector{
			seriesFlag: "xenial",
			conf:       defaultSeries{},
			force:      true,
		},
		ltsSeries:      "quantal",
		expectedSeries: "xenial",
		message:        "with the user specified series %q",
	}, {
		title: "no requested series, default to model series if supported",
		seriesSelector: seriesSelector{
			conf:            defaultSeries{"xenial", true},
			supportedSeries: []string{"precise", "xenial"},
		},
		expectedSeries: "xenial",
		message:        "with the configured model default series %q",
	}, {
		title: "juju deploy --force --series=wily for unsupported series",
		seriesSelector: seriesSelector{
			seriesFlag:      "wily",
			supportedSeries: []string{"trusty"},
			force:           true,
			conf:            defaultSeries{},
		},
		expectedSeries: "wily",
		message:        "with the user specified series %q",
	}, {
		title: "juju deploy --series=precise for non-default but supported series",
		seriesSelector: seriesSelector{
			seriesFlag:      "precise",
			supportedSeries: []string{"trusty", "precise"},
			conf:            defaultSeries{},
		},
		expectedSeries: "precise",
		message:        "with the user specified series %q",
	}, {
		title: "juju deploy precise/ubuntu for non-default but supported series",
		seriesSelector: seriesSelector{
			charmURLSeries:  "precise",
			supportedSeries: []string{"trusty", "precise"},
			conf:            defaultSeries{},
		},
		expectedSeries: "precise",
		message:        "with the user specified series %q",
	}, {
		title: "juju deploy precise/ubuntu --series=wily for non-default but supported series",
		seriesSelector: seriesSelector{
			charmURLSeries:  "precise",
			seriesFlag:      "wily",
			supportedSeries: []string{"trusty", "wily"},
			conf:            defaultSeries{},
		},
		expectedSeries: "wily",
		message:        "with the user specified series %q",
	}, {
		title: "juju deploy precise/ubuntu --series=quantal for usupported series",
		seriesSelector: seriesSelector{
			charmURLSeries:  "precise",
			seriesFlag:      "quantal",
			supportedSeries: []string{"trusty", "precise"},
			conf:            defaultSeries{},
		},
		err: `series "quantal" not supported by charm, supported series are: trusty,precise`,
	}}

	for i, test := range deploySeriesTests {

		func() {
			c.Logf("test %d [%s]", i, test.title)
			if test.ltsSeries != "" {
				previous := series.SetLatestLtsForTesting(test.ltsSeries)
				defer series.SetLatestLtsForTesting(previous)
			}
			series, err := test.seriesSelector.charmSeries()
			if test.err != "" {
				c.Check(err, gc.ErrorMatches, test.err)
				return
			}
			c.Check(err, jc.ErrorIsNil)
			c.Check(series, gc.Equals, test.expectedSeries)
		}()
	}
}