Esempio n. 1
0
package metrics_test

import (
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"loggregator/sinks/dump"
	"loggregator/sinks/syslog"
	"loggregator/sinks/websocket"

	"loggregator/sinks"
	"loggregator/sinkserver/metrics"
)

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

	var sinkManagerMetrics *metrics.SinkManagerMetrics
	var sink sinks.Sink

	BeforeEach(func() {
		sinkManagerMetrics = metrics.NewSinkManagerMetrics()
	})

	It("Should have metrics for dump sinks", func() {

		Expect(sinkManagerMetrics.Emit().Metrics[0].Name).To(Equal("numberOfDumpSinks"))
		Expect(sinkManagerMetrics.Emit().Metrics[0].Value).To(Equal(0))
		Expect(sinkManagerMetrics.Emit().Metrics[1].Value).To(Equal(0))
		Expect(sinkManagerMetrics.Emit().Metrics[2].Value).To(Equal(0))

		sink = &dump.DumpSink{}
		sinkManagerMetrics.Inc(sink)
Esempio n. 2
0
			sinkManager.RegisterSink(sink)
			sinkManager.Stop()
			Expect(sink.RunFinished()).To(BeTrue())

			close(done)
		})

		It("should close the app store chan when stopped", func() {
			sinkManager.Stop()
			Eventually(appServicesChan).Should(BeClosed())
		})
	})

	Context("With updates from appstore", func() {

		var metrics *metrics.SinkManagerMetrics
		var numSyslogSinks func() int

		BeforeEach(func() {
			metrics = sinkManager.Metrics
			numSyslogSinks = func() int {
				metrics.RLock()
				defer metrics.RUnlock()
				return metrics.SyslogSinks
			}
		})

		Context("When an add update is received", func() {
			It("Should create a new syslog sink from the newAppServicesChan", func() {
				initialNumSinks := numSyslogSinks()
				newAppServiceChan <- domain.AppService{AppId: "aptastic", Url: "https://localhost:884"}