forwarder.Write(envelope)

			Eventually(func() uint64 {
				return sender.GetCounter("udp.sendErrorCount")
			}).Should(BeEquivalentTo(1))
		})

		It("marshals, signs, writes and emits metrics", func() {
			bytes, err := proto.Marshal(envelope)
			Expect(err).NotTo(HaveOccurred())
			bytes = signature.SignMessage(bytes, sharedSecret)

			forwarder.Write(envelope)

			Eventually(client.WriteCallCount).Should(Equal(1))
			Eventually(func() []byte { return client.WriteArgsForCall(0) }).Should(Equal(bytes))
			Eventually(func() uint64 { return sender.GetCounter("DopplerForwarder.sentMessages") }).Should(BeEquivalentTo(1))
			Eventually(func() uint64 { return sender.GetCounter("dropsondeMarshaller.logMessageMarshalled") }).Should(BeEquivalentTo(1))
		})

		Context("when writes fail", func() {
			BeforeEach(func() {
				client.WriteReturns(0, errors.New("boom"))
			})

			It("does not increment message count or sentMessages", func() {
				forwarder.Write(envelope)

				Eventually(func() uint64 { return sender.GetCounter("udp.sentMessageCount") }).Should(BeZero())
				Eventually(func() uint64 { return sender.GetCounter("udp.sentByteCount") }).Should(BeZero())
				Eventually(func() uint64 { return sender.GetCounter("DopplerForwarder.sentMessages") }).Should(BeZero())
예제 #2
0
			forwarder.Write(envelope)

			Eventually(func() uint64 {
				return sender.GetCounter("udp.sendErrorCount")
			}).Should(BeEquivalentTo(1))
		})

		It("marshals, signs, writes and emits metrics", func() {
			bytes, err := proto.Marshal(envelope)
			Expect(err).NotTo(HaveOccurred())
			bytes = signature.SignMessage(bytes, sharedSecret)

			forwarder.Write(envelope)

			Expect(client.WriteArgsForCall(0)).To(Equal(bytes))
			Eventually(func() uint64 { return sender.GetCounter("DopplerForwarder.sentMessages") }).Should(BeEquivalentTo(1))
			Expect(sender.GetCounter("dropsondeMarshaller.logMessageMarshalled")).To(BeEquivalentTo(1))
		})

		Context("when writes fail", func() {
			BeforeEach(func() {
				client.WriteReturns(0, errors.New("boom"))
			})

			It("does not increment message count or sentMessages", func() {
				forwarder.Write(envelope)

				Consistently(func() uint64 { return sender.GetCounter("DopplerForwarder.sentMessages") }).Should(BeZero())
				Expect(sender.GetCounter("dropsondeMarshaller.LogMessageMarshalled")).To(BeZero())
			})