本文整理汇总了Golang中github.com/wallyworld/core/version.MustParseBinary函数的典型用法代码示例。如果您正苦于以下问题:Golang MustParseBinary函数的具体用法?Golang MustParseBinary怎么用?Golang MustParseBinary使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MustParseBinary函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestAutoUploadAfterFailedSync
func (s *BootstrapSuite) TestAutoUploadAfterFailedSync(c *gc.C) {
s.PatchValue(&version.Current.Series, config.LatestLtsSeries())
otherSeries := "quantal"
env := s.setupAutoUploadTest(c, "1.7.3", otherSeries)
// Run command and check for that upload has been run for tools matching the current juju version.
opc, errc := runCommand(nullContext(c), new(BootstrapCommand))
c.Assert(<-errc, gc.IsNil)
c.Assert((<-opc).(dummy.OpPutFile).Env, gc.Equals, "peckham")
list, err := envtools.FindTools(env, version.Current.Major, version.Current.Minor, coretools.Filter{}, false)
c.Assert(err, gc.IsNil)
c.Logf("found: " + list.String())
urls := list.URLs()
// We expect:
// supported LTS series precise, trusty,
// the specified series (quantal),
// and the environment's default series (raring).
expectedVers := []version.Binary{
version.MustParseBinary(fmt.Sprintf("1.7.3.1-%s-%s", "quantal", version.Current.Arch)),
version.MustParseBinary(fmt.Sprintf("1.7.3.1-%s-%s", "raring", version.Current.Arch)),
version.MustParseBinary(fmt.Sprintf("1.7.3.1-%s-%s", "precise", version.Current.Arch)),
version.MustParseBinary(fmt.Sprintf("1.7.3.1-%s-%s", "trusty", version.Current.Arch)),
}
c.Assert(urls, gc.HasLen, len(expectedVers))
for _, vers := range expectedVers {
c.Logf("seeking: " + vers.String())
_, found := urls[vers]
c.Check(found, gc.Equals, true)
}
}
开发者ID:jameinel,项目名称:core,代码行数:31,代码来源:bootstrap_test.go
示例2: assertWriteMetadata
func (s *simplestreamsSuite) assertWriteMetadata(c *gc.C, withMirrors bool) {
var versionStrings = []string{
"1.2.3-precise-amd64",
"2.0.1-raring-amd64",
}
dir := c.MkDir()
ttesting.MakeTools(c, dir, "releases", versionStrings)
toolsList := coretools.List{
{
// If sha256/size is already known, do not recalculate
Version: version.MustParseBinary("1.2.3-precise-amd64"),
Size: 123,
SHA256: "abcd",
}, {
Version: version.MustParseBinary("2.0.1-raring-amd64"),
// The URL is not used for generating metadata.
URL: "bogus://",
},
}
writer, err := filestorage.NewFileStorageWriter(dir)
c.Assert(err, gc.IsNil)
writeMirrors := tools.DoNotWriteMirrors
if withMirrors {
writeMirrors = tools.WriteMirrors
}
err = tools.MergeAndWriteMetadata(writer, toolsList, writeMirrors)
c.Assert(err, gc.IsNil)
metadata := ttesting.ParseMetadataFromDir(c, dir, withMirrors)
assertMetadataMatches(c, dir, toolsList, metadata)
}
开发者ID:jameinel,项目名称:core,代码行数:31,代码来源:simplestreams_test.go
示例3: TestMetadataFromTools
func (*metadataHelperSuite) TestMetadataFromTools(c *gc.C) {
metadata := tools.MetadataFromTools(nil)
c.Assert(metadata, gc.HasLen, 0)
toolsList := coretools.List{{
Version: version.MustParseBinary("1.2.3-precise-amd64"),
Size: 123,
SHA256: "abc",
}, {
Version: version.MustParseBinary("2.0.1-raring-amd64"),
URL: "file:///tmp/releases/juju-2.0.1-raring-amd64.tgz",
Size: 456,
SHA256: "xyz",
}}
metadata = tools.MetadataFromTools(toolsList)
c.Assert(metadata, gc.HasLen, len(toolsList))
for i, t := range toolsList {
md := metadata[i]
c.Assert(md.Release, gc.Equals, t.Version.Series)
c.Assert(md.Version, gc.Equals, t.Version.Number.String())
c.Assert(md.Arch, gc.Equals, t.Version.Arch)
// FullPath is only filled out when reading tools using simplestreams.
// It's not needed elsewhere and requires a URL() call.
c.Assert(md.FullPath, gc.Equals, "")
c.Assert(md.Path, gc.Equals, tools.StorageName(t.Version)[len("tools/"):])
c.Assert(md.FileType, gc.Equals, "tar.gz")
c.Assert(md.Size, gc.Equals, t.Size)
c.Assert(md.SHA256, gc.Equals, t.SHA256)
}
}
开发者ID:jameinel,项目名称:core,代码行数:30,代码来源:simplestreams_test.go
示例4: TestWriteMetadataMergeWithExisting
func (s *simplestreamsSuite) TestWriteMetadataMergeWithExisting(c *gc.C) {
dir := c.MkDir()
existingToolsList := coretools.List{
{
Version: version.MustParseBinary("1.2.3-precise-amd64"),
Size: 123,
SHA256: "abc",
}, {
Version: version.MustParseBinary("2.0.1-raring-amd64"),
Size: 456,
SHA256: "xyz",
},
}
writer, err := filestorage.NewFileStorageWriter(dir)
c.Assert(err, gc.IsNil)
err = tools.MergeAndWriteMetadata(writer, existingToolsList, tools.DoNotWriteMirrors)
c.Assert(err, gc.IsNil)
newToolsList := coretools.List{
existingToolsList[0],
{
Version: version.MustParseBinary("2.1.0-raring-amd64"),
Size: 789,
SHA256: "def",
},
}
err = tools.MergeAndWriteMetadata(writer, newToolsList, tools.DoNotWriteMirrors)
c.Assert(err, gc.IsNil)
requiredToolsList := append(existingToolsList, newToolsList[1])
metadata := ttesting.ParseMetadataFromDir(c, dir, false)
assertMetadataMatches(c, dir, requiredToolsList, metadata)
}
开发者ID:jameinel,项目名称:core,代码行数:31,代码来源:simplestreams_test.go
示例5: TestUpgraderUpgradesImmediately
func (s *UpgraderSuite) TestUpgraderUpgradesImmediately(c *gc.C) {
stor := s.Conn.Environ.Storage()
oldTools := envtesting.PrimeTools(c, stor, s.DataDir(), version.MustParseBinary("5.4.3-precise-amd64"))
s.PatchValue(&version.Current, oldTools.Version)
newTools := envtesting.AssertUploadFakeToolsVersions(
c, stor, version.MustParseBinary("5.4.5-precise-amd64"))[0]
err := statetesting.SetAgentVersion(s.State, newTools.Version.Number)
c.Assert(err, gc.IsNil)
// Make the download take a while so that we verify that
// the download happens before the upgrader checks if
// it's been stopped.
dummy.SetStorageDelay(coretesting.ShortWait)
u := s.makeUpgrader()
err = u.Stop()
envtesting.CheckUpgraderReadyError(c, err, &upgrader.UpgradeReadyError{
AgentName: s.machine.Tag(),
OldTools: oldTools.Version,
NewTools: newTools.Version,
DataDir: s.DataDir(),
})
foundTools, err := agenttools.ReadTools(s.DataDir(), newTools.Version)
c.Assert(err, gc.IsNil)
envtesting.CheckTools(c, foundTools, newTools)
}
开发者ID:jameinel,项目名称:core,代码行数:26,代码来源:upgrader_test.go
示例6: TestSetBootstrapTools
func (s *bootstrapSuite) TestSetBootstrapTools(c *gc.C) {
availableVersions := []version.Binary{
version.MustParseBinary("1.18.0-trusty-arm64"),
version.MustParseBinary("1.18.1-trusty-arm64"),
version.MustParseBinary("1.18.1.1-trusty-arm64"),
version.MustParseBinary("1.18.1.2-trusty-arm64"),
version.MustParseBinary("1.18.1.3-trusty-arm64"),
}
availableTools := make(tools.List, len(availableVersions))
for i, v := range availableVersions {
availableTools[i] = &tools.Tools{Version: v}
}
type test struct {
currentVersion version.Number
expectedTools version.Number
expectedAgentVersion version.Number
}
tests := []test{{
currentVersion: version.MustParse("1.18.0"),
expectedTools: version.MustParse("1.18.0"),
expectedAgentVersion: version.MustParse("1.18.1.3"),
}, {
currentVersion: version.MustParse("1.18.1.4"),
expectedTools: version.MustParse("1.18.1.3"),
expectedAgentVersion: version.MustParse("1.18.1.3"),
}, {
// build number is ignored unless major/minor don't
// match the latest.
currentVersion: version.MustParse("1.18.1.2"),
expectedTools: version.MustParse("1.18.1.3"),
expectedAgentVersion: version.MustParse("1.18.1.3"),
}, {
// If the current patch level exceeds whatever's in
// the tools source (e.g. when bootstrapping from trunk)
// then the latest available tools will be chosen.
currentVersion: version.MustParse("1.18.2"),
expectedTools: version.MustParse("1.18.1.3"),
expectedAgentVersion: version.MustParse("1.18.1.3"),
}}
env := newEnviron("foo", useDefaultKeys, nil)
for i, t := range tests {
c.Logf("test %d: %+v", i, t)
cfg, err := env.Config().Remove([]string{"agent-version"})
c.Assert(err, gc.IsNil)
err = env.SetConfig(cfg)
c.Assert(err, gc.IsNil)
s.PatchValue(&version.Current.Number, t.currentVersion)
bootstrapTools, err := bootstrap.SetBootstrapTools(env, availableTools)
c.Assert(err, gc.IsNil)
c.Assert(bootstrapTools, gc.HasLen, 1)
c.Assert(bootstrapTools[0].Version.Number, gc.Equals, t.expectedTools)
agentVersion, _ := env.Config().AgentVersion()
c.Assert(agentVersion, gc.Equals, t.expectedAgentVersion)
}
}
开发者ID:jameinel,项目名称:core,代码行数:57,代码来源:bootstrap_test.go
示例7: TestUpgraderRetryAndChanged
func (s *UpgraderSuite) TestUpgraderRetryAndChanged(c *gc.C) {
stor := s.Conn.Environ.Storage()
oldTools := envtesting.PrimeTools(c, stor, s.DataDir(), version.MustParseBinary("5.4.3-precise-amd64"))
s.PatchValue(&version.Current, oldTools.Version)
newTools := envtesting.AssertUploadFakeToolsVersions(
c, stor, version.MustParseBinary("5.4.5-precise-amd64"))[0]
err := statetesting.SetAgentVersion(s.State, newTools.Version.Number)
c.Assert(err, gc.IsNil)
retryc := make(chan time.Time)
*upgrader.RetryAfter = func() <-chan time.Time {
c.Logf("replacement retry after")
return retryc
}
dummy.Poison(s.Conn.Environ.Storage(), envtools.StorageName(newTools.Version), fmt.Errorf("a non-fatal dose"))
u := s.makeUpgrader()
defer u.Stop()
for i := 0; i < 3; i++ {
select {
case retryc <- time.Now():
case <-time.After(coretesting.LongWait):
c.Fatalf("upgrader did not retry (attempt %d)", i)
}
}
// Make it upgrade to some newer tools that can be
// downloaded ok; it should stop retrying, download
// the newer tools and exit.
newerTools := envtesting.AssertUploadFakeToolsVersions(
c, s.Conn.Environ.Storage(), version.MustParseBinary("5.4.6-precise-amd64"))[0]
err = statetesting.SetAgentVersion(s.State, newerTools.Version.Number)
c.Assert(err, gc.IsNil)
s.BackingState.StartSync()
done := make(chan error)
go func() {
done <- u.Wait()
}()
select {
case err := <-done:
envtesting.CheckUpgraderReadyError(c, err, &upgrader.UpgradeReadyError{
AgentName: s.machine.Tag(),
OldTools: oldTools.Version,
NewTools: newerTools.Version,
DataDir: s.DataDir(),
})
case <-time.After(coretesting.LongWait):
c.Fatalf("upgrader did not quit after upgrading")
}
}
开发者ID:jameinel,项目名称:core,代码行数:52,代码来源:upgrader_test.go
示例8: TestUploadFakeSeries
func (s *toolsSuite) TestUploadFakeSeries(c *gc.C) {
// Make some fake tools.
localStorage := c.MkDir()
vers := version.MustParseBinary("1.9.0-quantal-amd64")
versionStrings := []string{vers.String()}
expectedTools := ttesting.MakeToolsWithCheckSum(c, localStorage, "releases", versionStrings)
// Now try uploading them.
toolsFile := tools.StorageName(vers)
params := "?binaryVersion=" + vers.String() + "&series=precise,trusty"
resp, err := s.uploadRequest(c, s.toolsURI(c, params), true, path.Join(localStorage, toolsFile))
c.Assert(err, gc.IsNil)
// Check the response.
stor := s.Conn.Environ.Storage()
toolsURL, err := stor.URL(tools.StorageName(vers))
c.Assert(err, gc.IsNil)
expectedTools[0].URL = toolsURL
s.assertUploadResponse(c, resp, expectedTools[0])
// Check the contents.
for _, series := range []string{"precise", "quantal", "trusty"} {
toolsVersion := vers
toolsVersion.Series = series
r, err := stor.Get(tools.StorageName(toolsVersion))
c.Assert(err, gc.IsNil)
uploadedData, err := ioutil.ReadAll(r)
c.Assert(err, gc.IsNil)
expectedData, err := ioutil.ReadFile(filepath.Join(localStorage, tools.StorageName(vers)))
c.Assert(err, gc.IsNil)
c.Assert(uploadedData, gc.DeepEquals, expectedData)
}
}
开发者ID:jameinel,项目名称:core,代码行数:33,代码来源:tools_test.go
示例9: testAgentTools
func testAgentTools(c *gc.C, obj tooler, agent string) {
// object starts with zero'd tools.
t, err := obj.AgentTools()
c.Assert(t, gc.IsNil)
c.Assert(err, jc.Satisfies, errors.IsNotFound)
err = obj.SetAgentVersion(version.Binary{})
c.Assert(err, gc.ErrorMatches, fmt.Sprintf("cannot set agent version for %s: empty series or arch", agent))
v2 := version.MustParseBinary("7.8.9-foo-bar")
err = obj.SetAgentVersion(v2)
c.Assert(err, gc.IsNil)
t3, err := obj.AgentTools()
c.Assert(err, gc.IsNil)
c.Assert(t3.Version, gc.DeepEquals, v2)
err = obj.Refresh()
c.Assert(err, gc.IsNil)
t3, err = obj.AgentTools()
c.Assert(err, gc.IsNil)
c.Assert(t3.Version, gc.DeepEquals, v2)
testWhenDying(c, obj, noErr, deadErr, func() error {
return obj.SetAgentVersion(v2)
})
}
开发者ID:jameinel,项目名称:core,代码行数:25,代码来源:tools_test.go
示例10: runAllowRetriesTest
func (s *BootstrapSuite) runAllowRetriesTest(c *gc.C, test bootstrapRetryTest) {
toolsVersions := envtesting.VAll
if test.version != "" {
useVersion := strings.Replace(test.version, "%LTS%", config.LatestLtsSeries(), 1)
testVersion := version.MustParseBinary(useVersion)
s.PatchValue(&version.Current, testVersion)
if test.addVersionToSource {
toolsVersions = append([]version.Binary{}, toolsVersions...)
toolsVersions = append(toolsVersions, testVersion)
}
}
_, fake := makeEmptyFakeHome(c)
defer fake.Restore()
sourceDir := createToolsSource(c, toolsVersions)
s.PatchValue(&envtools.DefaultBaseURL, sourceDir)
var findToolsRetryValues []bool
mockFindTools := func(cloudInst environs.ConfigGetter, majorVersion, minorVersion int,
filter coretools.Filter, allowRetry bool) (list coretools.List, err error) {
findToolsRetryValues = append(findToolsRetryValues, allowRetry)
return nil, errors.NotFoundf("tools")
}
restore := envtools.TestingPatchBootstrapFindTools(mockFindTools)
defer restore()
_, errc := runCommand(nullContext(c), new(BootstrapCommand), test.args...)
err := <-errc
c.Check(findToolsRetryValues, gc.DeepEquals, test.expectedAllowRetry)
stripped := strings.Replace(err.Error(), "\n", "", -1)
c.Check(stripped, gc.Matches, test.err)
}
开发者ID:jameinel,项目名称:core,代码行数:32,代码来源:bootstrap_test.go
示例11: TestResolveMetadata
func (*metadataHelperSuite) TestResolveMetadata(c *gc.C) {
var versionStrings = []string{"1.2.3-precise-amd64"}
dir := c.MkDir()
ttesting.MakeTools(c, dir, "releases", versionStrings)
toolsList := coretools.List{{
Version: version.MustParseBinary(versionStrings[0]),
Size: 123,
SHA256: "abc",
}}
stor, err := filestorage.NewFileStorageReader(dir)
c.Assert(err, gc.IsNil)
err = tools.ResolveMetadata(stor, nil)
c.Assert(err, gc.IsNil)
// We already have size/sha256, so ensure that storage isn't consulted.
countingStorage := &countingStorage{StorageReader: stor}
metadata := tools.MetadataFromTools(toolsList)
err = tools.ResolveMetadata(countingStorage, metadata)
c.Assert(err, gc.IsNil)
c.Assert(countingStorage.counter, gc.Equals, 0)
// Now clear size/sha256, and check that it is called, and
// the size/sha256 sum are updated.
metadata[0].Size = 0
metadata[0].SHA256 = ""
err = tools.ResolveMetadata(countingStorage, metadata)
c.Assert(err, gc.IsNil)
c.Assert(countingStorage.counter, gc.Equals, 1)
c.Assert(metadata[0].Size, gc.Not(gc.Equals), 0)
c.Assert(metadata[0].SHA256, gc.Not(gc.Equals), "")
}
开发者ID:jameinel,项目名称:core,代码行数:32,代码来源:simplestreams_test.go
示例12: makeTools
func makeTools(c *gc.C, metadataDir, subdir string, versionStrings []string, withCheckSum bool) coretools.List {
toolsDir := filepath.Join(metadataDir, storage.BaseToolsPath)
if subdir != "" {
toolsDir = filepath.Join(toolsDir, subdir)
}
c.Assert(os.MkdirAll(toolsDir, 0755), gc.IsNil)
var toolsList coretools.List
for _, versionString := range versionStrings {
binary := version.MustParseBinary(versionString)
path := filepath.Join(toolsDir, fmt.Sprintf("juju-%s.tgz", binary))
data := binary.String()
err := ioutil.WriteFile(path, []byte(data), 0644)
c.Assert(err, gc.IsNil)
tool := &coretools.Tools{
Version: binary,
URL: path,
}
if withCheckSum {
tool.Size, tool.SHA256 = SHA256sum(c, path)
}
toolsList = append(toolsList, tool)
}
// Write the tools metadata.
stor, err := filestorage.NewFileStorageWriter(metadataDir)
c.Assert(err, gc.IsNil)
err = tools.MergeAndWriteMetadata(stor, toolsList, false)
c.Assert(err, gc.IsNil)
return toolsList
}
开发者ID:jameinel,项目名称:core,代码行数:29,代码来源:testing.go
示例13: newSimpleTools
func newSimpleTools(vers string) *tools.Tools {
return &tools.Tools{
URL: "http://foo.com/tools/releases/juju" + vers + ".tgz",
Version: version.MustParseBinary(vers),
Size: 10,
SHA256: "1234",
}
}
开发者ID:jameinel,项目名称:core,代码行数:8,代码来源:cloudinit_test.go
示例14: newTools
func newTools(vers, url string) *tools.Tools {
return &tools.Tools{
Version: version.MustParseBinary(vers),
URL: url,
Size: 10,
SHA256: "1234",
}
}
开发者ID:jameinel,项目名称:core,代码行数:8,代码来源:marshal_test.go
示例15: TestChangeAgentTools
func (t *ToolsSuite) TestChangeAgentTools(c *gc.C) {
files := []*testing.TarFile{
testing.NewTarFile("jujuc", 0755, "juju executable"),
testing.NewTarFile("jujud", 0755, "jujuc executable"),
}
data, checksum := testing.TarGz(files...)
testTools := &coretest.Tools{
URL: "http://foo/bar1",
Version: version.MustParseBinary("1.2.3-foo-bar"),
Size: int64(len(data)),
SHA256: checksum,
}
err := agenttools.UnpackTools(t.dataDir, testTools, bytes.NewReader(data))
c.Assert(err, gc.IsNil)
gotTools, err := agenttools.ChangeAgentTools(t.dataDir, "testagent", testTools.Version)
c.Assert(err, gc.IsNil)
c.Assert(*gotTools, gc.Equals, *testTools)
assertDirNames(c, t.toolsDir(), []string{"1.2.3-foo-bar", "testagent"})
assertDirNames(c, agenttools.ToolsDir(t.dataDir, "testagent"), []string{"jujuc", "jujud", toolsFile})
// Upgrade again to check that the link replacement logic works ok.
files2 := []*testing.TarFile{
testing.NewTarFile("foo", 0755, "foo content"),
testing.NewTarFile("bar", 0755, "bar content"),
}
data2, checksum2 := testing.TarGz(files2...)
tools2 := &coretest.Tools{
URL: "http://foo/bar2",
Version: version.MustParseBinary("1.2.4-foo-bar"),
Size: int64(len(data2)),
SHA256: checksum2,
}
err = agenttools.UnpackTools(t.dataDir, tools2, bytes.NewReader(data2))
c.Assert(err, gc.IsNil)
gotTools, err = agenttools.ChangeAgentTools(t.dataDir, "testagent", tools2.Version)
c.Assert(err, gc.IsNil)
c.Assert(*gotTools, gc.Equals, *tools2)
assertDirNames(c, t.toolsDir(), []string{"1.2.3-foo-bar", "1.2.4-foo-bar", "testagent"})
assertDirNames(c, agenttools.ToolsDir(t.dataDir, "testagent"), []string{"foo", "bar", toolsFile})
}
开发者ID:jameinel,项目名称:core,代码行数:44,代码来源:tools_test.go
示例16: TestReadList
func (s *StorageSuite) TestReadList(c *gc.C) {
store := s.env.Storage()
v001 := version.MustParseBinary("0.0.1-precise-amd64")
v100 := version.MustParseBinary("1.0.0-precise-amd64")
v101 := version.MustParseBinary("1.0.1-precise-amd64")
v111 := version.MustParseBinary("1.1.1-precise-amd64")
agentTools := envtesting.AssertUploadFakeToolsVersions(c, store, v001, v100, v101, v111)
t001 := agentTools[0]
t100 := agentTools[1]
t101 := agentTools[2]
t111 := agentTools[3]
for i, t := range []struct {
majorVersion,
minorVersion int
list coretools.List
}{{
0, 0, coretools.List{t001},
}, {
1, 0, coretools.List{t100, t101},
}, {
1, 1, coretools.List{t111},
}, {
1, -1, coretools.List{t100, t101, t111},
}, {
1, 2, nil,
}, {
2, 0, nil,
}} {
c.Logf("test %d", i)
list, err := envtools.ReadList(store, t.majorVersion, t.minorVersion)
if t.list != nil {
c.Assert(err, gc.IsNil)
// ReadList doesn't set the Size of SHA256, so blank out those attributes.
for _, tool := range t.list {
tool.Size = 0
tool.SHA256 = ""
}
c.Assert(list, gc.DeepEquals, t.list)
} else {
c.Assert(err, gc.Equals, coretools.ErrNoMatches)
}
}
}
开发者ID:jameinel,项目名称:core,代码行数:44,代码来源:storage_test.go
示例17: TestWatchAPIVersion
func (s *unitUpgraderSuite) TestWatchAPIVersion(c *gc.C) {
w, err := s.st.WatchAPIVersion(s.rawUnit.Tag())
c.Assert(err, gc.IsNil)
defer statetesting.AssertStop(c, w)
wc := statetesting.NewNotifyWatcherC(c, s.BackingState, w)
// Initial event
wc.AssertOneChange()
vers := version.MustParseBinary("10.20.34-quantal-amd64")
err = s.rawMachine.SetAgentVersion(vers)
c.Assert(err, gc.IsNil)
// One change noticing the new version
wc.AssertOneChange()
vers = version.MustParseBinary("10.20.35-quantal-amd64")
err = s.rawMachine.SetAgentVersion(vers)
c.Assert(err, gc.IsNil)
wc.AssertOneChange()
statetesting.AssertStop(c, w)
wc.AssertClosed()
}
开发者ID:jameinel,项目名称:core,代码行数:19,代码来源:unitupgrader_test.go
示例18: TestUpgraderRefusesToDowngradeMinorVersions
func (s *UpgraderSuite) TestUpgraderRefusesToDowngradeMinorVersions(c *gc.C) {
stor := s.Conn.Environ.Storage()
origTools := envtesting.PrimeTools(c, stor, s.DataDir(), version.MustParseBinary("5.4.3-precise-amd64"))
s.PatchValue(&version.Current, origTools.Version)
downgradeTools := envtesting.AssertUploadFakeToolsVersions(
c, stor, version.MustParseBinary("5.3.3-precise-amd64"))[0]
err := statetesting.SetAgentVersion(s.State, downgradeTools.Version.Number)
c.Assert(err, gc.IsNil)
u := s.makeUpgrader()
err = u.Stop()
// If the upgrade would have triggered, we would have gotten an
// UpgradeReadyError, since it was skipped, we get no error
c.Check(err, gc.IsNil)
_, err = agenttools.ReadTools(s.DataDir(), downgradeTools.Version)
// TODO: ReadTools *should* be returning some form of errors.NotFound,
// however, it just passes back a fmt.Errorf so we live with it
// c.Assert(err, jc.Satisfies, errors.IsNotFound)
c.Check(err, gc.ErrorMatches, "cannot read tools metadata in tools directory.*no such file or directory")
}
开发者ID:jameinel,项目名称:core,代码行数:20,代码来源:upgrader_test.go
示例19: TestWriteMetadataNoFetch
func (s *simplestreamsSuite) TestWriteMetadataNoFetch(c *gc.C) {
toolsList := coretools.List{
{
Version: version.MustParseBinary("1.2.3-precise-amd64"),
Size: 123,
SHA256: "abcd",
}, {
Version: version.MustParseBinary("2.0.1-raring-amd64"),
Size: 456,
SHA256: "xyz",
},
}
dir := c.MkDir()
writer, err := filestorage.NewFileStorageWriter(dir)
c.Assert(err, gc.IsNil)
err = tools.MergeAndWriteMetadata(writer, toolsList, tools.DoNotWriteMirrors)
c.Assert(err, gc.IsNil)
metadata := ttesting.ParseMetadataFromDir(c, dir, false)
assertMetadataMatches(c, dir, toolsList, metadata)
}
开发者ID:jameinel,项目名称:core,代码行数:20,代码来源:simplestreams_test.go
示例20: TestChangeAgentTools
func (s *UpgraderSuite) TestChangeAgentTools(c *gc.C) {
oldTools := &coretools.Tools{
Version: version.MustParseBinary("1.2.3-quantal-amd64"),
}
stor := s.Conn.Environ.Storage()
newTools := envtesting.PrimeTools(c, stor, s.DataDir(), version.MustParseBinary("5.4.3-precise-amd64"))
s.PatchValue(&version.Current, newTools.Version)
err := envtools.MergeAndWriteMetadata(stor, coretools.List{newTools}, envtools.DoNotWriteMirrors)
c.Assert(err, gc.IsNil)
ugErr := &upgrader.UpgradeReadyError{
AgentName: "anAgent",
OldTools: oldTools.Version,
NewTools: newTools.Version,
DataDir: s.DataDir(),
}
err = ugErr.ChangeAgentTools()
c.Assert(err, gc.IsNil)
link, err := os.Readlink(agenttools.ToolsDir(s.DataDir(), "anAgent"))
c.Assert(err, gc.IsNil)
c.Assert(link, gc.Equals, newTools.Version.String())
}
开发者ID:jameinel,项目名称:core,代码行数:21,代码来源:upgrader_test.go
注:本文中的github.com/wallyworld/core/version.MustParseBinary函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论