diff --git a/build.gradle b/build.gradle index 9201858..09ae6e5 100644 --- a/build.gradle +++ b/build.gradle @@ -27,10 +27,9 @@ dependencies { implementation 'org.slf4j:slf4j-api:1.7.+' runtimeOnly 'ch.qos.logback:logback-classic:1.+' - testImplementation 'org.codehaus.groovy:groovy-all:3.0.5' testImplementation('org.spockframework:spock-core:2.0-M3-groovy-3.0') + testImplementation('com.squareup.okhttp3:mockwebserver:4.9.0') testImplementation("org.slf4j:slf4j-simple:1.7.+") - testImplementation('com.squareup.okhttp3:mockwebserver:4.8.0') //implementation platform('org.testcontainers:testcontainers-bom:1.14.3') //import bom //testCompile "org.testcontainers:influxdb:1.14.3" } diff --git a/src/main/java/biz/nellemann/hmci/HmcClient.java b/src/main/java/biz/nellemann/hmci/HmcClient.java index d5a3375..8ed607d 100644 --- a/src/main/java/biz/nellemann/hmci/HmcClient.java +++ b/src/main/java/biz/nellemann/hmci/HmcClient.java @@ -308,27 +308,9 @@ class HmcClient { * @return Response body string */ private String getResponse(URL url) throws Exception { - return getResponse(url, 0); - } - - - /** - * Return a Response from the HMC - * @param url to get Response from - * @param retry number of retries for this call - * @return Response body string - */ - private String getResponse(URL url, Integer retry) throws Exception { log.debug("getResponse() - " + url.toString()); - if(responseErrors > 2) { - log.warn("getResponse() - retries > 2"); - responseErrors = 0; - login(); - return getResponse(url, retry++); - } - Request request = new Request.Builder() .url(url) .addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8") @@ -346,12 +328,7 @@ class HmcClient { log.warn("getResponse() - 401 - login and retry."); authToken = null; login(); - return getResponse(url, retry++); - } - - if(retry < 2) { - log.warn("getResponse() - Retrying due to unexpected response: " + response.code()); - return getResponse(url, retry++); + return null; } log.error("getResponse() - Unexpected response: " + response.code()); diff --git a/src/main/java/biz/nellemann/hmci/Main.java b/src/main/java/biz/nellemann/hmci/Main.java index 5267d98..9745f08 100644 --- a/src/main/java/biz/nellemann/hmci/Main.java +++ b/src/main/java/biz/nellemann/hmci/Main.java @@ -33,8 +33,8 @@ public class Main implements Callable { private final static Logger log = LoggerFactory.getLogger(Main.class); - @Option(names = { "-c", "--conf" }, description = "Configuration file [default: '/etc/hmci.toml'].") - private String configurationFile = "/etc/hmci.toml"; + @Option(names = { "-c", "--conf" }, description = "Configuration file [default: '/etc/hmci.toml'].", defaultValue = "/etc/hmci.toml", paramLabel = "") + private String configurationFile; public static void main(String... args) { int exitCode = new CommandLine(new Main()).execute(args); diff --git a/src/test/groovy/biz/nellemann/hmci/InfluxClientTest.groovy b/src/test/groovy/biz/nellemann/hmci/InfluxClientTest.groovy index c55bcc0..fd7f6c7 100644 --- a/src/test/groovy/biz/nellemann/hmci/InfluxClientTest.groovy +++ b/src/test/groovy/biz/nellemann/hmci/InfluxClientTest.groovy @@ -49,7 +49,7 @@ class InfluxClientTest extends Specification { influxClient.writeLogicalPartition(lpar) then: - lpar.metrics.systemUtil.utilSamples.first().sampleInfo.status == 2 + lpar.metrics.systemUtil.sample.sampleInfo.status == 2 }