Beispiel #1
0
func (s *bufferedLogWriterSuite) TestUninstallBufferedLogWriter(c *gc.C) {
	_, err := logsender.InstallBufferedLogWriter(10)
	c.Assert(err, jc.ErrorIsNil)

	err = logsender.UninstallBufferedLogWriter()
	c.Assert(err, jc.ErrorIsNil)

	// Second uninstall attempt should fail
	err = logsender.UninstallBufferedLogWriter()
	c.Assert(err, gc.ErrorMatches, "failed to uninstall log buffering: .+")
}
Beispiel #2
0
func (s *bufferedLogWriterSuite) TestInstallBufferedLogWriter(c *gc.C) {
	logsCh, err := logsender.InstallBufferedLogWriter(10)
	c.Assert(err, jc.ErrorIsNil)
	defer logsender.UninstallBufferedLogWriter()

	logger := loggo.GetLogger("bufferedLogWriter-test")

	for i := 0; i < 5; i++ {
		logger.Infof("%d", i)
	}

	for i := 0; i < 5; i++ {
		select {
		case rec := <-logsCh:
			c.Assert(rec.Message, gc.Equals, strconv.Itoa(i))
		case <-time.After(coretesting.LongWait):
			c.Fatal("timed out waiting for logs")
		}
	}
}
func (s *bufferedLogWriterSuite) TestUninstallBufferedLogWriterNoFeatureFlag(c *gc.C) {
	err := logsender.UninstallBufferedLogWriter()
	// With the feature flag, uninstalling without first installing
	// would result in an error.
	c.Assert(err, jc.ErrorIsNil)
}