2022-12-21 16:12:15 +00:00
|
|
|
import sysmon.plugins.power.PowerProcessorExtension
|
|
|
|
import sysmon.plugins.power.PowerProcessorStat
|
2021-05-07 10:39:55 +00:00
|
|
|
import spock.lang.Specification
|
|
|
|
|
2022-12-21 16:12:15 +00:00
|
|
|
class PowerProcessorTest extends Specification {
|
2021-05-07 10:39:55 +00:00
|
|
|
|
2021-06-08 18:24:43 +00:00
|
|
|
void "test AIX lparstat shared output processing"() {
|
2021-05-07 10:39:55 +00:00
|
|
|
|
|
|
|
setup:
|
2021-09-17 09:53:57 +00:00
|
|
|
InputStream inputStream = getClass().getResourceAsStream('/lparstat-aix-shared.txt')
|
2021-05-07 10:39:55 +00:00
|
|
|
|
|
|
|
when:
|
2022-12-21 16:12:15 +00:00
|
|
|
PowerProcessorExtension extension = new PowerProcessorExtension()
|
|
|
|
PowerProcessorStat stats = extension.processCommandOutput(inputStream)
|
2021-05-07 10:39:55 +00:00
|
|
|
|
|
|
|
then:
|
2021-05-10 14:56:56 +00:00
|
|
|
stats.getUser() == 83.7f
|
|
|
|
stats.getSys() == 3.3f
|
|
|
|
stats.getWait() == 0.0f
|
|
|
|
stats.getIdle() == 13.0f
|
2021-11-06 19:32:54 +00:00
|
|
|
stats.getFields().get("smt") == 8
|
2021-05-10 14:56:56 +00:00
|
|
|
stats.getFields().get("ent") == 0.50f
|
2021-06-08 18:24:43 +00:00
|
|
|
stats.getFields().get("type") == "Shared"
|
2021-05-07 10:39:55 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-02-25 14:45:11 +00:00
|
|
|
void "test AIX lparstat dedicated-donating output processing"() {
|
2021-06-08 18:24:43 +00:00
|
|
|
|
|
|
|
setup:
|
2022-02-25 14:45:11 +00:00
|
|
|
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
|
2021-11-06 19:32:54 +00:00
|
|
|
stats.getFields().get("smt") == 8
|
2021-06-08 18:24:43 +00:00
|
|
|
stats.getFields().get("physc") == 0.07f
|
|
|
|
stats.getFields().get("type") == "Dedicated"
|
2022-02-25 14:45:11 +00:00
|
|
|
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)
|
2022-02-25 14:45:11 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
}
|
2021-05-10 14:56:56 +00:00
|
|
|
|
2021-05-11 13:37:23 +00:00
|
|
|
void "test Linux lparstat output processing"() {
|
|
|
|
|
|
|
|
setup:
|
2021-09-17 09:53:57 +00:00
|
|
|
InputStream inputStream = getClass().getResourceAsStream('/lparstat-linux.txt')
|
2021-05-11 13:37:23 +00:00
|
|
|
|
|
|
|
when:
|
2022-12-21 16:12:15 +00:00
|
|
|
PowerProcessorExtension extension = new PowerProcessorExtension()
|
|
|
|
PowerProcessorStat stats = extension.processCommandOutput(inputStream)
|
2021-05-11 13:37:23 +00:00
|
|
|
|
|
|
|
then:
|
|
|
|
stats.getUser() == 0.03f
|
|
|
|
stats.getSys() == 0.0f
|
|
|
|
stats.getWait() == 0.0f
|
|
|
|
stats.getIdle() == 99.97f
|
2021-11-06 19:32:54 +00:00
|
|
|
stats.getFields().get("smt") == 8
|
2021-05-11 13:37:23 +00:00
|
|
|
stats.getFields().get("ent") == 4.00f
|
2021-05-21 09:08:43 +00:00
|
|
|
stats.getFields().get("mode") == "Uncapped"
|
|
|
|
stats.getFields().get("type") == "Shared"
|
2021-05-11 13:37:23 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-05-07 10:39:55 +00:00
|
|
|
}
|