예제 #1
0
	})

	Context("with a tcp wrapper", func() {
		BeforeEach(func() {
			protocol = "tcp"
		})

		It("counts the number of bytes sent", func() {
			// subtract a magic number three from the message length to make sure
			// we report the bytes sent by the client, not just the len of the
			// message given to it
			sentLength := len(message) - 3
			client.WriteOutput.sentLength <- sentLength
			client.WriteOutput.err <- nil

			err := wrapper.Write(client, message)
			Expect(err).NotTo(HaveOccurred())

			Eventually(func() uint64 {
				return sender.GetCounter("tcp.sentByteCount")
			}).Should(BeEquivalentTo(sentLength))
		})

		It("counts the number of messages sent", func() {
			client.WriteOutput.sentLength <- len(message)
			client.WriteOutput.err <- nil
			err := wrapper.Write(client, message)
			Expect(err).NotTo(HaveOccurred())

			Eventually(func() uint64 {
				return sender.GetCounter("tcp.sentMessageCount")
예제 #2
0
	})

	Context("with a tcp wrapper", func() {
		BeforeEach(func() {
			protocol = "tcp"
		})

		It("counts the number of bytes sent", func() {
			// subtract a magic number three from the message length to make sure
			// we report the bytes sent by the client, not just the len of the
			// message given to it
			sentLength := len(message) - 3
			client.WriteOutput.SentLength <- sentLength
			client.WriteOutput.Err <- nil

			err := wrapper.Write(client, message)
			Expect(err).NotTo(HaveOccurred())

			Eventually(mockBatcher.BatchAddCounterInput).Should(BeCalled(
				With("tcp.sentByteCount", uint64(sentLength)),
			))
		})

		It("does not count the number of messages sent", func() {
			client.WriteOutput.SentLength <- len(message)
			client.WriteOutput.Err <- nil
			mockChainer := newMockBatchCounterChainer()
			testhelpers.AlwaysReturn(mockChainer.SetTagOutput, mockChainer)

			err := wrapper.Write(client, message, mockChainer)
			Expect(err).NotTo(HaveOccurred())