本文整理汇总了Golang中github.com/juju/juju/version.MustParse函数的典型用法代码示例。如果您正苦于以下问题:Golang MustParse函数的具体用法?Golang MustParse怎么用?Golang MustParse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MustParse函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestPerformUpgrade
func (s *upgradeSuite) TestPerformUpgrade(c *gc.C) {
s.PatchValue(upgrades.UpgradeOperations, upgradeOperations)
for i, test := range upgradeTests {
c.Logf("%d: %s", i, test.about)
var messages []string
ctx := &mockContext{
messages: messages,
}
fromVersion := version.Zero
if test.fromVersion != "" {
fromVersion = version.MustParse(test.fromVersion)
}
toVersion := version.MustParse("1.18.0")
if test.toVersion != "" {
toVersion = version.MustParse(test.toVersion)
}
vers := version.Current
vers.Number = toVersion
s.PatchValue(&version.Current, vers)
err := upgrades.PerformUpgrade(fromVersion, test.target, ctx)
if test.err == "" {
c.Check(err, gc.IsNil)
} else {
c.Check(err, gc.ErrorMatches, test.err)
}
c.Check(ctx.messages, jc.DeepEquals, test.expectedSteps)
}
}
示例2: stateUpgradeOperations
func stateUpgradeOperations() []upgrades.Operation {
steps := []upgrades.Operation{
&mockUpgradeOperation{
targetVersion: version.MustParse("1.11.0"),
steps: []upgrades.Step{
newUpgradeStep("state step 1 - 1.11.0", upgrades.Controller),
newUpgradeStep("state step 2 error", upgrades.Controller),
newUpgradeStep("state step 3 - 1.11.0", upgrades.Controller),
},
},
&mockUpgradeOperation{
targetVersion: version.MustParse("1.21.0"),
steps: []upgrades.Step{
newUpgradeStep("state step 1 - 1.21.0", upgrades.DatabaseMaster),
newUpgradeStep("state step 2 - 1.21.0", upgrades.Controller),
},
},
&mockUpgradeOperation{
targetVersion: version.MustParse("1.22.0"),
steps: []upgrades.Step{
newUpgradeStep("state step 1 - 1.22.0", upgrades.DatabaseMaster),
newUpgradeStep("state step 2 - 1.22.0", upgrades.Controller),
},
},
}
return steps
}
示例3: TestFindToolsExactNotInStorage
func (s *toolsSuite) TestFindToolsExactNotInStorage(c *gc.C) {
mockToolsStorage := &mockToolsStorage{}
s.PatchValue(&version.Current, version.MustParse("1.22-beta1"))
s.testFindToolsExact(c, mockToolsStorage, false, true)
s.PatchValue(&version.Current, version.MustParse("1.22.0"))
s.testFindToolsExact(c, mockToolsStorage, false, false)
}
示例4: TestWatchAPIVersion
func (s *machineUpgraderSuite) TestWatchAPIVersion(c *gc.C) {
w, err := s.st.WatchAPIVersion(s.rawMachine.Tag().String())
c.Assert(err, jc.ErrorIsNil)
wc := watchertest.NewNotifyWatcherC(c, w, s.BackingState.StartSync)
defer wc.AssertStops()
// Initial event
wc.AssertOneChange()
// One change noticing the new version
vers := version.MustParse("10.20.34")
err = statetesting.SetAgentVersion(s.BackingState, vers)
c.Assert(err, jc.ErrorIsNil)
wc.AssertOneChange()
// Setting the version to the same value doesn't trigger a change
err = statetesting.SetAgentVersion(s.BackingState, vers)
c.Assert(err, jc.ErrorIsNil)
wc.AssertNoChange()
// Another change noticing another new version
vers = version.MustParse("10.20.35")
err = statetesting.SetAgentVersion(s.BackingState, vers)
c.Assert(err, jc.ErrorIsNil)
wc.AssertOneChange()
}
示例5: twoDotOhDeprecation
func twoDotOhDeprecation(replacement string) cmd.DeprecationCheck {
return &versionDeprecation{
replacement: replacement,
deprecate: version.MustParse("2.0-00"),
obsolete: version.MustParse("3.0-00"),
}
}
示例6: TestBlockUpgradeJujuWithRealUpload
func (s *UpgradeJujuSuite) TestBlockUpgradeJujuWithRealUpload(c *gc.C) {
s.Reset(c)
s.PatchValue(&version.Current, version.MustParse("1.99.99"))
cmd := newUpgradeJujuCommand(map[int]version.Number{2: version.MustParse("1.99.99")})
// Block operation
s.BlockAllChanges(c, "TestBlockUpgradeJujuWithRealUpload")
_, err := coretesting.RunCommand(c, cmd, "--upload-tools")
s.AssertBlocked(c, err, ".*TestBlockUpgradeJujuWithRealUpload.*")
}
示例7: TestPreferredStream
func (s *SimpleStreamsToolsSuite) TestPreferredStream(c *gc.C) {
for i, test := range preferredStreamTests {
c.Logf("\ntest %d", i)
s.PatchValue(&version.Current, version.MustParse(test.currentVers))
var vers *version.Number
if test.explicitVers != "" {
v := version.MustParse(test.explicitVers)
vers = &v
}
obtained := envtools.PreferredStream(vers, test.forceDevel, test.streamInConfig)
c.Check(obtained, gc.Equals, test.expected)
}
}
示例8: TestUpgradeJujuWithRealUpload
func (s *UpgradeJujuSuite) TestUpgradeJujuWithRealUpload(c *gc.C) {
s.Reset(c)
s.PatchValue(&version.Current, version.MustParse("1.99.99"))
cmd := newUpgradeJujuCommand(map[int]version.Number{2: version.MustParse("1.99.99")})
_, err := coretesting.RunCommand(c, cmd, "--upload-tools")
c.Assert(err, jc.ErrorIsNil)
vers := version.Binary{
Number: version.Current,
Arch: arch.HostArch(),
Series: series.HostSeries(),
}
vers.Build = 1
s.checkToolsUploaded(c, vers, vers.Number)
}
示例9: TestSuccess
func (s *EnvironmentVersionSuite) TestSuccess(c *gc.C) {
vs := "1.22.1"
s.fake.agentVersion = vs
v, err := envcmd.GetEnvironmentVersion(s.fake)
c.Assert(err, jc.ErrorIsNil)
c.Assert(v.Compare(version.MustParse(vs)), gc.Equals, 0)
}
示例10: TestReadConfReadsLegacyFormatAndWritesNew
func (*format_1_16Suite) TestReadConfReadsLegacyFormatAndWritesNew(c *gc.C) {
dataDir := c.MkDir()
formatPath := filepath.Join(dataDir, legacyFormatFilename)
err := utils.AtomicWriteFile(formatPath, []byte(legacyFormatFileContents), 0600)
c.Assert(err, gc.IsNil)
configPath := filepath.Join(dataDir, agentConfigFilename)
err = utils.AtomicWriteFile(configPath, []byte(agentConfig1_16Contents), 0600)
c.Assert(err, gc.IsNil)
config, err := ReadConfig(configPath)
c.Assert(err, gc.IsNil)
c.Assert(config, gc.NotNil)
// Test we wrote a currently valid config.
config, err = ReadConfig(configPath)
c.Assert(err, gc.IsNil)
c.Assert(config, gc.NotNil)
c.Assert(config.UpgradedToVersion(), jc.DeepEquals, version.MustParse("1.16.0"))
c.Assert(config.Jobs(), gc.HasLen, 0)
// Old format was deleted.
assertFileNotExist(c, formatPath)
// And new contents were written.
data, err := ioutil.ReadFile(configPath)
c.Assert(err, gc.IsNil)
c.Assert(string(data), gc.Not(gc.Equals), agentConfig1_16Contents)
}
示例11: TestStateStepsFor121
func (s *steps121Suite) TestStateStepsFor121(c *gc.C) {
expected := []string{
// Settings, and then environment UUID, related migrations should
// come first as other upgrade steps may rely on them.
"add the version field to all settings docs",
"add environment uuid to state server doc",
"set environment owner and server uuid",
// It is important to keep the order of the following three steps:
// 1.migrate machine instanceId, 2. Add env ID to machine docs, 3.
// Add env ID to instanceData docs. If the order changes, bad things
// will happen.
"migrate machine instanceId into instanceData",
"prepend the environment UUID to the ID of all machine docs",
"prepend the environment UUID to the ID of all instanceData docs",
"prepend the environment UUID to the ID of all containerRef docs",
"prepend the environment UUID to the ID of all service docs",
"prepend the environment UUID to the ID of all unit docs",
"prepend the environment UUID to the ID of all reboot docs",
"prepend the environment UUID to the ID of all relations docs",
"prepend the environment UUID to the ID of all relationscopes docs",
"prepend the environment UUID to the ID of all minUnit docs",
"prepend the environment UUID to the ID of all cleanup docs",
"prepend the environment UUID to the ID of all sequence docs",
// Non-environment UUID upgrade steps follow.
"rename the user LastConnection field to LastLogin",
"add all users in state as environment users",
"migrate custom image metadata into environment storage",
"migrate tools into environment storage",
"migrate individual unit ports to openedPorts collection",
"create entries in meter status collection for existing units",
"migrate machine jobs into ones with JobManageNetworking based on rules",
}
assertStateSteps(c, version.MustParse("1.21.0"), expected)
}
示例12: TestMissingAttributes
func (s *format_1_16Suite) TestMissingAttributes(c *gc.C) {
logDir, err := paths.LogDir(series.HostSeries())
c.Assert(err, jc.ErrorIsNil)
realDataDir, err := paths.DataDir(series.HostSeries())
c.Assert(err, jc.ErrorIsNil)
realDataDir = filepath.FromSlash(realDataDir)
logPath := filepath.Join(logDir, "juju")
logPath = filepath.FromSlash(logPath)
dataDir := c.MkDir()
formatPath := filepath.Join(dataDir, legacyFormatFilename)
err = utils.AtomicWriteFile(formatPath, []byte(legacyFormatFileContents), 0600)
c.Assert(err, jc.ErrorIsNil)
configPath := filepath.Join(dataDir, agentConfigFilename)
err = utils.AtomicWriteFile(configPath, []byte(configDataWithoutNewAttributes), 0600)
c.Assert(err, jc.ErrorIsNil)
readConfig, err := ReadConfig(configPath)
c.Assert(err, jc.ErrorIsNil)
c.Assert(readConfig.UpgradedToVersion(), gc.Equals, version.MustParse("1.16.0"))
configLogDir := filepath.FromSlash(readConfig.LogDir())
configDataDir := filepath.FromSlash(readConfig.DataDir())
c.Assert(configLogDir, gc.Equals, logPath)
c.Assert(configDataDir, gc.Equals, realDataDir)
// Test data doesn't include a StateServerKey so StateServingInfo
// should *not* be available
_, available := readConfig.StateServingInfo()
c.Assert(available, jc.IsFalse)
}
示例13: TestAsJSONBuffer
func (s *metadataSuite) TestAsJSONBuffer(c *gc.C) {
meta := backups.NewMetadata()
meta.Origin = backups.Origin{
Environment: "asdf-zxcv-qwe",
Machine: "0",
Hostname: "myhost",
Version: version.MustParse("1.21-alpha3"),
}
meta.Started = time.Date(2014, time.Month(9), 9, 11, 59, 34, 0, time.UTC)
meta.SetID("20140909-115934.asdf-zxcv-qwe")
err := meta.MarkComplete(10, "123af2cef")
c.Assert(err, jc.ErrorIsNil)
finished := meta.Started.Add(time.Minute)
meta.Finished = &finished
buf, err := meta.AsJSONBuffer()
c.Assert(err, jc.ErrorIsNil)
c.Check(buf.(*bytes.Buffer).String(), gc.Equals, `{`+
`"ID":"20140909-115934.asdf-zxcv-qwe",`+
`"Checksum":"123af2cef",`+
`"ChecksumFormat":"SHA-1, base64 encoded",`+
`"Size":10,`+
`"Stored":"0001-01-01T00:00:00Z",`+
`"Started":"2014-09-09T11:59:34Z",`+
`"Finished":"2014-09-09T12:00:34Z",`+
`"Notes":"",`+
`"Environment":"asdf-zxcv-qwe",`+
`"Machine":"0",`+
`"Hostname":"myhost",`+
`"Version":"1.21-alpha3"`+
`}`+"\n")
}
示例14: TestStepsFor125
func (s *steps125Suite) TestStepsFor125(c *gc.C) {
expected := []string{
"remove Jujud.pass file on windows",
"add juju registry key",
}
assertSteps(c, version.MustParse("1.25.0"), expected)
}
示例15: binary
// binary returns the tools metadata's binary version,
// which may be used for map lookup.
func (t *ToolsMetadata) binary() version.Binary {
return version.Binary{
Number: version.MustParse(t.Version),
Series: t.Release,
Arch: t.Arch,
}
}