github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/container/kvm/initialisation_internal_test.go (about) 1 // Copyright 2016 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package kvm 5 6 import ( 7 "fmt" 8 "io/ioutil" 9 "os" 10 11 "github.com/juju/testing" 12 jc "github.com/juju/testing/checkers" 13 gc "gopkg.in/check.v1" 14 ) 15 16 // gocheck boilerplate. 17 type initialisationInternalSuite struct { 18 testing.IsolationSuite 19 } 20 21 var _ = gc.Suite(&initialisationInternalSuite{}) 22 23 func (initialisationInternalSuite) TestCreatePool(c *gc.C) { 24 tmpDir, err := ioutil.TempDir("", "juju-initialisationInternalSuite") 25 defer func() { 26 err = os.RemoveAll(tmpDir) 27 if err != nil { 28 c.Errorf("failed to remove tmpDir: %s\n", err) 29 } 30 }() 31 c.Check(err, jc.ErrorIsNil) 32 pathfinder := func(s string) (string, error) { 33 return tmpDir, nil 34 } 35 stub := runStub{} 36 chown := func(string) error { return nil } 37 err = createPool(pathfinder, stub.Run, chown) 38 c.Check(err, jc.ErrorIsNil) 39 c.Assert(stub.Calls(), jc.DeepEquals, []string{ 40 fmt.Sprintf("virsh pool-define-as juju-pool dir - - - - %s/kvm/guests", tmpDir), 41 "virsh pool-build juju-pool", 42 "virsh pool-start juju-pool", 43 "virsh pool-autostart juju-pool", 44 }) 45 } 46 47 func (initialisationInternalSuite) TestRequiredPackagesAMD64(c *gc.C) { 48 got := getRequiredPackages("amd64") 49 c.Assert(got, jc.DeepEquals, []string{"qemu-kvm", "qemu-utils", "genisoimage", "libvirt-bin"}) 50 } 51 52 func (initialisationInternalSuite) TestRequiredPackagesARM64(c *gc.C) { 53 got := getRequiredPackages("arm64") 54 c.Assert(got, jc.DeepEquals, []string{"qemu-efi", "qemu-kvm", "qemu-utils", "genisoimage", "libvirt-bin"}) 55 }