summaryrefslogtreecommitdiffstats
path: root/sources/hv-collector-ct/src
diff options
context:
space:
mode:
authorFilip Krzywka <filip.krzywka@nokia.com>2018-12-17 14:25:56 +0100
committerFilip Krzywka <filip.krzywka@nokia.com>2018-12-18 09:15:59 +0100
commit8c180a2101f54d7cc0e3527c2bbe23390eea9cef (patch)
treefe6558ebd50df30f65094ac046d77725e50da361 /sources/hv-collector-ct/src
parentd55f5c0c3df4b2ea136100e61424810ede749778 (diff)
Add metric for rejected clients count
- renamed few counters to be more verbose about what they count - removed not needed 'total' suffix in metrics name Change-Id: I6be0201e5f39f1298706c536b12410413d49df19 Issue-ID: DCAEGEN2-1043 Signed-off-by: Filip Krzywka <filip.krzywka@nokia.com>
Diffstat (limited to 'sources/hv-collector-ct/src')
-rw-r--r--sources/hv-collector-ct/src/test/kotlin/org/onap/dcae/collectors/veshv/tests/component/MetricsSpecification.kt34
-rw-r--r--sources/hv-collector-ct/src/test/kotlin/org/onap/dcae/collectors/veshv/tests/fakes/metrics.kt18
2 files changed, 45 insertions, 7 deletions
diff --git a/sources/hv-collector-ct/src/test/kotlin/org/onap/dcae/collectors/veshv/tests/component/MetricsSpecification.kt b/sources/hv-collector-ct/src/test/kotlin/org/onap/dcae/collectors/veshv/tests/component/MetricsSpecification.kt
index 9f5c37e1..572cc796 100644
--- a/sources/hv-collector-ct/src/test/kotlin/org/onap/dcae/collectors/veshv/tests/component/MetricsSpecification.kt
+++ b/sources/hv-collector-ct/src/test/kotlin/org/onap/dcae/collectors/veshv/tests/component/MetricsSpecification.kt
@@ -23,18 +23,23 @@ import com.google.protobuf.ByteString
import org.assertj.core.api.Assertions.assertThat
import org.jetbrains.spek.api.Spek
import org.jetbrains.spek.api.dsl.describe
+import org.jetbrains.spek.api.dsl.given
import org.jetbrains.spek.api.dsl.it
+import org.jetbrains.spek.api.dsl.on
import org.onap.dcae.collectors.veshv.domain.VesEventDomain
import org.onap.dcae.collectors.veshv.domain.VesEventDomain.HEARTBEAT
import org.onap.dcae.collectors.veshv.domain.VesEventDomain.PERF3GPP
+import org.onap.dcae.collectors.veshv.model.ClientRejectionCause
import org.onap.dcae.collectors.veshv.model.MessageDropCause.INVALID_MESSAGE
import org.onap.dcae.collectors.veshv.model.MessageDropCause.ROUTE_NOT_FOUND
import org.onap.dcae.collectors.veshv.tests.fakes.MEASUREMENTS_FOR_VF_SCALING_TOPIC
import org.onap.dcae.collectors.veshv.tests.fakes.PERF3GPP_TOPIC
import org.onap.dcae.collectors.veshv.tests.fakes.basicConfiguration
import org.onap.dcae.collectors.veshv.tests.fakes.twoDomainsToOneTopicConfiguration
+import org.onap.dcae.collectors.veshv.tests.utils.garbageFrame
import org.onap.dcae.collectors.veshv.tests.utils.messageWithInvalidListenerVersion
import org.onap.dcae.collectors.veshv.tests.utils.messageWithInvalidWireFrameHeader
+import org.onap.dcae.collectors.veshv.tests.utils.messageWithPayloadOfSize
import org.onap.dcae.collectors.veshv.tests.utils.vesEvent
import org.onap.dcae.collectors.veshv.tests.utils.vesWireFrameMessage
import org.onap.dcae.collectors.veshv.tests.utils.wireFrameMessageWithInvalidPayload
@@ -153,7 +158,7 @@ object MetricsSpecification : Spek({
.isEqualTo(1)
}
- it("should gather summed metrics for dropped messages"){
+ it("should gather summed metrics for dropped messages") {
val sut = vesHvWithNoOpSink(basicConfiguration)
sut.handleConnection(
@@ -168,4 +173,31 @@ object MetricsSpecification : Spek({
.isEqualTo(2)
}
}
+
+ describe("clients rejected metrics") {
+
+ given("rejection causes") {
+ mapOf(
+ ClientRejectionCause.PAYLOAD_SIZE_EXCEEDED_IN_MESSAGE to
+ messageWithPayloadOfSize(Sut.MAX_PAYLOAD_SIZE_BYTES + 1),
+ ClientRejectionCause.INVALID_WIRE_FRAME_MARKER to garbageFrame()
+ ).forEach { cause, vesMessage ->
+ on("cause $cause") {
+ it("should notify correct metrics") {
+ val sut = vesHvWithNoOpSink()
+
+ sut.handleConnection(vesMessage)
+
+ val metrics = sut.metrics
+ assertThat(metrics.clientRejectionCause.size)
+ .describedAs("metrics were notified with only one rejection cause")
+ .isOne()
+ assertThat(metrics.clientRejectionCause.get(cause))
+ .describedAs("metrics were notified only once with correct client rejection cause")
+ .isOne()
+ }
+ }
+ }
+ }
+ }
})
diff --git a/sources/hv-collector-ct/src/test/kotlin/org/onap/dcae/collectors/veshv/tests/fakes/metrics.kt b/sources/hv-collector-ct/src/test/kotlin/org/onap/dcae/collectors/veshv/tests/fakes/metrics.kt
index 660ce498..a27d167a 100644
--- a/sources/hv-collector-ct/src/test/kotlin/org/onap/dcae/collectors/veshv/tests/fakes/metrics.kt
+++ b/sources/hv-collector-ct/src/test/kotlin/org/onap/dcae/collectors/veshv/tests/fakes/metrics.kt
@@ -25,6 +25,7 @@ import org.onap.dcae.collectors.veshv.model.MessageDropCause
import org.onap.dcae.collectors.veshv.model.RoutedMessage
import java.time.Duration
import java.time.Instant
+import org.onap.dcae.collectors.veshv.model.ClientRejectionCause
import java.util.concurrent.ConcurrentHashMap
import kotlin.test.fail
@@ -33,14 +34,15 @@ import kotlin.test.fail
* @since June 2018
*/
class FakeMetrics : Metrics {
- var bytesReceived: Int = 0
- var messageBytesReceived: Int = 0
- var lastProcessingTimeMicros: Double = -1.0
- var messagesSentCount: Int = 0
- var messagesDroppedCount: Int = 0
- private val messagesSentToTopic: MutableMap<String, Int> = ConcurrentHashMap()
+ var bytesReceived: Int = 0 ; private set
+ var messageBytesReceived: Int = 0 ; private set
+ var messagesDroppedCount: Int = 0 ; private set
+ var lastProcessingTimeMicros: Double = -1.0 ; private set
private val messagesDroppedCause: MutableMap<MessageDropCause, Int> = ConcurrentHashMap()
+ var messagesSentCount: Int = 0 ; private set
+ val messagesSentToTopic: MutableMap<String, Int> = ConcurrentHashMap()
+ var clientRejectionCause = mutableMapOf<ClientRejectionCause, Int>() ; private set
override fun notifyBytesReceived(size: Int) {
bytesReceived += size
@@ -63,6 +65,10 @@ class FakeMetrics : Metrics {
messagesDroppedCause.compute(cause) { k, _ -> messagesDroppedCause[k]?.inc() ?: 1 }
}
+ override fun notifyClientRejected(cause: ClientRejectionCause) {
+ clientRejectionCause.compute(cause) { k, _ -> clientRejectionCause[k]?.inc() ?: 1 }
+ }
+
fun messagesOnTopic(topic: String) =
messagesSentToTopic[topic] ?: fail("No messages were sent to topic $topic")