github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/upgrades/steps_22_test.go (about)

     1  // Copyright 2017 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package upgrades_test
     5  
     6  import (
     7  	"io/ioutil"
     8  	"path/filepath"
     9  
    10  	jc "github.com/juju/testing/checkers"
    11  	"github.com/juju/version"
    12  	gc "gopkg.in/check.v1"
    13  
    14  	"github.com/juju/juju/testing"
    15  	"github.com/juju/juju/upgrades"
    16  )
    17  
    18  var v220 = version.MustParse("2.2.0")
    19  
    20  type steps22Suite struct {
    21  	testing.BaseSuite
    22  }
    23  
    24  var _ = gc.Suite(&steps22Suite{})
    25  
    26  func (s *steps22Suite) TestAddNonDetachableStorageMachineId(c *gc.C) {
    27  	step := findStateStep(c, v220, "add machineid to non-detachable storage docs")
    28  	// Logic for step itself is tested in state package.
    29  	c.Assert(step.Targets(), jc.DeepEquals, []upgrades.Target{upgrades.DatabaseMaster})
    30  }
    31  
    32  func (s *steps22Suite) TestMeterStatusFile(c *gc.C) {
    33  	// Create a meter status file.
    34  	dataDir := c.MkDir()
    35  	statusFile := filepath.Join(dataDir, "meter-status.yaml")
    36  	err := ioutil.WriteFile(statusFile, []byte("things"), 0777)
    37  	c.Assert(err, jc.ErrorIsNil)
    38  
    39  	step := findStep(c, v220, "remove meter status file")
    40  
    41  	check := func() {
    42  		context := &mockContext{
    43  			agentConfig: &mockAgentConfig{dataDir: dataDir},
    44  		}
    45  		err = step.Run(context)
    46  		c.Assert(err, jc.ErrorIsNil)
    47  
    48  		// Status file should be gone.
    49  		c.Check(pathExists(statusFile), jc.IsFalse)
    50  		c.Check(pathExists(dataDir), jc.IsTrue)
    51  	}
    52  
    53  	check()
    54  	check() // Check OK when file not present.
    55  }
    56  
    57  func (s *steps22Suite) TestAddControllerLogCollectionsSizeSettings(c *gc.C) {
    58  	step := findStateStep(c, v220, "add controller log collection sizing config settings")
    59  	// Logic for step itself is tested in state package.
    60  	c.Assert(step.Targets(), jc.DeepEquals, []upgrades.Target{upgrades.DatabaseMaster})
    61  }
    62  
    63  func (s *steps22Suite) TestAddStatusHistoryPruneSettings(c *gc.C) {
    64  	step := findStateStep(c, v220, "add status history pruning config settings")
    65  	// Logic for step itself is tested in state package.
    66  	c.Assert(step.Targets(), jc.DeepEquals, []upgrades.Target{upgrades.DatabaseMaster})
    67  }
    68  
    69  func (s *steps22Suite) TestAddStorageInstanceConstraints(c *gc.C) {
    70  	step := findStateStep(c, v220, "add storage constraints to storage instance docs")
    71  	// Logic for step itself is tested in state package.
    72  	c.Assert(step.Targets(), jc.DeepEquals, []upgrades.Target{upgrades.DatabaseMaster})
    73  }
    74  
    75  func (s *steps22Suite) TestSplitLogStep(c *gc.C) {
    76  	step := findStateStep(c, v220, "split log collections")
    77  	// Logic for step itself is tested in state package.
    78  	c.Assert(step.Targets(), jc.DeepEquals, []upgrades.Target{upgrades.DatabaseMaster})
    79  }