Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(94)

Delta Between Two Patch Sets: state/state_test.go

Issue 12859043: Add an os-disk constraint
Left Patch Set: Add an os-disk constraint Created 11 years, 7 months ago
Right Patch Set: Add an os-disk constraint Created 11 years, 7 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « state/state.go ('k') | state/unit.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2012, 2013 Canonical Ltd. 1 // Copyright 2012, 2013 Canonical Ltd.
2 // Licensed under the AGPLv3, see LICENCE file for details. 2 // Licensed under the AGPLv3, see LICENCE file for details.
3 3
4 package state_test 4 package state_test
5 5
6 import ( 6 import (
7 "fmt" 7 "fmt"
8 "net/url" 8 "net/url"
9 "strconv" 9 "strconv"
10 "strings" 10 "strings"
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 _, err = s.State.InjectMachine("series", emptyCons, instance.Id("i-mlazy "), hc) 315 _, err = s.State.InjectMachine("series", emptyCons, instance.Id("i-mlazy "), hc)
316 c.Assert(err, gc.ErrorMatches, "cannot add a new machine: no jobs specif ied") 316 c.Assert(err, gc.ErrorMatches, "cannot add a new machine: no jobs specif ied")
317 } 317 }
318 318
319 func (s *StateSuite) TestInjectMachine(c *gc.C) { 319 func (s *StateSuite) TestInjectMachine(c *gc.C) {
320 cons := constraints.MustParse("mem=4G") 320 cons := constraints.MustParse("mem=4G")
321 arch := "amd64" 321 arch := "amd64"
322 mem := uint64(1024) 322 mem := uint64(1024)
323 disk := uint64(1024) 323 disk := uint64(1024)
324 hc := instance.HardwareCharacteristics{ 324 hc := instance.HardwareCharacteristics{
325 » » Arch: &arch, 325 » » Arch: &arch,
326 » » Mem: &mem, 326 » » Mem: &mem,
327 » » OsDisk: &disk, 327 » » RootDisk: &disk,
328 } 328 }
329 m, err := s.State.InjectMachine("series", cons, instance.Id("i-mindustri ous"), hc, state.JobHostUnits, state.JobManageEnviron) 329 m, err := s.State.InjectMachine("series", cons, instance.Id("i-mindustri ous"), hc, state.JobHostUnits, state.JobManageEnviron)
330 c.Assert(err, gc.IsNil) 330 c.Assert(err, gc.IsNil)
331 c.Assert(m.Jobs(), gc.DeepEquals, []state.MachineJob{state.JobHostUnits, state.JobManageEnviron}) 331 c.Assert(m.Jobs(), gc.DeepEquals, []state.MachineJob{state.JobHostUnits, state.JobManageEnviron})
332 instanceId, err := m.InstanceId() 332 instanceId, err := m.InstanceId()
333 c.Assert(err, gc.IsNil) 333 c.Assert(err, gc.IsNil)
334 c.Assert(instanceId, gc.Equals, instance.Id("i-mindustrious")) 334 c.Assert(instanceId, gc.Equals, instance.Id("i-mindustrious"))
335 mcons, err := m.Constraints() 335 mcons, err := m.Constraints()
336 c.Assert(err, gc.IsNil) 336 c.Assert(err, gc.IsNil)
337 c.Assert(cons, gc.DeepEquals, mcons) 337 c.Assert(cons, gc.DeepEquals, mcons)
(...skipping 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after
1745 c.Assert(state.ParentId("0"), gc.Equals, "") 1745 c.Assert(state.ParentId("0"), gc.Equals, "")
1746 c.Assert(state.ParentId("0/lxc/1"), gc.Equals, "0") 1746 c.Assert(state.ParentId("0/lxc/1"), gc.Equals, "0")
1747 c.Assert(state.ParentId("0/lxc/1/kvm/0"), gc.Equals, "0/lxc/1") 1747 c.Assert(state.ParentId("0/lxc/1/kvm/0"), gc.Equals, "0/lxc/1")
1748 } 1748 }
1749 1749
1750 func (s *StateSuite) TestContainerTypeFromId(c *gc.C) { 1750 func (s *StateSuite) TestContainerTypeFromId(c *gc.C) {
1751 c.Assert(state.ContainerTypeFromId("0"), gc.Equals, instance.ContainerTy pe("")) 1751 c.Assert(state.ContainerTypeFromId("0"), gc.Equals, instance.ContainerTy pe(""))
1752 c.Assert(state.ContainerTypeFromId("0/lxc/1"), gc.Equals, instance.LXC) 1752 c.Assert(state.ContainerTypeFromId("0/lxc/1"), gc.Equals, instance.LXC)
1753 c.Assert(state.ContainerTypeFromId("0/lxc/1/kvm/0"), gc.Equals, instance .KVM) 1753 c.Assert(state.ContainerTypeFromId("0/lxc/1/kvm/0"), gc.Equals, instance .KVM)
1754 } 1754 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b