Simplifications and cleanup.

This commit is contained in:
Mark Nellemann 2020-10-14 17:28:43 +02:00
parent 95964dabcc
commit 3265f0721c
4 changed files with 5 additions and 29 deletions

View File

@ -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"
}

View File

@ -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());

View File

@ -33,8 +33,8 @@ public class Main implements Callable<Integer> {
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 = "<file>")
private String configurationFile;
public static void main(String... args) {
int exitCode = new CommandLine(new Main()).execute(args);

View File

@ -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
}