summaryrefslogtreecommitdiffstats
path: root/node-maintainer
diff options
context:
space:
mode:
authorOla Aunrønning <olaa@yahoo-inc.com>2017-08-08 14:19:36 +0200
committerOla Aunrønning <olaa@yahoo-inc.com>2017-08-15 12:29:36 +0200
commitbf9c5c49df085578d04e5c64a0f1692bf39ab6a6 (patch)
tree596a7b25152d8465bd08ff14b57d905eb08782f8 /node-maintainer
parent7cf1265d6eb1501de350612e2d446300b8f9ebd3 (diff)
Begun work on result reporting. Moved noderepo to commons
Diffstat (limited to 'node-maintainer')
-rw-r--r--node-maintainer/pom.xml5
-rw-r--r--node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/ReportSender.java62
-rw-r--r--node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/IPAddressVerifier.java (renamed from node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/noderepo/IPAddressVerifier.java)8
-rw-r--r--node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeJsonConverter.java (renamed from node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/noderepo/NodeJsonConverter.java)2
-rw-r--r--node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeRepoInfoRetriever.java (renamed from node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/noderepo/NodeRepoInfoRetriever.java)2
-rw-r--r--node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeRepoJsonModel.java (renamed from node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/noderepo/NodeRepoJsonModel.java)8
-rw-r--r--node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/report/BenchmarkReport.java (renamed from node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/report/BenchmarkReport.java)2
-rw-r--r--node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/report/HardwareDivergenceReport.java23
-rw-r--r--node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/report/SpecVerificationReport.java (renamed from node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/report/VerificationReport.java)4
-rw-r--r--node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/BenchmarkResultInspector.java2
-rw-r--r--node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/HardwareBenchmarker.java33
-rw-r--r--node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/HardwareNodeComparator.java48
-rw-r--r--node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/SpecVerifier.java41
-rw-r--r--node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/VerifierSettings.java2
-rw-r--r--node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/IPAddressVerifierTest.java (renamed from node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/noderepo/IPAddressVerifierTest.java)2
-rw-r--r--node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeJsonConverterTest.java (renamed from node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/noderepo/NodeJsonConverterTest.java)2
-rw-r--r--node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeRepoInfoRetrieverTest.java (renamed from node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/noderepo/NodeRepoInfoRetrieverTest.java)2
-rw-r--r--node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/hardware/BenchmarkResultInspectorTest.java2
-rw-r--r--node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/hardware/HardwareBenchmarkerTest.java6
-rw-r--r--node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/hardware/report/BenchmarkReportTest.java2
-rw-r--r--node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/SpecVerifierTest.java11
-rw-r--r--node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/report/SpecVerificationReportTest.java (renamed from node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/report/VerificationReportTest.java)23
22 files changed, 194 insertions, 98 deletions
diff --git a/node-maintainer/pom.xml b/node-maintainer/pom.xml
index d56e12d92c6..03ed8a77f7d 100644
--- a/node-maintainer/pom.xml
+++ b/node-maintainer/pom.xml
@@ -33,6 +33,11 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>com.yahoo.vespa</groupId>
+ <artifactId>application</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/ReportSender.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/ReportSender.java
new file mode 100644
index 00000000000..1f57392d2e9
--- /dev/null
+++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/ReportSender.java
@@ -0,0 +1,62 @@
+package com.yahoo.vespa.hosted.node.verification.commons;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import com.yahoo.application.Networking;
+import com.yahoo.application.container.handler.Request;
+import com.yahoo.application.container.JDisc;
+import com.yahoo.application.container.handler.Response;
+import com.yahoo.text.Utf8;
+import com.yahoo.vespa.hosted.node.verification.commons.noderepo.NodeRepoInfoRetriever;
+import com.yahoo.vespa.hosted.node.verification.commons.noderepo.NodeRepoJsonModel;
+import com.yahoo.vespa.hosted.node.verification.commons.report.BenchmarkReport;
+import com.yahoo.vespa.hosted.node.verification.commons.report.HardwareDivergenceReport;
+import com.yahoo.vespa.hosted.node.verification.commons.report.SpecVerificationReport;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+
+public class ReportSender {
+
+ private static void updateNodeRepository(ArrayList<URL> nodeInfoUrls, HardwareDivergenceReport hardwareDivergenceReport) throws IOException {
+ ObjectMapper om = new ObjectMapper();
+ String report = "{\"hardwareDivergence\": " + om.writeValueAsString(hardwareDivergenceReport) + "}";
+ System.out.println(report);
+ /*
+ //TODO: Update node repo
+ String url = nodeInfoUrls.get(0).toString();
+ Request request = new Request(url, Utf8.toBytes(report), Request.Method.PATCH);
+ JDisc container = JDisc.fromServicesXml("<jdisc version=\"1.0\"/>", Networking.disable);
+ Response response = container.handleRequest(request);
+ container.close();
+
+ for (URL nodeInfoUrl : nodeInfoUrls) {
+ new Request(nodeInfoUrl.toString(),
+ Utf8.toBytes(report),
+ Request.Method.PATCH);
+
+ }*/
+ }
+
+ public static void reportBenchmarkResults(BenchmarkReport benchmarkReport, ArrayList<URL> nodeInfoUrls) throws IOException {
+ HardwareDivergenceReport hardwareDivergenceReport = generateHardwareDivergenceReport(nodeInfoUrls);
+ hardwareDivergenceReport.setBenchmarkReport(benchmarkReport);
+ updateNodeRepository(nodeInfoUrls, hardwareDivergenceReport);
+ }
+
+ public static void reportSpecVerificationResults(SpecVerificationReport specVerificationReport, ArrayList<URL> nodeInfoUrls) throws IOException {
+ HardwareDivergenceReport hardwareDivergenceReport = generateHardwareDivergenceReport(nodeInfoUrls);
+ hardwareDivergenceReport.setSpecVerificationReport(specVerificationReport);
+ updateNodeRepository(nodeInfoUrls, hardwareDivergenceReport);
+ }
+
+ private static HardwareDivergenceReport generateHardwareDivergenceReport(ArrayList<URL> nodeInfoUrls) throws IOException {
+ NodeRepoJsonModel nodeRepoJsonModel = NodeRepoInfoRetriever.retrieve(nodeInfoUrls);
+ ObjectMapper om = new ObjectMapper();
+ if (nodeRepoJsonModel.getHardwareDivergence() == null) {
+ return new HardwareDivergenceReport();
+ }
+ return om.readValue(nodeRepoJsonModel.getHardwareDivergence(), HardwareDivergenceReport.class);
+ }
+}
diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/noderepo/IPAddressVerifier.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/IPAddressVerifier.java
index 72149d561c5..b9704f464c7 100644
--- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/noderepo/IPAddressVerifier.java
+++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/IPAddressVerifier.java
@@ -1,6 +1,6 @@
-package com.yahoo.vespa.hosted.node.verification.spec.noderepo;
+package com.yahoo.vespa.hosted.node.verification.commons.noderepo;
-import com.yahoo.vespa.hosted.node.verification.spec.report.VerificationReport;
+import com.yahoo.vespa.hosted.node.verification.commons.report.SpecVerificationReport;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
@@ -23,10 +23,10 @@ public class IPAddressVerifier {
private static final Logger logger = Logger.getLogger(IPAddressVerifier.class.getName());
- public void reportFaultyIpAddresses(NodeRepoJsonModel nodeRepoJsonModel, VerificationReport verificationReport) {
+ public void reportFaultyIpAddresses(NodeRepoJsonModel nodeRepoJsonModel, SpecVerificationReport specVerificationReport) {
String[] faultyIpAddresses = getFaultyIpAddresses(nodeRepoJsonModel);
if (faultyIpAddresses.length > 0) {
- verificationReport.setFaultyIpAddresses(faultyIpAddresses);
+ specVerificationReport.setFaultyIpAddresses(faultyIpAddresses);
}
}
diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/noderepo/NodeJsonConverter.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeJsonConverter.java
index ec078624920..b1e20fbbb3e 100644
--- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/noderepo/NodeJsonConverter.java
+++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeJsonConverter.java
@@ -1,4 +1,4 @@
-package com.yahoo.vespa.hosted.node.verification.spec.noderepo;
+package com.yahoo.vespa.hosted.node.verification.commons.noderepo;
import com.yahoo.vespa.hosted.node.verification.spec.retrievers.HardwareInfo;
diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/noderepo/NodeRepoInfoRetriever.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeRepoInfoRetriever.java
index f3bc70310ce..59cf87bd44c 100644
--- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/noderepo/NodeRepoInfoRetriever.java
+++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeRepoInfoRetriever.java
@@ -1,4 +1,4 @@
-package com.yahoo.vespa.hosted.node.verification.spec.noderepo;
+package com.yahoo.vespa.hosted.node.verification.commons.noderepo;
import com.fasterxml.jackson.databind.ObjectMapper;
diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/noderepo/NodeRepoJsonModel.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeRepoJsonModel.java
index 319fa08f28f..9a314b061c4 100644
--- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/noderepo/NodeRepoJsonModel.java
+++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeRepoJsonModel.java
@@ -1,4 +1,4 @@
-package com.yahoo.vespa.hosted.node.verification.spec.noderepo;
+package com.yahoo.vespa.hosted.node.verification.commons.noderepo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
@@ -32,6 +32,9 @@ public class NodeRepoJsonModel {
private String hostname;
@JsonProperty
private String environment;
+ @JsonProperty
+ private String hardwareDivergence;
+ private String nodeRepoUrl;
public HardwareInfo copyToHardwareInfo() {
HardwareInfo hardwareInfo = new HardwareInfo();
@@ -81,4 +84,7 @@ public class NodeRepoJsonModel {
return environment;
}
+ public String getHardwareDivergence() {
+ return hardwareDivergence;
+ }
}
diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/report/BenchmarkReport.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/report/BenchmarkReport.java
index e1b8cd9bb8c..50794af278d 100644
--- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/report/BenchmarkReport.java
+++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/report/BenchmarkReport.java
@@ -1,4 +1,4 @@
-package com.yahoo.vespa.hosted.node.verification.hardware.report;
+package com.yahoo.vespa.hosted.node.verification.commons.report;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/report/HardwareDivergenceReport.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/report/HardwareDivergenceReport.java
new file mode 100644
index 00000000000..af85b142141
--- /dev/null
+++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/report/HardwareDivergenceReport.java
@@ -0,0 +1,23 @@
+package com.yahoo.vespa.hosted.node.verification.commons.report;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class HardwareDivergenceReport {
+
+ @JsonProperty
+ SpecVerificationReport specVerificationReport;
+
+ @JsonProperty
+ BenchmarkReport benchmarkReport;
+
+ public void setSpecVerificationReport(SpecVerificationReport specVerificationReport) {
+ this.specVerificationReport = specVerificationReport;
+ }
+
+ public void setBenchmarkReport(BenchmarkReport benchmarkReport) {
+ this.benchmarkReport = benchmarkReport;
+ }
+
+}
diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/report/VerificationReport.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/report/SpecVerificationReport.java
index ede4b0fc73a..b6af61e4d20 100644
--- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/report/VerificationReport.java
+++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/report/SpecVerificationReport.java
@@ -1,4 +1,4 @@
-package com.yahoo.vespa.hosted.node.verification.spec.report;
+package com.yahoo.vespa.hosted.node.verification.commons.report;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
@@ -11,7 +11,7 @@ import com.yahoo.vespa.hosted.node.verification.spec.retrievers.HardwareInfo;
* Attributes of equal value remain null.
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
-public class VerificationReport {
+public class SpecVerificationReport {
@JsonProperty
private Double actualMemoryAvailable;
diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/BenchmarkResultInspector.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/BenchmarkResultInspector.java
index d5174549b9d..23f6e245e86 100644
--- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/BenchmarkResultInspector.java
+++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/BenchmarkResultInspector.java
@@ -1,7 +1,7 @@
package com.yahoo.vespa.hosted.node.verification.hardware;
import com.yahoo.vespa.hosted.node.verification.hardware.benchmarks.BenchmarkResults;
-import com.yahoo.vespa.hosted.node.verification.hardware.report.BenchmarkReport;
+import com.yahoo.vespa.hosted.node.verification.commons.report.BenchmarkReport;
public class BenchmarkResultInspector {
diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/HardwareBenchmarker.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/HardwareBenchmarker.java
index 5bd407ae0fd..7e7d3c65dc0 100644
--- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/HardwareBenchmarker.java
+++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/HardwareBenchmarker.java
@@ -3,13 +3,17 @@ package com.yahoo.vespa.hosted.node.verification.hardware;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yahoo.vespa.hosted.node.verification.commons.CommandExecutor;
+import com.yahoo.vespa.hosted.node.verification.commons.HostURLGenerator;
+import com.yahoo.vespa.hosted.node.verification.commons.ReportSender;
import com.yahoo.vespa.hosted.node.verification.hardware.benchmarks.Benchmark;
import com.yahoo.vespa.hosted.node.verification.hardware.benchmarks.BenchmarkResults;
import com.yahoo.vespa.hosted.node.verification.hardware.benchmarks.CPUBenchmark;
import com.yahoo.vespa.hosted.node.verification.hardware.benchmarks.DiskBenchmark;
import com.yahoo.vespa.hosted.node.verification.hardware.benchmarks.MemoryBenchmark;
-import com.yahoo.vespa.hosted.node.verification.hardware.report.BenchmarkReport;
+import com.yahoo.vespa.hosted.node.verification.commons.report.BenchmarkReport;
+import java.io.IOException;
+import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
@@ -18,7 +22,7 @@ import java.util.Arrays;
*/
public class HardwareBenchmarker {
- public static boolean hardwareBenchmarks(CommandExecutor commandExecutor) {
+ public static boolean hardwareBenchmarks(CommandExecutor commandExecutor, ArrayList<URL> nodeInfoUrls) throws IOException {
BenchmarkResults benchmarkResults = new BenchmarkResults();
ArrayList<Benchmark> benchmarks = new ArrayList<>(Arrays.asList(
new DiskBenchmark(benchmarkResults, commandExecutor),
@@ -28,10 +32,14 @@ public class HardwareBenchmarker {
benchmark.doBenchmark();
}
BenchmarkReport benchmarkReport = BenchmarkResultInspector.makeBenchmarkReport(benchmarkResults);
- printBenchmarkResults(benchmarkReport);
+ if (!isAllBenchmarksOK(benchmarkReport)) {
+ ReportSender.reportBenchmarkResults(benchmarkReport, nodeInfoUrls);
+ }
return isAllBenchmarksOK(benchmarkReport);
}
+
+
private static boolean isAllBenchmarksOK(BenchmarkReport benchmarkReport) {
ObjectMapper om = new ObjectMapper();
try {
@@ -43,18 +51,15 @@ public class HardwareBenchmarker {
}
}
- private static void printBenchmarkResults(BenchmarkReport benchmarkReport) {
- ObjectMapper om = new ObjectMapper();
- try {
- System.out.println(om.writeValueAsString(benchmarkReport));
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- public static void main(String[] args) {
+ public static void main(String[] args) throws IOException {
CommandExecutor commandExecutor = new CommandExecutor();
- if (!HardwareBenchmarker.hardwareBenchmarks(commandExecutor)){
+ ArrayList<URL> nodeInfoUrls;
+ if (args.length == 0) {
+ nodeInfoUrls = HostURLGenerator.generateNodeInfoUrl(commandExecutor);
+ } else {
+ nodeInfoUrls = HostURLGenerator.generateNodeInfoUrl(commandExecutor, args[0]);
+ }
+ if (!HardwareBenchmarker.hardwareBenchmarks(commandExecutor, nodeInfoUrls)){
System.exit(2);
}
}
diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/HardwareNodeComparator.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/HardwareNodeComparator.java
index 82664424c0a..6d4bcf575ab 100644
--- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/HardwareNodeComparator.java
+++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/HardwareNodeComparator.java
@@ -1,75 +1,75 @@
package com.yahoo.vespa.hosted.node.verification.spec;
+import com.yahoo.vespa.hosted.node.verification.commons.report.SpecVerificationReport;
import com.yahoo.vespa.hosted.node.verification.spec.retrievers.HardwareInfo;
import com.yahoo.vespa.hosted.node.verification.spec.retrievers.HardwareInfo.DiskType;
-import com.yahoo.vespa.hosted.node.verification.spec.report.VerificationReport;
/**
* Created by olaa on 04/07/2017.
- * Compares two HardwareInfo objects and stores divergent values in a VerificationReport
+ * Compares two HardwareInfo objects and stores divergent values in a SpecVerificationReport
*/
public class HardwareNodeComparator {
private static final double PERCENTAGE_THRESHOLD = 0.05;
- public static VerificationReport compare(HardwareInfo nodeRepoHardwareInfo, HardwareInfo actualHardware) {
- VerificationReport verificationReport = new VerificationReport();
+ public static SpecVerificationReport compare(HardwareInfo nodeRepoHardwareInfo, HardwareInfo actualHardware) {
+ SpecVerificationReport specVerificationReport = new SpecVerificationReport();
if (nodeRepoHardwareInfo == null || actualHardware == null) {
- return verificationReport;
+ return specVerificationReport;
}
- setReportMetrics(nodeRepoHardwareInfo, actualHardware, verificationReport);
- return verificationReport;
+ setReportMetrics(nodeRepoHardwareInfo, actualHardware, specVerificationReport);
+ return specVerificationReport;
}
- private static void setReportMetrics(HardwareInfo nodeRepoHardwareInfo, HardwareInfo actualHardware, VerificationReport verificationReport) {
- setMemoryMetrics(nodeRepoHardwareInfo, actualHardware, verificationReport);
- setCpuMetrics(nodeRepoHardwareInfo, actualHardware, verificationReport);
- setDiskTypeMetrics(nodeRepoHardwareInfo, actualHardware, verificationReport);
- setDiskSpaceMetrics(nodeRepoHardwareInfo, actualHardware, verificationReport);
- setNetMetrics(nodeRepoHardwareInfo, actualHardware, verificationReport);
+ private static void setReportMetrics(HardwareInfo nodeRepoHardwareInfo, HardwareInfo actualHardware, SpecVerificationReport specVerificationReport) {
+ setMemoryMetrics(nodeRepoHardwareInfo, actualHardware, specVerificationReport);
+ setCpuMetrics(nodeRepoHardwareInfo, actualHardware, specVerificationReport);
+ setDiskTypeMetrics(nodeRepoHardwareInfo, actualHardware, specVerificationReport);
+ setDiskSpaceMetrics(nodeRepoHardwareInfo, actualHardware, specVerificationReport);
+ setNetMetrics(nodeRepoHardwareInfo, actualHardware, specVerificationReport);
}
- private static void setMemoryMetrics(HardwareInfo nodeRepoHardwareInfo, HardwareInfo actualHardware, VerificationReport verificationReport) {
+ private static void setMemoryMetrics(HardwareInfo nodeRepoHardwareInfo, HardwareInfo actualHardware, SpecVerificationReport specVerificationReport) {
double expectedMemory = nodeRepoHardwareInfo.getMinMainMemoryAvailableGb();
double actualMemory = actualHardware.getMinMainMemoryAvailableGb();
if (outsideThreshold(expectedMemory, actualMemory, PERCENTAGE_THRESHOLD)) {
- verificationReport.setActualMemoryAvailable(actualMemory);
+ specVerificationReport.setActualMemoryAvailable(actualMemory);
}
}
- private static void setCpuMetrics(HardwareInfo nodeRepoHardwareInfo, HardwareInfo actualHardware, VerificationReport verificationReport) {
+ private static void setCpuMetrics(HardwareInfo nodeRepoHardwareInfo, HardwareInfo actualHardware, SpecVerificationReport specVerificationReport) {
int expectedCpuCores = nodeRepoHardwareInfo.getMinCpuCores();
int actualCpuCores = actualHardware.getMinCpuCores();
if (expectedCpuCores != actualCpuCores) {
- verificationReport.setActualcpuCores(actualCpuCores);
+ specVerificationReport.setActualcpuCores(actualCpuCores);
}
}
- private static void setDiskTypeMetrics(HardwareInfo nodeRepoHardwareInfo, HardwareInfo actualHardware, VerificationReport verificationReport) {
+ private static void setDiskTypeMetrics(HardwareInfo nodeRepoHardwareInfo, HardwareInfo actualHardware, SpecVerificationReport specVerificationReport) {
DiskType expectedFastDisk = nodeRepoHardwareInfo.getDiskType();
DiskType actualFastDisk = actualHardware.getDiskType();
if (expectedFastDisk != null && actualFastDisk != null && expectedFastDisk != actualFastDisk) {
- verificationReport.setActualDiskType(actualFastDisk);
+ specVerificationReport.setActualDiskType(actualFastDisk);
}
}
- private static void setDiskSpaceMetrics(HardwareInfo nodeRepoHardwareInfo, HardwareInfo actualHardware, VerificationReport verificationReport) {
+ private static void setDiskSpaceMetrics(HardwareInfo nodeRepoHardwareInfo, HardwareInfo actualHardware, SpecVerificationReport specVerificationReport) {
double expectedDiskSpace = nodeRepoHardwareInfo.getMinDiskAvailableGb();
double actualDiskSpace = actualHardware.getMinDiskAvailableGb();
if (outsideThreshold(expectedDiskSpace, actualDiskSpace, PERCENTAGE_THRESHOLD)) {
- verificationReport.setActualDiskSpaceAvailable(actualDiskSpace);
+ specVerificationReport.setActualDiskSpaceAvailable(actualDiskSpace);
}
}
- private static void setNetMetrics(HardwareInfo nodeRepoHardwareInfo, HardwareInfo actualHardware, VerificationReport verificationReport) {
+ private static void setNetMetrics(HardwareInfo nodeRepoHardwareInfo, HardwareInfo actualHardware, SpecVerificationReport specVerificationReport) {
double expectedInterfaceSpeed = nodeRepoHardwareInfo.getInterfaceSpeedMbs();
double actualInterfaceSpeed = actualHardware.getInterfaceSpeedMbs();
if (expectedInterfaceSpeed > actualInterfaceSpeed) {
- verificationReport.setActualInterfaceSpeed(actualInterfaceSpeed);
+ specVerificationReport.setActualInterfaceSpeed(actualInterfaceSpeed);
}
if (nodeRepoHardwareInfo.isIpv6Connection() && !actualHardware.isIpv6Connection()) {
- verificationReport.setActualIpv6Connection(actualHardware.isIpv6Connection());
+ specVerificationReport.setActualIpv6Connection(actualHardware.isIpv6Connection());
}
private static boolean outsideThreshold(double value1, double value2 , double thresholdPercentage) {
diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/SpecVerifier.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/SpecVerifier.java
index 0fcb6206237..2ef7668cc2d 100644
--- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/SpecVerifier.java
+++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/SpecVerifier.java
@@ -4,13 +4,14 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yahoo.vespa.hosted.node.verification.commons.CommandExecutor;
import com.yahoo.vespa.hosted.node.verification.commons.HostURLGenerator;
-import com.yahoo.vespa.hosted.node.verification.spec.noderepo.IPAddressVerifier;
-import com.yahoo.vespa.hosted.node.verification.spec.noderepo.NodeJsonConverter;
-import com.yahoo.vespa.hosted.node.verification.spec.noderepo.NodeRepoInfoRetriever;
-import com.yahoo.vespa.hosted.node.verification.spec.noderepo.NodeRepoJsonModel;
+import com.yahoo.vespa.hosted.node.verification.commons.ReportSender;
+import com.yahoo.vespa.hosted.node.verification.commons.noderepo.IPAddressVerifier;
+import com.yahoo.vespa.hosted.node.verification.commons.noderepo.NodeJsonConverter;
+import com.yahoo.vespa.hosted.node.verification.commons.noderepo.NodeRepoInfoRetriever;
+import com.yahoo.vespa.hosted.node.verification.commons.noderepo.NodeRepoJsonModel;
+import com.yahoo.vespa.hosted.node.verification.commons.report.SpecVerificationReport;
import com.yahoo.vespa.hosted.node.verification.spec.retrievers.HardwareInfo;
import com.yahoo.vespa.hosted.node.verification.spec.retrievers.HardwareInfoRetriever;
-import com.yahoo.vespa.hosted.node.verification.spec.report.VerificationReport;
import java.io.IOException;
import java.net.URL;
@@ -36,21 +37,23 @@ public class SpecVerifier {
}
VerifierSettings verifierSettings = new VerifierSettings(nodeRepoJsonModel);
HardwareInfo actualHardware = HardwareInfoRetriever.retrieve(commandExecutor, verifierSettings);
- VerificationReport verificationReport = makeVerificationReport(actualHardware, nodeRepoJsonModel);
- printResults(verificationReport);
- return isValidSpec(verificationReport);
+ SpecVerificationReport specVerificationReport = makeVerificationReport(actualHardware, nodeRepoJsonModel);
+ if (!isValidSpec(specVerificationReport)) {
+ ReportSender.reportSpecVerificationResults(specVerificationReport, nodeInfoUrls);
+ }
+ return isValidSpec(specVerificationReport);
}
- private static boolean isValidSpec(VerificationReport verificationReport) throws JsonProcessingException {
+ private static boolean isValidSpec(SpecVerificationReport specVerificationReport) throws JsonProcessingException {
ObjectMapper om = new ObjectMapper();
- return om.writeValueAsString(verificationReport).length() == 2;
+ return om.writeValueAsString(specVerificationReport).length() == 2;
}
- protected static VerificationReport makeVerificationReport(HardwareInfo actualHardware, NodeRepoJsonModel nodeRepoJsonModel) {
- VerificationReport verificationReport = HardwareNodeComparator.compare(NodeJsonConverter.convertJsonModelToHardwareInfo(nodeRepoJsonModel), actualHardware);
+ protected static SpecVerificationReport makeVerificationReport(HardwareInfo actualHardware, NodeRepoJsonModel nodeRepoJsonModel) {
+ SpecVerificationReport specVerificationReport = HardwareNodeComparator.compare(NodeJsonConverter.convertJsonModelToHardwareInfo(nodeRepoJsonModel), actualHardware);
IPAddressVerifier ipAddressVerifier = new IPAddressVerifier();
- ipAddressVerifier.reportFaultyIpAddresses(nodeRepoJsonModel, verificationReport);
- return verificationReport;
+ ipAddressVerifier.reportFaultyIpAddresses(nodeRepoJsonModel, specVerificationReport);
+ return specVerificationReport;
}
protected static NodeRepoJsonModel getNodeRepositoryJSON(ArrayList<URL> nodeInfoUrls) throws IOException {
@@ -58,16 +61,6 @@ public class SpecVerifier {
return nodeRepoJsonModel;
}
- private static void printResults(VerificationReport verificationReport) {
- //TODO: Instead of println, report JSON to node repo
- ObjectMapper om = new ObjectMapper();
- try {
- System.out.println(om.writeValueAsString(verificationReport));
- } catch (JsonProcessingException e) {
- e.printStackTrace();
- }
- }
-
public static void main(String[] args) throws IOException {
CommandExecutor commandExecutor = new CommandExecutor();
ArrayList<URL> nodeInfoUrls;
diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/VerifierSettings.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/VerifierSettings.java
index 936c19f6c7f..c170ac0bedf 100644
--- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/VerifierSettings.java
+++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/VerifierSettings.java
@@ -1,6 +1,6 @@
package com.yahoo.vespa.hosted.node.verification.spec;
-import com.yahoo.vespa.hosted.node.verification.spec.noderepo.NodeRepoJsonModel;
+import com.yahoo.vespa.hosted.node.verification.commons.noderepo.NodeRepoJsonModel;
/**
* Created by sgrostad on 07/08/2017.
diff --git a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/noderepo/IPAddressVerifierTest.java b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/IPAddressVerifierTest.java
index eee2244b6ff..50f350aea63 100644
--- a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/noderepo/IPAddressVerifierTest.java
+++ b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/IPAddressVerifierTest.java
@@ -1,4 +1,4 @@
-package com.yahoo.vespa.hosted.node.verification.spec.noderepo;
+package com.yahoo.vespa.hosted.node.verification.commons.noderepo;
import org.junit.Before;
import org.junit.Test;
diff --git a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/noderepo/NodeJsonConverterTest.java b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeJsonConverterTest.java
index 5d76f7fb012..24280e99cfa 100644
--- a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/noderepo/NodeJsonConverterTest.java
+++ b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeJsonConverterTest.java
@@ -1,4 +1,4 @@
-package com.yahoo.vespa.hosted.node.verification.spec.noderepo;
+package com.yahoo.vespa.hosted.node.verification.commons.noderepo;
import com.yahoo.vespa.hosted.node.verification.spec.retrievers.HardwareInfo;
import org.junit.Test;
diff --git a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/noderepo/NodeRepoInfoRetrieverTest.java b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeRepoInfoRetrieverTest.java
index 729506fcab0..8d7cf4d06f0 100644
--- a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/noderepo/NodeRepoInfoRetrieverTest.java
+++ b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeRepoInfoRetrieverTest.java
@@ -1,4 +1,4 @@
-package com.yahoo.vespa.hosted.node.verification.spec.noderepo;
+package com.yahoo.vespa.hosted.node.verification.commons.noderepo;
import org.junit.Before;
import org.junit.Test;
diff --git a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/hardware/BenchmarkResultInspectorTest.java b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/hardware/BenchmarkResultInspectorTest.java
index 55f5af05771..7314839c438 100644
--- a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/hardware/BenchmarkResultInspectorTest.java
+++ b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/hardware/BenchmarkResultInspectorTest.java
@@ -1,7 +1,7 @@
package com.yahoo.vespa.hosted.node.verification.hardware;
import com.yahoo.vespa.hosted.node.verification.hardware.benchmarks.BenchmarkResults;
-import com.yahoo.vespa.hosted.node.verification.hardware.report.BenchmarkReport;
+import com.yahoo.vespa.hosted.node.verification.commons.report.BenchmarkReport;
import org.junit.Before;
import org.junit.Test;
diff --git a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/hardware/HardwareBenchmarkerTest.java b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/hardware/HardwareBenchmarkerTest.java
index c976aff54c5..1b1eafd8cd9 100644
--- a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/hardware/HardwareBenchmarkerTest.java
+++ b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/hardware/HardwareBenchmarkerTest.java
@@ -4,6 +4,8 @@ import com.yahoo.vespa.hosted.node.verification.mock.MockCommandExecutor;
import org.junit.Before;
import org.junit.Test;
+import java.util.ArrayList;
+
import static org.junit.Assert.assertTrue;
public class HardwareBenchmarkerTest {
@@ -22,7 +24,7 @@ public class HardwareBenchmarkerTest {
}
@Test
- public void hardwareBenchmarks_should_return_true() {
+ public void hardwareBenchmarks_should_return_true() throws Exception {
mockCommandExecutor.addCommand("cat " + VALID_DISK_BENCHMARK_PATH);
mockCommandExecutor.addCommand("cat " + VALID_CPU_BENCHMARK_PATH);
mockCommandExecutor.addDummyCommand();
@@ -31,7 +33,7 @@ public class HardwareBenchmarkerTest {
mockCommandExecutor.addCommand("cat " + VALID_MEMORY_READ_BENCHMARK_PATH);
mockCommandExecutor.addDummyCommand();
mockCommandExecutor.addDummyCommand();
- assertTrue(HardwareBenchmarker.hardwareBenchmarks(mockCommandExecutor));
+ assertTrue(HardwareBenchmarker.hardwareBenchmarks(mockCommandExecutor, new ArrayList<>()));
}
diff --git a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/hardware/report/BenchmarkReportTest.java b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/hardware/report/BenchmarkReportTest.java
index 8b501d4bcff..a9568ed4a3e 100644
--- a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/hardware/report/BenchmarkReportTest.java
+++ b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/hardware/report/BenchmarkReportTest.java
@@ -1,7 +1,7 @@
package com.yahoo.vespa.hosted.node.verification.hardware.report;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.yahoo.vespa.hosted.node.verification.hardware.benchmarks.BenchmarkResults;
+import com.yahoo.vespa.hosted.node.verification.commons.report.BenchmarkReport;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
diff --git a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/SpecVerifierTest.java b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/SpecVerifierTest.java
index 6d6708f938f..c0e5cc62b6e 100644
--- a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/SpecVerifierTest.java
+++ b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/SpecVerifierTest.java
@@ -2,10 +2,10 @@ package com.yahoo.vespa.hosted.node.verification.spec;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yahoo.vespa.hosted.node.verification.mock.MockCommandExecutor;
-import com.yahoo.vespa.hosted.node.verification.spec.noderepo.NodeRepoInfoRetriever;
-import com.yahoo.vespa.hosted.node.verification.spec.noderepo.NodeRepoJsonModel;
+import com.yahoo.vespa.hosted.node.verification.commons.noderepo.NodeRepoInfoRetriever;
+import com.yahoo.vespa.hosted.node.verification.commons.noderepo.NodeRepoJsonModel;
import com.yahoo.vespa.hosted.node.verification.spec.retrievers.HardwareInfo;
-import com.yahoo.vespa.hosted.node.verification.spec.report.VerificationReport;
+import com.yahoo.vespa.hosted.node.verification.commons.report.SpecVerificationReport;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
@@ -14,7 +14,6 @@ import java.io.File;
import java.net.URL;
import java.nio.file.Paths;
import java.util.ArrayList;
-import java.util.Arrays;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -92,10 +91,10 @@ public class SpecVerifierTest {
actualHardware.setDiskType(HardwareInfo.DiskType.SLOW);
nodeInfoUrls.add(new File(NODE_REPO_PATH).toURI().toURL());
NodeRepoJsonModel nodeRepoJsonModel = NodeRepoInfoRetriever.retrieve(nodeInfoUrls);
- VerificationReport verificationSpecReport = SpecVerifier.makeVerificationReport(actualHardware, nodeRepoJsonModel);
+ SpecVerificationReport verificationSpecVerificationReport = SpecVerifier.makeVerificationReport(actualHardware, nodeRepoJsonModel);
String expectedJson = "{\"actualInterfaceSpeed\":100.0}";
ObjectMapper om = new ObjectMapper();
- String actualJson = om.writeValueAsString(verificationSpecReport);
+ String actualJson = om.writeValueAsString(verificationSpecVerificationReport);
assertEquals(expectedJson, actualJson);
}
diff --git a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/report/VerificationReportTest.java b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/report/SpecVerificationReportTest.java
index 2f7bc75af75..e5e7f2ca49a 100644
--- a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/report/VerificationReportTest.java
+++ b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/report/SpecVerificationReportTest.java
@@ -1,6 +1,7 @@
package com.yahoo.vespa.hosted.node.verification.spec.report;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.yahoo.vespa.hosted.node.verification.commons.report.SpecVerificationReport;
import com.yahoo.vespa.hosted.node.verification.mock.MockCommandExecutor;
import com.yahoo.vespa.hosted.node.verification.spec.retrievers.HardwareInfo;
import org.junit.Before;
@@ -8,35 +9,35 @@ import org.junit.Test;
import static org.junit.Assert.*;
-public class VerificationReportTest {
+public class SpecVerificationReportTest {
- private VerificationReport verificationReport;
+ private SpecVerificationReport specVerificationReport;
private static final String REPORT_PATH = "src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/reportJSON";
@Before
public void setup() {
- verificationReport = new VerificationReport();
+ specVerificationReport = new SpecVerificationReport();
}
@Test
public void VerificationReport_returns_empty_string_when_all_specs_are_correct() throws Exception {
String expectedJson = "{}";
ObjectMapper om = new ObjectMapper();
- String actualJson = om.writeValueAsString(verificationReport);
+ String actualJson = om.writeValueAsString(specVerificationReport);
assertEquals(expectedJson, actualJson);
}
@Test
public void Json_is_in_wanted_format_when_all_specs_are_wrong() throws Exception {
- verificationReport.setActualInterfaceSpeed(100D);
- verificationReport.setActualDiskSpaceAvailable(500D);
- verificationReport.setActualDiskType(HardwareInfo.DiskType.FAST);
- verificationReport.setActualMemoryAvailable(123D);
- verificationReport.setActualcpuCores(4);
- verificationReport.setFaultyIpAddresses(new String[]{"2001:4998:44:505d:0:0:0:2618"});
+ specVerificationReport.setActualInterfaceSpeed(100D);
+ specVerificationReport.setActualDiskSpaceAvailable(500D);
+ specVerificationReport.setActualDiskType(HardwareInfo.DiskType.FAST);
+ specVerificationReport.setActualMemoryAvailable(123D);
+ specVerificationReport.setActualcpuCores(4);
+ specVerificationReport.setFaultyIpAddresses(new String[]{"2001:4998:44:505d:0:0:0:2618"});
String expectedJson = MockCommandExecutor.readFromFile(REPORT_PATH).get(0);
ObjectMapper om = new ObjectMapper();
- String actualJson = om.writeValueAsString(verificationReport);
+ String actualJson = om.writeValueAsString(specVerificationReport);
assertEquals(expectedJson, actualJson);
}