More testing, coverage setup and aa try-catch to avoid exits on errors
This commit is contained in:
parent
e805d25143
commit
5004a30331
29
build.gradle
29
build.gradle
|
@ -5,6 +5,9 @@ plugins {
|
||||||
// Apply the application plugin to add support for building a CLI application.
|
// Apply the application plugin to add support for building a CLI application.
|
||||||
id 'application'
|
id 'application'
|
||||||
|
|
||||||
|
// Code coverage of tests
|
||||||
|
id 'jacoco'
|
||||||
|
|
||||||
id "com.github.johnrengelman.shadow" version "6.0.0"
|
id "com.github.johnrengelman.shadow" version "6.0.0"
|
||||||
id "nebula.ospackage" version "8.4.1"
|
id "nebula.ospackage" version "8.4.1"
|
||||||
}
|
}
|
||||||
|
@ -68,3 +71,29 @@ buildDeb {
|
||||||
dependsOn startShadowScripts
|
dependsOn startShadowScripts
|
||||||
requires('default-jre-headless')
|
requires('default-jre-headless')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
jacoco {
|
||||||
|
toolVersion = "0.8.5"
|
||||||
|
}
|
||||||
|
|
||||||
|
jacocoTestReport {
|
||||||
|
group = "verification"
|
||||||
|
reports {
|
||||||
|
xml.enabled false
|
||||||
|
csv.enabled false
|
||||||
|
html.destination file("${buildDir}/reports/coverage")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
test.finalizedBy jacocoTestReport
|
||||||
|
|
||||||
|
jacocoTestCoverageVerification {
|
||||||
|
violationRules {
|
||||||
|
rule {
|
||||||
|
limit {
|
||||||
|
minimum = 0.3 // FIXME: Raise when more tests are implemented
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
check.dependsOn jacocoTestCoverageVerification
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
group = biz.nellemann.hmci
|
group = biz.nellemann.hmci
|
||||||
version = 1.0.3
|
version = 1.0.4
|
||||||
|
|
|
@ -104,7 +104,6 @@ class App implements Runnable {
|
||||||
|
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
log.error(e.message)
|
log.error(e.message)
|
||||||
hmc = null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -129,7 +128,6 @@ class App implements Runnable {
|
||||||
|
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
log.error(e.message)
|
log.error(e.message)
|
||||||
hmc = null
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,17 +194,21 @@ class App implements Runnable {
|
||||||
|
|
||||||
while(keepRunning) {
|
while(keepRunning) {
|
||||||
|
|
||||||
getMetricsForSystems()
|
try {
|
||||||
getMetricsForPartitions()
|
getMetricsForSystems()
|
||||||
|
getMetricsForPartitions()
|
||||||
|
|
||||||
writeMetricsForManagedSystems()
|
writeMetricsForManagedSystems()
|
||||||
writeMetricsForLogicalPartitions()
|
writeMetricsForLogicalPartitions()
|
||||||
influxClient.writeBatchPoints()
|
influxClient.writeBatchPoints()
|
||||||
|
|
||||||
// Refresh HMC's
|
// Refresh HMC's
|
||||||
if(executions > rescanHmcEvery) {
|
if(executions > rescanHmcEvery) {
|
||||||
executions = 0
|
executions = 0
|
||||||
discover()
|
discover()
|
||||||
|
}
|
||||||
|
} catch(Exception e) {
|
||||||
|
log.error(e.message, e)
|
||||||
}
|
}
|
||||||
|
|
||||||
executions++
|
executions++
|
||||||
|
|
|
@ -82,4 +82,9 @@ class HmcClientTest extends Specification {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// getPcmDataForManagedSystem
|
||||||
|
|
||||||
|
// getPcmDataForLogicalPartition
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ class InfluxClientTest extends Specification {
|
||||||
influxClient.logoff()
|
influxClient.logoff()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Ignore
|
||||||
void "write ManagedSystem data to influx"() {
|
void "write ManagedSystem data to influx"() {
|
||||||
|
|
||||||
setup:
|
setup:
|
||||||
|
@ -34,7 +34,7 @@ class InfluxClientTest extends Specification {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Ignore
|
||||||
void "write LogicalPartition data to influx"() {
|
void "write LogicalPartition data to influx"() {
|
||||||
|
|
||||||
setup:
|
setup:
|
||||||
|
|
|
@ -23,6 +23,45 @@ class LogicalPartitionTest extends Specification {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void "test getMemoryMetrics"() {
|
||||||
|
|
||||||
|
setup:
|
||||||
|
def testFile = new File(getClass().getResource('/pcm-data-logical-partition.json').toURI())
|
||||||
|
def testJson = testFile.getText('UTF-8')
|
||||||
|
ManagedSystem system = new ManagedSystem("site1", "e09834d1-c930-3883-bdad-405d8e26e166", "Test Name","Test Type", "Test Model", "Test S/N")
|
||||||
|
LogicalPartition lpar = new LogicalPartition("2DE05DB6-8AD5-448F-8327-0F488D287E82", "9Flash01", "OS400", system)
|
||||||
|
|
||||||
|
when:
|
||||||
|
lpar.processMetrics(testJson)
|
||||||
|
List<Map> listOfMaps = lpar.getMemoryMetrics()
|
||||||
|
|
||||||
|
then:
|
||||||
|
listOfMaps.size() == 1
|
||||||
|
listOfMaps.first().get("fields")['logicalMem'] == 8192.000
|
||||||
|
listOfMaps.first().get("tags")['partition'] == '9Flash01'
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void "test getProcessorMetrics"() {
|
||||||
|
|
||||||
|
setup:
|
||||||
|
def testFile = new File(getClass().getResource('/pcm-data-logical-partition.json').toURI())
|
||||||
|
def testJson = testFile.getText('UTF-8')
|
||||||
|
ManagedSystem system = new ManagedSystem("site1", "e09834d1-c930-3883-bdad-405d8e26e166", "Test Name","Test Type", "Test Model", "Test S/N")
|
||||||
|
LogicalPartition lpar = new LogicalPartition("2DE05DB6-8AD5-448F-8327-0F488D287E82", "9Flash01", "OS400", system)
|
||||||
|
|
||||||
|
when:
|
||||||
|
lpar.processMetrics(testJson)
|
||||||
|
List<Map> listOfMaps = lpar.getProcessorMetrics()
|
||||||
|
|
||||||
|
then:
|
||||||
|
listOfMaps.size() == 1
|
||||||
|
listOfMaps.first().get("fields")['utilizedProcUnits'] == 0.001
|
||||||
|
listOfMaps.first().get("tags")['partition'] == '9Flash01'
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void "test getVirtualEthernetAdapterMetrics"() {
|
void "test getVirtualEthernetAdapterMetrics"() {
|
||||||
|
|
||||||
setup:
|
setup:
|
||||||
|
@ -41,7 +80,23 @@ class LogicalPartitionTest extends Specification {
|
||||||
listOfMaps.first().get("tags")['sea'] == 'ent5'
|
listOfMaps.first().get("tags")['sea'] == 'ent5'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void "test getVirtualFiberChannelAdaptersMetrics"() {
|
||||||
|
|
||||||
|
setup:
|
||||||
|
def testFile = new File(getClass().getResource('/pcm-data-logical-partition.json').toURI())
|
||||||
|
def testJson = testFile.getText('UTF-8')
|
||||||
|
ManagedSystem system = new ManagedSystem("site1", "e09834d1-c930-3883-bdad-405d8e26e166", "Test Name","Test Type", "Test Model", "Test S/N")
|
||||||
|
LogicalPartition lpar = new LogicalPartition("2DE05DB6-8AD5-448F-8327-0F488D287E82", "9Flash01", "OS400", system)
|
||||||
|
|
||||||
|
when:
|
||||||
|
lpar.processMetrics(testJson)
|
||||||
|
List<Map> listOfMaps = lpar.getVirtualFiberChannelAdaptersMetrics()
|
||||||
|
|
||||||
|
then:
|
||||||
|
listOfMaps.size() == 4
|
||||||
|
listOfMaps.first().get("fields")['writeBytes'] == 546.133
|
||||||
|
listOfMaps.first().get("tags")['viosId'] == '2'
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
23
src/test/groovy/biz/nellemann/hmci/MetaSystemTest.groovy
Normal file
23
src/test/groovy/biz/nellemann/hmci/MetaSystemTest.groovy
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
package biz.nellemann.hmci
|
||||||
|
|
||||||
|
import spock.lang.Specification
|
||||||
|
|
||||||
|
import java.time.Instant
|
||||||
|
|
||||||
|
class MetaSystemTest extends Specification {
|
||||||
|
|
||||||
|
void "test timestamp retrieval from xml"() {
|
||||||
|
|
||||||
|
setup:
|
||||||
|
def testFile = new File(getClass().getResource('/pcm-data-managed-system.json').toURI())
|
||||||
|
def testJson = testFile.getText('UTF-8')
|
||||||
|
|
||||||
|
when:
|
||||||
|
ManagedSystem system = new ManagedSystem("site1", "e09834d1-c930-3883-bdad-405d8e26e166", "Test Name","Test Type", "Test Model", "Test S/N")
|
||||||
|
system.processMetrics(testJson)
|
||||||
|
Instant instant = system.getTimestamp()
|
||||||
|
|
||||||
|
then:
|
||||||
|
instant.getEpochSecond() == 1597086630
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue