aboutsummaryrefslogtreecommitdiffstats
path: root/cps-application/src/test/groovy
diff options
context:
space:
mode:
authoremaclee <lee.anjella.macabuhay@est.tech>2024-12-11 14:58:25 +0000
committerLee Anjella Macabuhay <lee.anjella.macabuhay@est.tech>2025-01-07 12:02:29 +0000
commit0d61c432b2604f0459dea95bbd328c279b04fbef (patch)
tree3cd35b93ed02048699006082ad1086c986c0990f /cps-application/src/test/groovy
parentffac9f27f7183d8e80aa74a7b113f68dcadb3f87 (diff)
Add gauge metric for NCMP "cmhandle states"
Issue-ID: CPS-2456 Change-Id: I1aebcc68dfdc9c48c230c74376742d67b05c0615 Signed-off-by: emaclee <lee.anjella.macabuhay@est.tech>
Diffstat (limited to 'cps-application/src/test/groovy')
-rw-r--r--cps-application/src/test/groovy/org/onap/cps/config/MicroMeterConfigSpec.groovy28
1 files changed, 24 insertions, 4 deletions
diff --git a/cps-application/src/test/groovy/org/onap/cps/config/MicroMeterConfigSpec.groovy b/cps-application/src/test/groovy/org/onap/cps/config/MicroMeterConfigSpec.groovy
index 61bc2cf027..67ca64624a 100644
--- a/cps-application/src/test/groovy/org/onap/cps/config/MicroMeterConfigSpec.groovy
+++ b/cps-application/src/test/groovy/org/onap/cps/config/MicroMeterConfigSpec.groovy
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2023 Nordix Foundation.
+ * Copyright (C) 2023-2025 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,16 +20,36 @@
package org.onap.cps.config
+import com.hazelcast.map.IMap
import io.micrometer.core.instrument.simple.SimpleMeterRegistry
import spock.lang.Specification
class MicroMeterConfigSpec extends Specification {
- def objectUnderTest = new MicroMeterConfig()
+ def cmHandlesByState = Mock(IMap)
+ def objectUnderTest = new MicroMeterConfig(cmHandlesByState)
+ def simpleMeterRegistry = new SimpleMeterRegistry()
- def 'Creating a tined aspect.'() {
+ def 'Creating a timed aspect.'() {
expect: ' a timed aspect can be created'
- assert objectUnderTest.timedAspect(new SimpleMeterRegistry()) != null
+ assert objectUnderTest.timedAspect(simpleMeterRegistry) != null
+ }
+
+ def 'Creating gauges for cm handle states.'() {
+ given: 'cache returns value for each state'
+ cmHandlesByState.get(_) >> 1
+ when: 'gauges for each state are created'
+ objectUnderTest.advisedCmHandles(simpleMeterRegistry)
+ objectUnderTest.readyCmHandles(simpleMeterRegistry)
+ objectUnderTest.lockedCmHandles(simpleMeterRegistry)
+ objectUnderTest.deletingCmHandles(simpleMeterRegistry)
+ objectUnderTest.deletedCmHandles(simpleMeterRegistry)
+ then: 'each state has the correct value when queried'
+ def states = ["ADVISED", "READY", "LOCKED", "DELETING", "DELETED"]
+ states.each { state ->
+ def gaugeValue = simpleMeterRegistry.get("cmHandlesByState").tag("state",state).gauge().value()
+ assert gaugeValue == 1
+ }
}
}