本文整理汇总了Golang中github.com/juju/juju/provider/dummy.Reset函数的典型用法代码示例。如果您正苦于以下问题:Golang Reset函数的具体用法?Golang Reset怎么用?Golang Reset使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Reset函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: tearDownConn
func (s *JujuConnSuite) tearDownConn(c *gc.C) {
serverAlive := gitjujutesting.MgoServer.Addr() != ""
// Bootstrap will set the admin password, and render non-authorized use
// impossible. s.State may still hold the right password, so try to reset
// the password so that the MgoSuite soft-resetting works. If that fails,
// it will still work, but it will take a while since it has to kill the
// whole database and start over.
if err := s.State.SetAdminMongoPassword(""); err != nil && serverAlive {
c.Logf("cannot reset admin password: %v", err)
}
for _, st := range s.apiStates {
err := st.Close()
if serverAlive {
c.Assert(err, gc.IsNil)
}
}
err := s.Conn.Close()
if serverAlive {
c.Assert(err, gc.IsNil)
}
err = s.APIConn.Close()
if serverAlive {
c.Assert(err, gc.IsNil)
}
dummy.Reset()
s.apiStates = nil
s.Conn = nil
s.State = nil
utils.SetHome(s.oldHome)
osenv.SetJujuHome(s.oldJujuHome)
s.oldHome = ""
s.RootDir = ""
}
开发者ID:rogpeppe,项目名称:juju,代码行数:34,代码来源:conn.go
示例2: TestImageMetadataBadArgs
func (s *ImageMetadataSuite) TestImageMetadataBadArgs(c *gc.C) {
for i, t := range errTests {
c.Logf("test: %d", i)
_, err := runImageMetadata(c, s.store, t.args...)
c.Check(err, gc.NotNil, gc.Commentf("test %d: %s", i, t.args))
dummy.Reset(c)
}
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:8,代码来源:imagemetadata_test.go
示例3: resetEnv
func (s *SimpleStreamsToolsSuite) resetEnv(c *gc.C, attrs map[string]interface{}) {
version.Current = s.origCurrentVersion
dummy.Reset()
cfg, err := config.New(config.NoDefaults, dummy.SampleConfig().Merge(attrs))
c.Assert(err, jc.ErrorIsNil)
env, err := environs.Prepare(cfg, envtesting.BootstrapContext(c), configstore.NewMem())
c.Assert(err, jc.ErrorIsNil)
s.env = env
s.removeTools(c)
}
开发者ID:snailwalker,项目名称:juju,代码行数:10,代码来源:tools_test.go
示例4: TestImageMetadataBadArgs
func (s *ImageMetadataSuite) TestImageMetadataBadArgs(c *gc.C) {
testing.MakeSampleJujuHome(c)
s.AddCleanup(func(*gc.C) {
dummy.Reset()
})
for i, t := range errTests {
c.Logf("test: %d", i)
ctx := testing.Context(c)
code := cmd.Main(envcmd.Wrap(&ImageMetadataCommand{}), ctx, t.args)
c.Check(code, gc.Equals, 1)
}
}
开发者ID:Pankov404,项目名称:juju,代码行数:12,代码来源:imagemetadata_test.go
示例5: TestBootstrapTools
func (s *bootstrapSuite) TestBootstrapTools(c *gc.C) {
s.PatchValue(&envtools.BundleTools, toolstesting.GetMockBundleTools(c))
allTests := append(envtesting.BootstrapToolsTests, bootstrapSetAgentVersionTests...)
// version.Current is set in the loop so ensure it is restored later.
s.PatchValue(&version.Current, version.Current)
for i, test := range allTests {
c.Logf("\ntest %d: %s", i, test.Info)
dummy.Reset()
attrs := dummy.SampleConfig().Merge(coretesting.Attrs{
"state-server": false,
"development": test.Development,
"default-series": test.DefaultSeries,
})
if test.AgentVersion != version.Zero {
attrs["agent-version"] = test.AgentVersion.String()
}
cfg, err := config.New(config.NoDefaults, attrs)
c.Assert(err, gc.IsNil)
env, err := environs.Prepare(cfg, coretesting.Context(c), configstore.NewMem())
c.Assert(err, gc.IsNil)
envtesting.RemoveAllTools(c, env)
version.Current = test.CliVersion
envtesting.AssertUploadFakeToolsVersions(c, env.Storage(), test.Available...)
// Remove the default tools URL from the search path, just look in cloud storage.
s.PatchValue(&envtools.DefaultBaseURL, "")
cons := constraints.Value{}
if test.Arch != "" {
cons = constraints.MustParse("arch=" + test.Arch)
}
err = bootstrap.Bootstrap(coretesting.Context(c), env, environs.BootstrapParams{Constraints: cons})
if test.Err != "" {
c.Check(err, gc.NotNil)
if err != nil {
stripped := strings.Replace(err.Error(), "\n", "", -1)
c.Check(stripped, gc.Matches, ".*"+stripped)
}
continue
} else {
c.Check(err, gc.IsNil)
}
unique := map[version.Number]bool{}
for _, expected := range test.Expect {
unique[expected.Number] = true
}
for expectAgentVersion := range unique {
agentVersion, ok := env.Config().AgentVersion()
c.Check(ok, gc.Equals, true)
c.Check(agentVersion, gc.Equals, expectAgentVersion)
}
}
}
开发者ID:klyachin,项目名称:juju,代码行数:53,代码来源:bootstrap_test.go
示例6: resetJujuHome
// resetJujuHome restores an new, clean Juju home environment without tools.
func resetJujuHome(c *gc.C, envName string) environs.Environ {
jenvDir := gitjujutesting.HomePath(".juju", "environments")
err := os.RemoveAll(jenvDir)
c.Assert(err, jc.ErrorIsNil)
coretesting.WriteEnvironments(c, envConfig)
dummy.Reset()
store, err := configstore.Default()
c.Assert(err, jc.ErrorIsNil)
env, err := environs.PrepareFromName(envName, envcmd.BootstrapContext(cmdtesting.NullContext(c)), store)
c.Assert(err, jc.ErrorIsNil)
return env
}
开发者ID:kakamessi99,项目名称:juju,代码行数:13,代码来源:bootstrap_test.go
示例7: resetJujuHome
// resetJujuHome restores an new, clean Juju home environment without tools.
func resetJujuHome(c *gc.C) environs.Environ {
jenvDir := gitjujutesting.HomePath(".juju", "environments")
err := os.RemoveAll(jenvDir)
c.Assert(err, gc.IsNil)
coretesting.WriteEnvironments(c, envConfig)
dummy.Reset()
store, err := configstore.Default()
c.Assert(err, gc.IsNil)
env, err := environs.PrepareFromName("peckham", cmdtesting.NullContext(c), store)
c.Assert(err, gc.IsNil)
envtesting.RemoveAllTools(c, env)
return env
}
开发者ID:zhouqt,项目名称:juju,代码行数:14,代码来源:bootstrap_test.go
示例8: TearDownTest
func (s *ConnSuite) TearDownTest(c *gc.C) {
if s.conn == nil {
return
}
err := s.conn.State.SetAdminMongoPassword("")
c.Assert(err, gc.IsNil)
err = s.conn.Environ.Destroy()
c.Check(err, gc.IsNil)
assertClose(c, s.conn)
s.conn = nil
dummy.Reset()
s.ToolsFixture.TearDownTest(c)
s.MgoSuite.TearDownTest(c)
s.BaseSuite.TearDownTest(c)
}
开发者ID:rogpeppe,项目名称:juju,代码行数:15,代码来源:conn_test.go
示例9: SetUpTest
func (s *ToolsMetadataSuite) SetUpTest(c *gc.C) {
s.FakeJujuHomeSuite.SetUpTest(c)
s.AddCleanup(func(*gc.C) {
dummy.Reset()
loggo.ResetLoggers()
})
env, err := environs.PrepareFromName(
"erewhemos", envcmd.BootstrapContextNoVerify(coretesting.Context(c)), configstore.NewMem())
c.Assert(err, jc.ErrorIsNil)
s.env = env
loggo.GetLogger("").SetLogLevel(loggo.INFO)
// Switch the default tools location.
s.publicStorageDir = c.MkDir()
s.PatchValue(&tools.DefaultBaseURL, s.publicStorageDir)
}
开发者ID:Pankov404,项目名称:juju,代码行数:16,代码来源:toolsmetadata_test.go
示例10: resetEnv
func (s *SimpleStreamsToolsSuite) resetEnv(c *gc.C, attrs map[string]interface{}) {
jujuversion.Current = s.origCurrentVersion
dummy.Reset(c)
attrs = dummy.SampleConfig().Merge(attrs)
env, err := environs.Prepare(envtesting.BootstrapContext(c),
jujuclienttesting.NewMemStore(),
environs.PrepareParams{
ControllerName: attrs["name"].(string),
BaseConfig: attrs,
CloudName: "dummy",
},
)
c.Assert(err, jc.ErrorIsNil)
s.env = env
s.removeTools(c)
}
开发者ID:makyo,项目名称:juju,代码行数:16,代码来源:tools_test.go
示例11: tearDownConn
func (s *JujuConnSuite) tearDownConn(c *gc.C) {
testServer := gitjujutesting.MgoServer.Addr()
serverAlive := testServer != ""
// Bootstrap will set the admin password, and render non-authorized use
// impossible. s.State may still hold the right password, so try to reset
// the password so that the MgoSuite soft-resetting works. If that fails,
// it will still work, but it will take a while since it has to kill the
// whole database and start over.
if s.State != nil {
if err := s.State.SetAdminMongoPassword(""); err != nil && serverAlive {
c.Logf("cannot reset admin password: %v", err)
}
err := s.State.Close()
if serverAlive {
// This happens way too often with failing tests,
// so add some context in case of an error.
c.Check(
err,
gc.IsNil,
gc.Commentf("closing state failed, testing server %q is alive", testServer),
)
}
s.State = nil
}
for _, st := range s.apiStates {
err := st.Close()
if serverAlive {
c.Check(err, gc.IsNil)
}
}
s.apiStates = nil
if s.APIState != nil {
err := s.APIState.Close()
s.APIState = nil
if serverAlive {
c.Check(err, gc.IsNil)
}
}
dummy.Reset()
utils.SetHome(s.oldHome)
osenv.SetJujuHome(s.oldJujuHome)
s.oldHome = ""
s.RootDir = ""
}
开发者ID:kapilt,项目名称:juju,代码行数:45,代码来源:conn.go
示例12: resetEnv
func (s *SimpleStreamsToolsSuite) resetEnv(c *gc.C, attrs map[string]interface{}) {
jujuversion.Current = s.origCurrentVersion
dummy.Reset(c)
attrs = dummy.SampleConfig().Merge(attrs)
env, err := bootstrap.Prepare(envtesting.BootstrapContext(c),
jujuclienttesting.NewMemStore(),
bootstrap.PrepareParams{
ControllerConfig: coretesting.FakeControllerConfig(),
ControllerName: attrs["name"].(string),
ModelConfig: attrs,
Cloud: dummy.SampleCloudSpec(),
AdminSecret: "admin-secret",
},
)
c.Assert(err, jc.ErrorIsNil)
s.env = env
s.removeTools(c)
}
开发者ID:bac,项目名称:juju,代码行数:18,代码来源:tools_test.go
示例13: TestBootstrapAPIReadyRetries
func (s *BootstrapSuite) TestBootstrapAPIReadyRetries(c *gc.C) {
s.PatchValue(&bootstrapReadyPollDelay, 1*time.Millisecond)
s.PatchValue(&bootstrapReadyPollCount, 5)
defaultSeriesVersion := jujuversion.Current
// Force a dev version by having a non zero build number.
// This is because we have not uploaded any tools and auto
// upload is only enabled for dev versions.
defaultSeriesVersion.Build = 1234
s.PatchValue(&jujuversion.Current, defaultSeriesVersion)
for _, t := range []struct {
numRetries int
err error
}{
{0, nil}, // agent ready immediately
{2, nil}, // agent ready after 2 polls
{6, &rpc.RequestError{
Message: params.CodeUpgradeInProgress,
Code: params.CodeUpgradeInProgress,
}}, // agent ready after 6 polls but that's too long
{-1, errOther}, // another error is returned
} {
resetJujuXDGDataHome(c)
dummy.Reset(c)
s.store = jujuclienttesting.NewMemStore()
s.mockBlockClient.numRetries = t.numRetries
s.mockBlockClient.retryCount = 0
_, err := coretesting.RunCommand(
c, s.newBootstrapCommand(),
"devcontroller", "dummy", "--auto-upgrade",
)
c.Check(errors.Cause(err), gc.DeepEquals, t.err)
expectedRetries := t.numRetries
if t.numRetries <= 0 {
expectedRetries = 1
}
// Only retry maximum of bootstrapReadyPollCount times.
if expectedRetries > 5 {
expectedRetries = 5
}
c.Check(s.mockBlockClient.retryCount, gc.Equals, expectedRetries)
}
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:43,代码来源:bootstrap_test.go
示例14: TestAPIEndpointNotCached
func (s *APIEndpointForEnvSuite) TestAPIEndpointNotCached(c *gc.C) {
coretesting.WriteEnvironments(c, coretesting.MultipleEnvConfig)
store, err := configstore.Default()
c.Assert(err, gc.IsNil)
ctx := coretesting.Context(c)
env, err := environs.PrepareFromName("erewhemos", ctx, store)
c.Assert(err, gc.IsNil)
defer dummy.Reset()
envtesting.UploadFakeTools(c, env.Storage())
err = bootstrap.Bootstrap(ctx, env, environs.BootstrapParams{})
c.Assert(err, gc.IsNil)
// Note: if we get Bootstrap to start caching the API endpoint
// immediately, we'll still want to have this test for compatibility.
// We can just write blank info instead of reading and checking it is empty.
savedInfo, err := store.ReadInfo("erewhemos")
c.Assert(err, gc.IsNil)
// Ensure that the data isn't cached
c.Check(savedInfo.APIEndpoint().Addresses, gc.HasLen, 0)
called := 0
expectState := mockedAPIState(true, true)
apiOpen := func(apiInfo *api.Info, opts api.DialOpts) (juju.APIState, error) {
c.Check(apiInfo.Tag, gc.Equals, "user-admin")
c.Check(string(apiInfo.CACert), gc.Equals, coretesting.CACert)
c.Check(apiInfo.Password, gc.Equals, coretesting.DefaultMongoPassword)
c.Check(opts, gc.DeepEquals, api.DefaultDialOpts())
// we didn't know about it when connecting
c.Check(apiInfo.EnvironTag, gc.Equals, "")
called++
return expectState, nil
}
endpoint, err := juju.APIEndpointInStore("erewhemos", false, store, apiOpen)
c.Assert(err, gc.IsNil)
c.Assert(called, gc.Equals, 1)
c.Check(endpoint.Addresses, gc.DeepEquals, []string{"0.1.2.3:1234"})
c.Check(endpoint.EnvironUUID, gc.Equals, "fake-uuid")
}
开发者ID:rogpeppe,项目名称:juju,代码行数:38,代码来源:apiconn_test.go
示例15: tearDownTest
func (s *syncSuite) tearDownTest(c *gc.C) {
dummy.Reset()
version.Current = s.origVersion
s.ToolsFixture.TearDownTest(c)
s.FakeJujuHomeSuite.TearDownTest(c)
}
开发者ID:zhouqt,项目名称:juju,代码行数:6,代码来源:sync_test.go
示例16: TearDownSuite
func (s *BootstrapSuite) TearDownSuite(c *gc.C) {
s.MgoSuite.TearDownSuite(c)
s.BaseSuite.TearDownSuite(c)
dummy.Reset()
}
开发者ID:ktsakalozos,项目名称:juju,代码行数:5,代码来源:bootstrap_test.go
示例17: TearDownTest
func (s *uploadSuite) TearDownTest(c *gc.C) {
dummy.Reset()
s.ToolsFixture.TearDownTest(c)
s.FakeJujuHomeSuite.TearDownTest(c)
}
开发者ID:zhouqt,项目名称:juju,代码行数:5,代码来源:sync_test.go
示例18: TearDownTest
func (s *SimpleStreamsToolsSuite) TearDownTest(c *gc.C) {
dummy.Reset()
version.Current = s.origCurrentVersion
s.ToolsFixture.TearDownTest(c)
s.BaseSuite.TearDownTest(c)
}
开发者ID:snailwalker,项目名称:juju,代码行数:6,代码来源:tools_test.go
示例19: TearDownTest
func (cs *NewAPIClientSuite) TearDownTest(c *gc.C) {
dummy.Reset()
cs.FakeJujuHomeSuite.TearDownTest(c)
}
开发者ID:klyachin,项目名称:juju,代码行数:4,代码来源:api_test.go
示例20: TearDownTest
func (s *URLsSuite) TearDownTest(c *gc.C) {
dummy.Reset()
s.BaseSuite.TearDownTest(c)
}
开发者ID:Pankov404,项目名称:juju,代码行数:5,代码来源:urls_test.go
注:本文中的github.com/juju/juju/provider/dummy.Reset函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论