diff options
author | Remigiusz Janeczek <remigiusz.janeczek@nokia.com> | 2020-04-23 08:02:47 +0200 |
---|---|---|
committer | Remigiusz Janeczek <remigiusz.janeczek@nokia.com> | 2020-04-23 13:17:18 +0200 |
commit | 66254ca1c5df0d7971764799088c8f20c79f4ca7 (patch) | |
tree | 0fe0f7bdedc9b90ebf942b0999c40134e49721b7 /sources/hv-collector-main/src/test | |
parent | 77f5d0a87ae482c222bf2ef61f0b8ff9b3e5ff68 (diff) |
Add metric for total latency without routing
Add metric for time between Producer and HV-VES output without
sending to Kafka
Refactor metrics test
Add new latencies and individual cores usage to Grafana
Issue-ID: DCAEGEN2-1576
Signed-off-by: Remigiusz Janeczek <remigiusz.janeczek@nokia.com>
Change-Id: I6112db76be1c7108c18336b50f9f12d5ce62c24a
Diffstat (limited to 'sources/hv-collector-main/src/test')
-rw-r--r-- | sources/hv-collector-main/src/test/kotlin/org/onap/dcae/collectors/veshv/main/MicrometerMetricsTest.kt | 98 |
1 files changed, 65 insertions, 33 deletions
diff --git a/sources/hv-collector-main/src/test/kotlin/org/onap/dcae/collectors/veshv/main/MicrometerMetricsTest.kt b/sources/hv-collector-main/src/test/kotlin/org/onap/dcae/collectors/veshv/main/MicrometerMetricsTest.kt index efd353ec..dd206d08 100644 --- a/sources/hv-collector-main/src/test/kotlin/org/onap/dcae/collectors/veshv/main/MicrometerMetricsTest.kt +++ b/sources/hv-collector-main/src/test/kotlin/org/onap/dcae/collectors/veshv/main/MicrometerMetricsTest.kt @@ -146,8 +146,66 @@ object MicrometerMetricsTest : Spek({ "$PREFIX.messages.received.payload.bytes" ) } + + on("$PREFIX.messages.to.collector.travel.time") { + val counterName = "$PREFIX.messages.to.collector.travel.time" + val toCollectorTravelTimeMs = 100L + + it("should update timer") { + val now = Instant.now() + val vesMessage = vesMessageReceivedAt(now, sentAt = now.minusMillis(toCollectorTravelTimeMs)) + cut.notifyMessageReceived(vesMessage) + + registry.verifyTimer(counterName) { timer -> + assertThat(timer.mean(TimeUnit.MILLISECONDS)).isEqualTo(toCollectorTravelTimeMs.toDouble()) + } + + verifyCountersAndTimersAreUnchangedBut(counterName) + } + } } + describe("notifyMessageReadyForRouting"){ + on("$PREFIX.messages.processing.time.without.routing") { + val counterName = "$PREFIX.messages.processing.time.without.routing" + val processingTimeMs = 100L + + it("should update timer") { + + cut.notifyMessageReadyForRouting(vesMessageReceivedAt(Instant.now().minusMillis(processingTimeMs))) + + registry.verifyTimer(counterName) { timer -> + assertThat(timer.mean(TimeUnit.MILLISECONDS)).isGreaterThanOrEqualTo(processingTimeMs.toDouble()) + } + verifyCountersAndTimersAreUnchangedBut( + counterName, + "$PREFIX.messages.latency.without.routing" + ) + } + } + + on("$PREFIX.messages.latency.without.routing") { + val counterName = "$PREFIX.messages.latency.without.routing" + val latencyWithoutRoutingMs = 200L + + it("should update timer") { + + val sentAt = Instant.now().minusMillis(latencyWithoutRoutingMs) + + cut.notifyMessageReadyForRouting(vesMessageSentAt(sentAt)) + + registry.verifyTimer(counterName) { timer -> + assertThat(timer.mean(TimeUnit.MILLISECONDS)).isGreaterThanOrEqualTo(latencyWithoutRoutingMs.toDouble()) + } + verifyCountersAndTimersAreUnchangedBut( + counterName, + "$PREFIX.messages.processing.time.without.routing" + ) + } + } + } + + describe("notifyMessageSent") { val topicName1 = "PERF3GPP" val topicName2 = "CALLTRACE" @@ -206,39 +264,6 @@ object MicrometerMetricsTest : Spek({ } } - on("$PREFIX.messages.to.collector.travel.time") { - val counterName = "$PREFIX.messages.to.collector.travel.time" - val toCollectorTravelTimeMs = 100L - - it("should update timer") { - val now = Instant.now() - val vesMessage = vesMessageReceivedAt(now, sentAt = now.minusMillis(toCollectorTravelTimeMs)) - cut.notifyMessageReceived(vesMessage) - - registry.verifyTimer(counterName) { timer -> - assertThat(timer.mean(TimeUnit.MILLISECONDS)).isEqualTo(toCollectorTravelTimeMs.toDouble()) - } - - verifyCountersAndTimersAreUnchangedBut(counterName) - } - } - - on("$PREFIX.messages.processing.time.without.routing") { - val counterName = "$PREFIX.messages.processing.time.without.routing" - val processingTimeMs = 100L - - it("should update timer") { - - cut.notifyMessageReadyForRouting(vesMessageReceivedAt(Instant.now().minusMillis(processingTimeMs))) - - registry.verifyTimer(counterName) { timer -> - assertThat(timer.mean(TimeUnit.MILLISECONDS)).isGreaterThanOrEqualTo(processingTimeMs.toDouble()) - } - - verifyCountersAndTimersAreUnchangedBut(counterName) - } - } - on("$PREFIX.messages.latency") { val counterName = "$PREFIX.messages.latency" val latencyMs = 1666L @@ -398,6 +423,13 @@ object MicrometerMetricsTest : Spek({ } }) +private fun vesMessageSentAt(sentAt: Instant): VesMessage { + val lastEpochMicrosec = sentAt.epochSecond * 1000000 + sentAt.nano / 1000 + val commonHeader = commonHeader(lastEpochMicrosec = lastEpochMicrosec) + return VesMessage(commonHeader, + wireProtocolFrame(commonHeader, ByteString.copyFromUtf8("highvolume measurements"))) +} + private fun vesMessageReceivedAt(receivedAt: Instant, sentAt: Instant): VesMessage { val lastEpochMicrosec = sentAt.epochSecond * 1000000 + sentAt.nano / 1000 val commonHeader = commonHeader(lastEpochMicrosec = lastEpochMicrosec) |