示例#1
0
文件: lxc_test.go 项目: makyo/juju
func (*NetworkSuite) TestNetworkConfigTemplate(c *gc.C) {
	// Intentionally using an invalid type "foo" here to test it gets
	// changed to the default "veth" and a warning is logged.
	config := lxc.NetworkConfigTemplate(container.NetworkConfig{"foo", "bar", 4321, nil})
	// In the past, the entire lxc.conf file was just networking. With
	// the addition of the auto start, we now have to have better
	// isolate this test. As such, we parse the conf template results
	// and just get the results that start with 'lxc.network' as that
	// is what the test cares about.
	obtained := []string{}
	for _, value := range strings.Split(config, "\n") {
		if strings.HasPrefix(value, "lxc.network") {
			obtained = append(obtained, value)
		}
	}
	expected := []string{
		"lxc.network.type = veth",
		"lxc.network.link = bar",
		"lxc.network.flags = up",
		"lxc.network.mtu = 4321",
	}
	c.Assert(obtained, jc.DeepEquals, expected)
	log := c.GetTestLog()
	c.Assert(log, jc.Contains,
		`WARNING juju.container.lxc unknown network type "foo", using the default "bridge" config`,
	)
}
示例#2
0
文件: lxc_test.go 项目: kapilt/juju
func (*NetworkSuite) TestNetworkConfigTemplate(c *gc.C) {
	config := lxc.NetworkConfigTemplate("foo", "bar")
	//In the past, the entire lxc.conf file was just networking. With the addition
	//of the auto start, we now have to have better isolate this test. As such, we
	//parse the conf template results and just get the results that start with
	//'lxc.network' as that is what the test cares about.
	obtained := []string{}
	for _, value := range strings.Split(config, "\n") {
		if strings.HasPrefix(value, "lxc.network") {
			obtained = append(obtained, value)
		}
	}
	expected := []string{
		"lxc.network.type = foo",
		"lxc.network.link = bar",
		"lxc.network.flags = up",
	}
	c.Assert(obtained, gc.DeepEquals, expected)
}