本文整理汇总了Golang中github.com/juju/juju/version.MustParse函数的典型用法代码示例。如果您正苦于以下问题:Golang MustParse函数的具体用法?Golang MustParse怎么用?Golang MustParse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MustParse函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
}
}
开发者ID:kapilt,项目名称:juju,代码行数:28,代码来源:upgrade_test.go
示例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
}
开发者ID:exekias,项目名称:juju,代码行数:27,代码来源:upgrade_test.go
示例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)
}
开发者ID:pmatulis,项目名称:juju,代码行数:7,代码来源:tools_test.go
示例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()
}
开发者ID:pmatulis,项目名称:juju,代码行数:26,代码来源:upgrader_test.go
示例5: twoDotOhDeprecation
func twoDotOhDeprecation(replacement string) cmd.DeprecationCheck {
return &versionDeprecation{
replacement: replacement,
deprecate: version.MustParse("2.0-00"),
obsolete: version.MustParse("3.0-00"),
}
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:7,代码来源:main.go
示例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.*")
}
开发者ID:imoapps,项目名称:juju,代码行数:9,代码来源:upgradejuju_test.go
示例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)
}
}
开发者ID:snailwalker,项目名称:juju,代码行数:13,代码来源:tools_test.go
示例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)
}
开发者ID:imoapps,项目名称:juju,代码行数:14,代码来源:upgradejuju_test.go
示例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)
}
开发者ID:ktsakalozos,项目名称:juju,代码行数:7,代码来源:environmentcommand_test.go
示例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)
}
开发者ID:rogpeppe,项目名称:juju,代码行数:26,代码来源:format-1.16_whitebox_test.go
示例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)
}
开发者ID:kakamessi99,项目名称:juju,代码行数:35,代码来源:steps121_test.go
示例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)
}
开发者ID:imoapps,项目名称:juju,代码行数:31,代码来源:format-1.16_whitebox_test.go
示例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")
}
开发者ID:imoapps,项目名称:juju,代码行数:35,代码来源:metadata_test.go
示例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)
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:7,代码来源:steps125_test.go
示例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,
}
}
开发者ID:rogpeppe,项目名称:juju,代码行数:9,代码来源:simplestreams.go
示例16: TestFindAvailableToolsSpecificVersion
func (s *toolsSuite) TestFindAvailableToolsSpecificVersion(c *gc.C) {
currentVersion := version.Binary{
Number: version.Current,
Arch: arch.HostArch(),
Series: series.HostSeries(),
}
currentVersion.Major = 2
currentVersion.Minor = 3
s.PatchValue(&version.Current, currentVersion.Number)
var findToolsCalled int
s.PatchValue(bootstrap.FindTools, func(_ environs.Environ, major, minor int, stream string, f tools.Filter) (tools.List, error) {
c.Assert(f.Number.Major, gc.Equals, 10)
c.Assert(f.Number.Minor, gc.Equals, 11)
c.Assert(f.Number.Patch, gc.Equals, 12)
c.Assert(stream, gc.Equals, "released")
findToolsCalled++
return []*tools.Tools{
&tools.Tools{
Version: currentVersion,
URL: "http://testing.invalid/tools.tar.gz",
},
}, nil
})
env := newEnviron("foo", useDefaultKeys, nil)
toolsVersion := version.MustParse("10.11.12")
result, err := bootstrap.FindAvailableTools(env, &toolsVersion, nil, nil, false)
c.Assert(err, jc.ErrorIsNil)
c.Assert(findToolsCalled, gc.Equals, 1)
c.Assert(result, jc.DeepEquals, tools.List{
&tools.Tools{
Version: currentVersion,
URL: "http://testing.invalid/tools.tar.gz",
},
})
}
开发者ID:pmatulis,项目名称:juju,代码行数:35,代码来源:tools_test.go
示例17: checkCanUpgrade
func (st *State) checkCanUpgrade(currentVersion, newVersion string) error {
matchCurrent := "^" + regexp.QuoteMeta(currentVersion) + "-"
matchNew := "^" + regexp.QuoteMeta(newVersion) + "-"
// Get all machines and units with a different or empty version.
sel := bson.D{{"$or", []bson.D{
{{"tools", bson.D{{"$exists", false}}}},
{{"$and", []bson.D{
{{"tools.version", bson.D{{"$not", bson.RegEx{matchCurrent, ""}}}}},
{{"tools.version", bson.D{{"$not", bson.RegEx{matchNew, ""}}}}},
}}},
}}}
var agentTags []string
for _, collection := range []*mgo.Collection{st.machines, st.units} {
var doc struct {
Id string `bson:"_id"`
}
iter := collection.Find(sel).Select(bson.D{{"_id", 1}}).Iter()
for iter.Next(&doc) {
switch collection.Name {
case "machines":
agentTags = append(agentTags, names.NewMachineTag(doc.Id).String())
case "units":
agentTags = append(agentTags, names.NewUnitTag(doc.Id).String())
}
}
if err := iter.Close(); err != nil {
return err
}
}
if len(agentTags) > 0 {
return newVersionInconsistentError(version.MustParse(currentVersion), agentTags)
}
return nil
}
开发者ID:klyachin,项目名称:juju,代码行数:34,代码来源:state.go
示例18: TestMissingAttributes
func (s *format_1_18Suite) 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()
configPath := filepath.Join(dataDir, agentConfigFilename)
err = utils.AtomicWriteFile(configPath, []byte(configData1_18WithoutUpgradedToVersion), 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)
c.Assert(readConfig.PreferIPv6(), jc.IsFalse)
// The api info doesn't have the environment tag set.
apiInfo, ok := readConfig.APIInfo()
c.Assert(ok, jc.IsTrue)
c.Assert(apiInfo.EnvironTag.Id(), gc.Equals, "")
}
开发者ID:imoapps,项目名称:juju,代码行数:27,代码来源:format-1.18_whitebox_test.go
示例19: TestAllowedTargetVersionSuite
func (s *AllowedTargetVersionSuite) TestAllowedTargetVersionSuite(c *gc.C) {
cases := []allowedTest{
{current: "1.2.3", target: "1.3.3", allowed: true},
{current: "1.2.3", target: "1.2.3", allowed: true},
{current: "1.2.3", target: "2.2.3", allowed: true},
{current: "1.2.3", target: "1.1.3", allowed: false},
{current: "1.2.3", target: "1.2.2", allowed: true},
{current: "1.2.3", target: "0.2.3", allowed: false},
}
for i, test := range cases {
c.Logf("test case %d, %#v", i, test)
current := version.MustParse(test.current)
target := version.MustParse(test.target)
c.Check(upgrader.AllowedTargetVersion(current, target), gc.Equals, test.allowed)
}
}
开发者ID:klyachin,项目名称:juju,代码行数:16,代码来源:upgrader_test.go
示例20: TestStateStepsNotAttemptedWhenNoStateTarget
func (s *upgradeSuite) TestStateStepsNotAttemptedWhenNoStateTarget(c *gc.C) {
stateCount := 0
stateUpgradeOperations := func() []upgrades.Operation {
stateCount++
return nil
}
s.PatchValue(upgrades.StateUpgradeOperations, stateUpgradeOperations)
apiCount := 0
upgradeOperations := func() []upgrades.Operation {
apiCount++
return nil
}
s.PatchValue(upgrades.UpgradeOperations, upgradeOperations)
fromVers := version.MustParse("1.18.0")
ctx := new(mockContext)
check := func(target upgrades.Target, expectedStateCallCount int) {
stateCount = 0
apiCount = 0
err := upgrades.PerformUpgrade(fromVers, targets(target), ctx)
c.Assert(err, jc.ErrorIsNil)
c.Assert(stateCount, gc.Equals, expectedStateCallCount)
c.Assert(apiCount, gc.Equals, 1)
}
check(upgrades.Controller, 1)
check(upgrades.DatabaseMaster, 1)
check(upgrades.AllMachines, 0)
check(upgrades.HostMachine, 0)
}
开发者ID:exekias,项目名称:juju,代码行数:31,代码来源:upgrade_test.go
注:本文中的github.com/juju/juju/version.MustParse函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论