Example #1
0
func (s *upgraderSuite) TestToolsForAgent(c *gc.C) {
	cur := version.Current
	agent := params.Entity{Tag: s.rawMachine.Tag()}

	// The machine must have its existing tools set before we query for the
	// next tools. This is so that we can grab Arch and Series without
	// having to pass it in again
	err := s.rawMachine.SetAgentVersion(version.Current)
	c.Assert(err, gc.IsNil)

	args := params.Entities{Entities: []params.Entity{agent}}
	results, err := s.upgrader.Tools(args)
	c.Assert(err, gc.IsNil)
	assertTools := func() {
		c.Check(results.Results, gc.HasLen, 1)
		c.Assert(results.Results[0].Error, gc.IsNil)
		agentTools := results.Results[0].Tools
		c.Check(agentTools.URL, gc.Not(gc.Equals), "")
		c.Check(agentTools.Version, gc.DeepEquals, cur)
	}
	assertTools()
	c.Check(results.Results[0].DisableSSLHostnameVerification, jc.IsFalse)

	envtesting.SetSSLHostnameVerification(c, s.State, false)

	results, err = s.upgrader.Tools(args)
	c.Assert(err, gc.IsNil)
	assertTools()
	c.Check(results.Results[0].DisableSSLHostnameVerification, jc.IsTrue)
}
Example #2
0
func (s *machineUpgraderSuite) TestTools(c *gc.C) {
	cur := version.Current
	curTools := &tools.Tools{Version: cur, URL: ""}
	curTools.Version.Minor++
	s.rawMachine.SetAgentVersion(cur)
	// Upgrader.Tools returns the *desired* set of tools, not the currently
	// running set. We want to be upgraded to cur.Version
	stateTools, hostnameVerification, err := s.st.Tools(s.rawMachine.Tag())
	c.Assert(err, gc.IsNil)
	c.Assert(stateTools.Version, gc.Equals, cur)
	c.Assert(stateTools.URL, gc.Not(gc.Equals), "")
	c.Assert(hostnameVerification, gc.Equals, utils.VerifySSLHostnames)

	envtesting.SetSSLHostnameVerification(c, s.State, false)

	stateTools, hostnameVerification, err = s.st.Tools(s.rawMachine.Tag())
	c.Assert(err, gc.IsNil)
	c.Assert(stateTools.Version, gc.Equals, cur)
	c.Assert(stateTools.URL, gc.Not(gc.Equals), "")
	c.Assert(hostnameVerification, gc.Equals, utils.NoVerifySSLHostnames)
}