예제 #1
0
func TestDeaagent(t *testing.T) {
	RegisterFailHandler(Fail)

	BeforeSuite(func() {
		fakeLogSender = fake.NewFakeLogSender()
		logs.Initialize(fakeLogSender)
	})

	RunSpecs(t, "Deaagent Suite")
}
)

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

	var (
		logger lager.Logger
	)
	Context("with a dropsonde source instance", func() {

		BeforeEach(func() {
			logger = lagertest.NewTestLogger("test")

		})
		It("logs to dropsonde", func() {

			fakeLogSender := fake.NewFakeLogSender()
			logs.Initialize(fakeLogSender)
			accessLogger := NewFileAndLoggregatorAccessLogger(logger, "42")
			go accessLogger.Run()

			accessLogger.Log(*CreateAccessLogRecord())

			Eventually(fakeLogSender.GetLogs).Should(HaveLen(1))
			Expect(fakeLogSender.GetLogs()[0].AppId).To(Equal("my_awesome_id"))
			Expect(fakeLogSender.GetLogs()[0].Message).To(MatchRegexp("^.*foo.bar.*\n"))
			Expect(fakeLogSender.GetLogs()[0].SourceType).To(Equal("RTR"))
			Expect(fakeLogSender.GetLogs()[0].SourceInstance).To(Equal("42"))
			Expect(fakeLogSender.GetLogs()[0].MessageType).To(Equal("OUT"))

			accessLogger.Stop()
		})
예제 #3
0
package logs_test

import (
	"github.com/cloudfoundry/dropsonde/log_sender/fake"
	"github.com/cloudfoundry/dropsonde/logs"

	"errors"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Logs", func() {
	var fakeLogSender *fake.FakeLogSender

	BeforeEach(func() {
		fakeLogSender = fake.NewFakeLogSender()
		logs.Initialize(fakeLogSender)
	})

	It("delegates SendAppLog", func() {
		logs.SendAppLog("app-id", "custom-log-message", "App", "0")

		Expect(fakeLogSender.GetLogs()).To(HaveLen(1))
		Expect(fakeLogSender.GetLogs()[0]).To(Equal(fake.Log{AppId: "app-id", Message: "custom-log-message", SourceType: "App", SourceInstance: "0", MessageType: "OUT"}))
	})

	It("delegates SendAppErrorLog", func() {
		logs.SendAppErrorLog("app-id", "custom-log-error-message", "App", "0")

		Expect(fakeLogSender.GetLogs()).To(HaveLen(1))
		Expect(fakeLogSender.GetLogs()[0]).To(Equal(fake.Log{AppId: "app-id", Message: "custom-log-error-message", SourceType: "App", SourceInstance: "0", MessageType: "ERR"}))
예제 #4
0
			daemonGlobalRequestHandlers map[string]handlers.GlobalRequestHandler
			daemonNewChannelHandlers    map[string]handlers.NewChannelHandler
			sshDaemon                   *daemon.Daemon

			proxyListener net.Listener
			sshdListener  net.Listener

			proxyAddress  string
			daemonAddress string

			proxyServer *server.Server
			sshdServer  *server.Server
		)

		BeforeEach(func() {
			fakeLogSender = fake_logs.NewFakeLogSender()
			logs.Initialize(fakeLogSender)

			proxyAuthenticator = &fake_authenticators.FakePasswordAuthenticator{}

			proxySSHConfig = &ssh.ServerConfig{}
			proxySSHConfig.PasswordCallback = proxyAuthenticator.Authenticate
			proxySSHConfig.AddHostKey(TestHostKey)

			daemonAuthenticator = &fake_authenticators.FakePasswordAuthenticator{}
			daemonAuthenticator.AuthenticateReturns(&ssh.Permissions{}, nil)

			daemonSSHConfig = &ssh.ServerConfig{}
			daemonSSHConfig.PasswordCallback = daemonAuthenticator.Authenticate
			daemonSSHConfig.AddHostKey(TestHostKey)
			daemonGlobalRequestHandlers = map[string]handlers.GlobalRequestHandler{}