예제 #1
0
				}).Should(HaveLen(1))

				sinkManager.UnregisterSink(dumpSink)

				Eventually(func() []*events.Envelope {
					return sinkManager.RecentLogsFor("appId")
				}).Should(HaveLen(0))
			})
		})

		Context("with a SyslogSink", func() {
			var syslogSink sinks.Sink

			BeforeEach(func() {
				url := &url.URL{Scheme: "syslog", Host: "localhost:9998"}
				writer, _ := syslogwriter.NewSyslogWriter(url, "appId", &net.Dialer{Timeout: 500 * time.Millisecond}, 0)
				syslogSink = syslog.NewSyslogSink("appId", url, loggertesthelper.Logger(), 100, writer, func(string, string) {}, "dropsonde-origin")

				sinkManager.RegisterSink(syslogSink)
			})

			It("removes the sink", func() {
				Expect(fakeMetricSender.GetValue("messageRouter.numberOfSyslogSinks").Value).To(Equal(float64(1)))

				sinkManager.UnregisterSink(syslogSink)

				Expect(fakeMetricSender.GetValue("messageRouter.numberOfSyslogSinks").Value).To(Equal(float64(0)))
			})
		})

		Context("when called twice", func() {
예제 #2
0
				sinkManager.UnregisterSink(dumpSink)

				Eventually(func() []*events.Envelope {
					return sinkManager.RecentLogsFor("appId")
				}).Should(HaveLen(0))
			})
		})

		Context("with a SyslogSink", func() {
			var syslogSink sinks.Sink

			BeforeEach(func() {
				url, err := url.Parse("syslog://localhost:9998")
				Expect(err).To(BeNil())
				writer, _ := syslogwriter.NewSyslogWriter(url, "appId")
				syslogSink = syslog.NewSyslogSink("appId", "localhost:9999", loggertesthelper.Logger(), 100, writer, func(string, string, string) {}, "dropsonde-origin")

				sinkManager.RegisterSink(syslogSink)
			})

			It("removes the sink", func() {
				Expect(fakeMetricSender.GetValue("messageRouter.numberOfSyslogSinks").Value).To(Equal(float64(1)))

				sinkManager.UnregisterSink(syslogSink)

				Expect(fakeMetricSender.GetValue("messageRouter.numberOfSyslogSinks").Value).To(Equal(float64(0)))
			})
		})

		Context("when called twice", func() {
예제 #3
0
	var sysLogWriter syslogwriter.Writer
	var dialer *net.Dialer
	var syslogServerSession *gexec.Session

	BeforeEach(func() {
		dialer = &net.Dialer{
			Timeout: 500 * time.Millisecond,
		}

		port := 9800 + config.GinkgoConfig.ParallelNode
		address := net.JoinHostPort("127.0.0.1", strconv.Itoa(port))

		outputURL := &url.URL{Scheme: "syslog", Host: address}
		syslogServerSession = startSyslogServer(address)
		sysLogWriter, _ = syslogwriter.NewSyslogWriter(outputURL, "appId", dialer, 0)

		Eventually(func() error {
			err := sysLogWriter.Connect()
			return err
		}, 5, 1).ShouldNot(HaveOccurred())
	}, 10)

	AfterEach(func() {
		sysLogWriter.Close()
		syslogServerSession.Kill().Wait()
	})

	Context("Message Format", func() {
		It("sends messages in the proper format", func() {
			sysLogWriter.Write(standardOutPriority, []byte("just a test"), "App", "2", time.Now().UnixNano())
예제 #4
0
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/gbytes"
	"github.com/onsi/gomega/gexec"
)

var _ = Describe("SyslogWriter", func() {

	var sysLogWriter syslogwriter.Writer
	standardOutPriority := 14

	var syslogServerSession *gexec.Session
	BeforeEach(func(done Done) {
		outputURL, _ := url.Parse("syslog://127.0.0.1:9999")
		syslogServerSession = startSyslogServer("127.0.0.1:9999")
		sysLogWriter, _ = syslogwriter.NewSyslogWriter(outputURL, "appId")

		Eventually(func() error {
			err := sysLogWriter.Connect()
			return err
		}, 5, 1).ShouldNot(HaveOccurred())

		close(done)
	}, 10)

	AfterEach(func() {
		sysLogWriter.Close()
		syslogServerSession.Kill().Wait()
	})

	Context("Message Format", func() {