Add tests for log level setting
@@ -236,6 +236,7 @@ var _ = Describe("Heartbeater", func() {
})
Context("when the ATC responds to registration requests", func() {
+ Context("When the DEBUG log level is set", func() {
BeforeEach(func() {
fakeATC1.AppendHandlers(verifyRegister)
fakeATC2.AppendHandlers(verifyHeartbeat)
@@ -255,6 +256,38 @@ var _ = Describe("Heartbeater", func() {
expectedWorker.ActiveVolumes = 2
Eventually(heartbeats).Should(Receive(Equal(registration{expectedWorker, 2 * interval})))
})
+
+ It("logs debug messages", func() {
+ Expect(clientWriter).Should(gbytes.Say("test.register.start"))
+ Expect(clientWriter).Should(gbytes.Say("test.register.reached-worker"))
+ Expect(clientWriter).Should(gbytes.Say("test.register.done"))
+
+ fakeClock.WaitForWatcherAndIncrement(interval)
+ Eventually(clientWriter).Should(gbytes.Say("test.heartbeat.start"))
+ Eventually(clientWriter).Should(gbytes.Say("test.heartbeat.reached-worker"))
+ Eventually(clientWriter).Should(gbytes.Say("test.heartbeat.done"))
+ })
+ })
+
+ Context("When the ERROR log level is set", func() {
+ BeforeEach(func() {
+ fakeATC1.AppendHandlers(verifyRegister)
+ fakeATC2.AppendHandlers(verifyHeartbeat)
+ logLevel = lager.ERROR
+ })
+
+ It("does not log messages", func() {
+ Expect(clientWriter).ShouldNot(gbytes.Say("test.register.start"))
+ Expect(clientWriter).ShouldNot(gbytes.Say("test.register.reached-worker"))
+ Expect(clientWriter).ShouldNot(gbytes.Say("test.register.done"))
+
+ fakeClock.WaitForWatcherAndIncrement(interval)
+ Eventually(clientWriter).ShouldNot(gbytes.Say("test.heartbeat.start"))
+ Eventually(clientWriter).ShouldNot(gbytes.Say("test.heartbeat.reached-worker"))
+ Eventually(clientWriter).ShouldNot(gbytes.Say("test.heartbeat.done"))
+ })
+ })
+
})
Context("when heartbeat returns worker is landed", func() {
