inputChan <- envelope outputMessage := <-outputChan Expect(outputMessage).To(Equal(message)) }) Context("metrics", func() { It("emits the correct metrics context", func() { Expect(marshaller.Emit().Name).To(Equal("dropsondeMarshaller")) }) It("emits a heartbeat counter", func() { envelope := &events.Envelope{ Origin: proto.String("fake-origin-3"), EventType: events.Envelope_Heartbeat.Enum(), Heartbeat: factories.NewHeartbeat(1, 2, 3), } inputChan <- envelope testhelpers.EventuallyExpectMetric(marshaller, "heartbeatMarshalled", 1) }) It("emits a marshal error counter", func() { envelope := &events.Envelope{} inputChan <- envelope testhelpers.EventuallyExpectMetric(marshaller, "marshalErrors", 1) }) }) })
Expect(writer.Data()).Should(HaveLen(1)) outputMessage := writer.Data()[0] Expect(outputMessage).To(Equal(message)) }) Context("metrics", func() { It("emits the correct metrics context", func() { Expect(marshaller.Emit().Name).To(Equal("eventMarshaller")) }) It("emits a marshal error counter", func() { envelope := &events.Envelope{} marshaller.Write(envelope) testhelpers.EventuallyExpectMetric(marshaller, "marshalErrors", 1) }) It("emits a dropsonde marshal error counter", func() { fakeMetricSender := fake.NewFakeMetricSender() batcher := metricbatcher.New(fakeMetricSender, 1*time.Millisecond) metrics.Initialize(fakeMetricSender, batcher) envelope := &events.Envelope{} marshaller.Write(envelope) Eventually(func() uint64 { return fakeMetricSender.GetCounter("dropsondeMarshaller.marshalErrors") }).Should(BeEquivalentTo(1)) }) }) })
signedMessage := append(signature, message...) inputChan <- signedMessage outputMessage := <-outputChan Expect(outputMessage).To(Equal(message)) }) Context("metrics", func() { It("emits the correct metrics context", func() { Expect(signatureVerifier.Emit().Name).To(Equal("signatureVerifier")) }) It("emits a missing signature error counter", func() { inputChan <- []byte{1, 2, 3} testhelpers.EventuallyExpectMetric(signatureVerifier, "missingSignatureErrors", 1) }) It("emits an invalid signature error counter", func() { inputChan <- make([]byte, 32) testhelpers.EventuallyExpectMetric(signatureVerifier, "invalidSignatureErrors", 1) }) It("emits an valid signature counter", func() { message := []byte{1, 2, 3} mac := hmac.New(sha256.New, []byte("valid-secret")) mac.Write(message) signature := mac.Sum(nil) signedMessage := append(signature, message...) inputChan <- signedMessage
close(runComplete) }() }) AfterEach(func() { close(inputChan) Eventually(runComplete).Should(BeClosed()) }) It("emits the correct metrics context", func() { Expect(unmarshaller.Emit().Name).To(Equal("dropsondeUnmarshaller")) }) It("emits a heartbeat counter", func() { envelope := &events.Envelope{ Origin: proto.String("fake-origin-3"), EventType: events.Envelope_Heartbeat.Enum(), Heartbeat: factories.NewHeartbeat(1, 2, 3), } message, _ := proto.Marshal(envelope) inputChan <- message testhelpers.EventuallyExpectMetric(unmarshaller, "heartbeatReceived", 1) }) It("emits an unmarshal error counter", func() { inputChan <- []byte{1, 2, 3} testhelpers.EventuallyExpectMetric(unmarshaller, "unmarshalErrors", 1) }) }) })
Expect(mockWriter.Events).To(HaveLen(0)) }) }) Context("metrics", func() { BeforeEach(func() { unmarshaller = eventunmarshaller.New(mockWriter, loggertesthelper.Logger()) }) It("emits the correct metrics context", func() { Expect(unmarshaller.Emit().Name).To(Equal("EventUnmarshaller")) }) It("emits a value metric counter", func() { unmarshaller.Write(message) testhelpers.EventuallyExpectMetric(unmarshaller, "valueMetricReceived", 1) Eventually(fakeEventEmitter.GetMessages).Should(HaveLen(1)) Expect(fakeEventEmitter.GetMessages()[0].Event.(*events.CounterEvent)).To(Equal(&events.CounterEvent{ Name: proto.String("EventUnmarshaller.valueMetricReceived"), Delta: proto.Uint64(1), })) }) It("emits a total log message counter", func() { envelope1 := &events.Envelope{ Origin: proto.String("fake-origin-3"), EventType: events.Envelope_LogMessage.Enum(), LogMessage: factories.NewLogMessage(events.LogMessage_OUT, "test log message 1", "fake-app-id-1", "DEA"), }