sysmon/plugins/power/src/test/groovy/PowerProcessorTest.groovy

90 lines
2.8 KiB
Groovy
Raw Normal View History

2022-12-21 16:12:15 +00:00
import sysmon.plugins.power.PowerProcessorExtension
import sysmon.plugins.power.PowerProcessorStat
import spock.lang.Specification
2022-12-21 16:12:15 +00:00
class PowerProcessorTest extends Specification {
2021-06-08 18:24:43 +00:00
void "test AIX lparstat shared output processing"() {
setup:
InputStream inputStream = getClass().getResourceAsStream('/lparstat-aix-shared.txt')
when:
2022-12-21 16:12:15 +00:00
PowerProcessorExtension extension = new PowerProcessorExtension()
PowerProcessorStat stats = extension.processCommandOutput(inputStream)
then:
stats.getUser() == 83.7f
stats.getSys() == 3.3f
stats.getWait() == 0.0f
stats.getIdle() == 13.0f
stats.getFields().get("smt") == 8
stats.getFields().get("ent") == 0.50f
2021-06-08 18:24:43 +00:00
stats.getFields().get("type") == "Shared"
}
void "test AIX lparstat dedicated-donating output processing"() {
2021-06-08 18:24:43 +00:00
setup:
InputStream inputStream = getClass().getResourceAsStream('/lparstat-aix-dedicated-donating.txt')
2021-06-08 18:24:43 +00:00
when:
2022-12-21 16:12:15 +00:00
PowerProcessorExtension extension = new PowerProcessorExtension()
PowerProcessorStat stats = extension.processCommandOutput(inputStream)
2021-06-08 18:24:43 +00:00
then:
stats.getUser() == 0.1f
stats.getSys() == 0.2f
stats.getWait() == 0.0f
stats.getIdle() == 99.7f
stats.getFields().get("smt") == 8
2021-06-08 18:24:43 +00:00
stats.getFields().get("physc") == 0.07f
stats.getFields().get("type") == "Dedicated"
stats.getFields().get("mode") == "Donating"
}
void "test AIX lparstat dedicated-capped output processing"() {
setup:
InputStream inputStream = getClass().getResourceAsStream('/lparstat-aix-dedicated-capped.txt')
when:
2022-12-21 16:12:15 +00:00
PowerProcessorExtension extension = new PowerProcessorExtension()
PowerProcessorStat stats = extension.processCommandOutput(inputStream)
then:
stats.getUser() == 0.0f
stats.getSys() == 0.1f
stats.getWait() == 0.0f
stats.getIdle() == 99.9f
stats.getFields().get("smt") == 4
stats.getFields().get("type") == "Dedicated"
stats.getFields().get("mode") == "Capped"
2021-06-08 18:24:43 +00:00
}
void "test Linux lparstat output processing"() {
setup:
InputStream inputStream = getClass().getResourceAsStream('/lparstat-linux.txt')
when:
2022-12-21 16:12:15 +00:00
PowerProcessorExtension extension = new PowerProcessorExtension()
PowerProcessorStat stats = extension.processCommandOutput(inputStream)
then:
stats.getUser() == 0.03f
stats.getSys() == 0.0f
stats.getWait() == 0.0f
stats.getIdle() == 99.97f
stats.getFields().get("smt") == 8
stats.getFields().get("ent") == 4.00f
2021-05-21 09:08:43 +00:00
stats.getFields().get("mode") == "Uncapped"
stats.getFields().get("type") == "Shared"
}
}