示例#1
0
func (s *instanceSuite) TestNewInstanceSummaryArchitectures(c *gc.C) {
	summary := lxdclient.NewInstanceSummary(infoWithArchitecture(lxdshared.ARCH_32BIT_INTEL_X86))
	c.Check(summary.Hardware.Architecture, gc.Equals, "i386")
	summary = lxdclient.NewInstanceSummary(infoWithArchitecture(lxdshared.ARCH_64BIT_INTEL_X86))
	c.Check(summary.Hardware.Architecture, gc.Equals, "amd64")
	summary = lxdclient.NewInstanceSummary(infoWithArchitecture(lxdshared.ARCH_64BIT_POWERPC_LITTLE_ENDIAN))
	c.Check(summary.Hardware.Architecture, gc.Equals, "ppc64el")
	info := templateContainerInfo
	info.Architecture = "unknown"
	summary = lxdclient.NewInstanceSummary(&info)
	c.Check(summary.Hardware.Architecture, gc.Equals, "unknown")
}
示例#2
0
func (s *instanceSuite) TestNewInstanceSummaryMemory(c *gc.C) {
	// No suffix
	summary := lxdclient.NewInstanceSummary(infoWithMemory("128"))
	c.Check(summary.Hardware.MemoryMB, gc.Equals, uint(0))
	// Invalid integer
	summary = lxdclient.NewInstanceSummary(infoWithMemory("blah"))
	c.Check(summary.Hardware.MemoryMB, gc.Equals, uint(0))
	// Too big to fit in uint
	tooBig := fmt.Sprintf("%vMB", uint64(math.MaxUint32)+1)
	summary = lxdclient.NewInstanceSummary(infoWithMemory(tooBig))
	c.Check(summary.Hardware.MemoryMB, gc.Equals, uint(math.MaxUint32))
	// Just big enough
	justEnough := fmt.Sprintf("%vMB", uint(math.MaxUint32)-1)
	summary = lxdclient.NewInstanceSummary(infoWithMemory(justEnough))
	c.Check(summary.Hardware.MemoryMB, gc.Equals, uint(math.MaxUint32-1))
}
示例#3
0
func (s *instanceSuite) TestNewInstanceSummaryTemplate(c *gc.C) {
	archStr, err := lxdshared.ArchitectureName(lxdshared.ARCH_64BIT_INTEL_X86)
	c.Assert(err, jc.ErrorIsNil)
	c.Check(templateContainerInfo.Architecture, gc.Equals, archStr)
	summary := lxdclient.NewInstanceSummary(&templateContainerInfo)
	c.Check(summary.Name, gc.Equals, "container-name")
	c.Check(summary.Status, gc.Equals, lxdclient.StatusStarting)
	c.Check(summary.Hardware.Architecture, gc.Equals, "amd64")
	c.Check(summary.Hardware.NumCores, gc.Equals, uint(2))
	c.Check(summary.Hardware.MemoryMB, gc.Equals, uint(256))
	// NotImplemented yet
	c.Check(summary.Hardware.RootDiskMB, gc.Equals, uint64(0))
	c.Check(summary.Metadata, gc.DeepEquals, map[string]string{"something": "something value"})
}