本文整理汇总了Golang中github.com/wallyworld/core/state/api.State.Rsyslog方法的典型用法代码示例。如果您正苦于以下问题:Golang State.Rsyslog方法的具体用法?Golang State.Rsyslog怎么用?Golang State.Rsyslog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/wallyworld/core/state/api.State
的用法示例。
在下文中一共展示了State.Rsyslog方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: testNamespace
// testNamespace starts a worker and ensures that
// the rsyslog config file has the expected filename,
// and the appropriate log dir is used.
func (s *RsyslogSuite) testNamespace(c *gc.C, st *api.State, tag, namespace, expectedFilename, expectedLogDir string) {
restarted := make(chan struct{}, 2) // once for create, once for teardown
s.PatchValue(rsyslog.RestartRsyslog, func() error {
restarted <- struct{}{}
return nil
})
err := os.MkdirAll(expectedLogDir, 0755)
c.Assert(err, gc.IsNil)
err = s.APIState.Client().EnvironmentSet(map[string]interface{}{"rsyslog-ca-cert": coretesting.CACert})
c.Assert(err, gc.IsNil)
worker, err := rsyslog.NewRsyslogConfigWorker(st.Rsyslog(), rsyslog.RsyslogModeForwarding, tag, namespace, []string{"0.1.2.3"})
c.Assert(err, gc.IsNil)
defer func() { c.Assert(worker.Wait(), gc.IsNil) }()
defer worker.Kill()
// Ensure that ca-cert.pem gets written to the expected log dir.
waitForFile(c, filepath.Join(expectedLogDir, "ca-cert.pem"))
// Wait for rsyslog to be restarted, so we can check to see
// what the name of the config file is.
waitForRestart(c, restarted)
dir, err := os.Open(*rsyslog.RsyslogConfDir)
c.Assert(err, gc.IsNil)
names, err := dir.Readdirnames(-1)
dir.Close()
c.Assert(err, gc.IsNil)
c.Assert(names, gc.HasLen, 1)
c.Assert(names[0], gc.Equals, expectedFilename)
}