From d55f5c0c3df4b2ea136100e61424810ede749778 Mon Sep 17 00:00:00 2001 From: Piotr Jaszczyk Date: Fri, 14 Dec 2018 12:05:47 +0100 Subject: Metric: Processing time Add processing time metric measured as difference between "sent to DMaaP" and "WTP decoded" events. Change-Id: I73bb665145019fcca5ae36e2199ed0e1cc088fdf Issue-ID: DCAEGEN2-1036 Signed-off-by: Piotr Jaszczyk --- .../dcae/collectors/veshv/tests/utils/vesEvents.kt | 37 ++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'sources/hv-collector-test-utils/src/main/kotlin') diff --git a/sources/hv-collector-test-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/tests/utils/vesEvents.kt b/sources/hv-collector-test-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/tests/utils/vesEvents.kt index cf30d2ce..a8456890 100644 --- a/sources/hv-collector-test-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/tests/utils/vesEvents.kt +++ b/sources/hv-collector-test-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/tests/utils/vesEvents.kt @@ -23,8 +23,10 @@ package org.onap.dcae.collectors.veshv.tests.utils import com.google.protobuf.ByteString import com.google.protobuf.MessageLite import org.onap.dcae.collectors.veshv.domain.ByteData +import org.onap.dcae.collectors.veshv.domain.PayloadContentType import org.onap.dcae.collectors.veshv.domain.VesEventDomain import org.onap.dcae.collectors.veshv.domain.VesEventDomain.PERF3GPP +import org.onap.dcae.collectors.veshv.domain.WireFrameMessage import org.onap.ves.VesEventOuterClass import org.onap.ves.VesEventOuterClass.CommonEventHeader import org.onap.ves.VesEventOuterClass.CommonEventHeader.Priority @@ -72,7 +74,38 @@ fun commonHeader(domain: VesEventDomain = PERF3GPP, .setVesEventListenerVersion(vesEventListenerVersion) .build() -fun vesEventBytes(commonHeader: CommonEventHeader, byteString: ByteString = ByteString.EMPTY): ByteData = - vesEvent(commonHeader, byteString).toByteData() +fun emptyWireProtocolFrame(): WireFrameMessage = wireProtocolFrameWithPayloadSize(0) + + +fun wireProtocolFrameWithPayloadSize(size: Int): WireFrameMessage = WireFrameMessage( + payload = ByteData(ByteArray(size)), + versionMajor = WireFrameMessage.SUPPORTED_VERSION_MAJOR, + versionMinor = WireFrameMessage.SUPPORTED_VERSION_MINOR, + payloadSize = size, + payloadType = PayloadContentType.GOOGLE_PROTOCOL_BUFFER.hexValue +) + +fun wireProtocolFrame(commonHeader: CommonEventHeader, eventFields: ByteString = ByteString.EMPTY): WireFrameMessage = + vesEventBytes(commonHeader, eventFields).let { payload -> + WireFrameMessage( + payload = payload, + versionMajor = WireFrameMessage.SUPPORTED_VERSION_MAJOR, + versionMinor = WireFrameMessage.SUPPORTED_VERSION_MINOR, + payloadSize = payload.size(), + payloadType = PayloadContentType.GOOGLE_PROTOCOL_BUFFER.hexValue + ) + } + +fun wireProtocolFrame(evt: VesEventOuterClass.VesEvent) = + WireFrameMessage( + payload = ByteData(evt.toByteArray()), + payloadSize = evt.serializedSize, + payloadType = PayloadContentType.GOOGLE_PROTOCOL_BUFFER.hexValue, + versionMajor = WireFrameMessage.SUPPORTED_VERSION_MAJOR, + versionMinor = WireFrameMessage.SUPPORTED_VERSION_MINOR + ) + +fun vesEventBytes(commonHeader: CommonEventHeader, eventFields: ByteString = ByteString.EMPTY): ByteData = + vesEvent(commonHeader, eventFields).toByteData() fun MessageLite.toByteData(): ByteData = ByteData(toByteArray()) \ No newline at end of file -- cgit 1.2.3-korg