summaryrefslogtreecommitdiffstats
path: root/node-maintainer
diff options
context:
space:
mode:
authorOla Aunrønning <olaa@yahoo-inc.com>2017-08-07 16:40:58 +0200
committerOla Aunrønning <olaa@yahoo-inc.com>2017-08-15 12:29:27 +0200
commit055800a4ea5501d6adb4e9d842b720c5547f6240 (patch)
tree73fd415f0484a9b2c3f7e3d913bb783f86e48408 /node-maintainer
parent6b512283fd1e7a315ad652fab2964a2300a0f53b (diff)
Changed how SpecVerification reports. Now creates JSON containing only actual hardware values that are different from node repo
Diffstat (limited to 'node-maintainer')
-rw-r--r--node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/HardwareNodeComparator.java47
-rw-r--r--node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/SpecVerifier.java8
-rw-r--r--node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/VerifierSettings.java12
-rw-r--r--node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/report/VerificationReport.java6
-rw-r--r--node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/NetRetriever.java2
-rw-r--r--node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/SpecVerifierTest.java8
-rw-r--r--node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/report/VerificationReportTest.java23
-rw-r--r--node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/reportJSON2
-rw-r--r--node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/HardwareInfoRetrieverTest.java2
-rw-r--r--node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/NetRetrieverTest.java2
10 files changed, 33 insertions, 79 deletions
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 2fba6cd1f2a..99942611e60 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
@@ -32,7 +32,7 @@ public class HardwareNodeComparator {
private static void setMemoryMetrics(HardwareInfo nodeRepoHardwareInfo, HardwareInfo actualHardware, VerificationReport verificationReport) {
double expectedMemory = nodeRepoHardwareInfo.getMinMainMemoryAvailableGb();
double actualMemory = actualHardware.getMinMainMemoryAvailableGb();
- if (outsideThreshold(expectedMemory, actualMemory, PERCENTAGE_THRESHOLD)) {
+ if (!insideThreshold(expectedMemory, actualMemory, PERCENTAGE_THRESHOLD)) {
verificationReport.setActualMemoryAvailable(actualMemory);
}
}
@@ -56,7 +56,7 @@ public class HardwareNodeComparator {
private static void setDiskSpaceMetrics(HardwareInfo nodeRepoHardwareInfo, HardwareInfo actualHardware, VerificationReport verificationReport) {
double expectedDiskSpace = nodeRepoHardwareInfo.getMinDiskAvailableGb();
double actualDiskSpace = actualHardware.getMinDiskAvailableGb();
- if (outsideThreshold(expectedDiskSpace, actualDiskSpace, PERCENTAGE_THRESHOLD)) {
+ if (!insideThreshold(expectedDiskSpace, actualDiskSpace, PERCENTAGE_THRESHOLD)) {
verificationReport.setActualDiskSpaceAvailable(actualDiskSpace);
}
}
@@ -64,48 +64,15 @@ public class HardwareNodeComparator {
private static void setNetMetrics(HardwareInfo nodeRepoHardwareInfo, HardwareInfo actualHardware, VerificationReport verificationReport) {
double expectedInterfaceSpeed = nodeRepoHardwareInfo.getInterfaceSpeedMbs();
double actualInterfaceSpeed = actualHardware.getInterfaceSpeedMbs();
- if (nodeRepoHardwareInfo.getInterfaceSpeedMbs() > actualHardware.getInterfaceSpeedMbs()) {
- specReportMetrics.setExpectedInterfaceSpeed(expectedInterfaceSpeed);
- specReportMetrics.setActualInterfaceSpeed(actualInterfaceSpeed);
+ if (expectedInterfaceSpeed > actualInterfaceSpeed) {
+ verificationReport.setActualInterfaceSpeed(actualInterfaceSpeed);
}
- if (nodeRepoHardwareInfo.isIpv6Connection() != actualHardware.isIpv6Connection()) {
- specReportMetrics.setActualIpv6Connection(actualHardware.isIpv6Connection());
- specReportMetrics.setExpectedIpv6Connection(nodeRepoHardwareInfo.isIpv6Connection());
+ if (nodeRepoHardwareInfo.isIpv6Connection() && !actualHardware.isIpv6Connection()) {
+ verificationReport.setActualIpv6Connection(actualHardware.isIpv6Connection());
}
- private static boolean compareCPU(HardwareInfo nodeRepoHardwareInfo, HardwareInfo actualHardware, SpecReportDimensions specReportDimensions) {
- boolean equalCPU = nodeRepoHardwareInfo.getMinCpuCores() == actualHardware.getMinCpuCores();
- specReportDimensions.setCpuCoresMatch(equalCPU);
- return equalCPU;
- }
-
- private static boolean compareMemory(HardwareInfo nodeRepoHardwareInfo, HardwareInfo actualHardware, SpecReportDimensions specReportDimensions) {
- boolean equalMemory = insideThreshold(nodeRepoHardwareInfo.getMinMainMemoryAvailableGb(), actualHardware.getMinMainMemoryAvailableGb(), PERCENTAGE_THRESHOLD);
- specReportDimensions.setMemoryMatch(equalMemory);
- return equalMemory;
- }
-
- private static boolean compareNetInterface(HardwareInfo nodeRepoHardwareInfo, HardwareInfo actualHardware, SpecReportDimensions specReportDimensions) {
- boolean equalNetInterfaceSpeed = nodeRepoHardwareInfo.getInterfaceSpeedMbs() <= actualHardware.getInterfaceSpeedMbs();
- boolean equalIpv6Interface = !nodeRepoHardwareInfo.getIpv6Interface() || actualHardware.getIpv6Interface();
- boolean equalIpv4Interface = !nodeRepoHardwareInfo.getIpv4Interface() || actualHardware.getIpv4Interface();
- boolean equalIpv6Connection = !nodeRepoHardwareInfo.isIpv6Connection() || actualHardware.isIpv6Connection();
- specReportDimensions.setNetInterfaceSpeedMatch(equalNetInterfaceSpeed);
- specReportDimensions.setIpv6Match(equalIpv6Interface);
- specReportDimensions.setIpv4Match(equalIpv4Interface);
- return equalIpv4Interface && equalIpv6Connection && equalNetInterfaceSpeed && equalIpv6Interface;
- }
-
- private static boolean compareDisk(HardwareInfo nodeRepoHardwareInfo, HardwareInfo actualHardware, SpecReportDimensions specReportDimensions) {
- boolean equalDiskType = nodeRepoHardwareInfo.getDiskType() == actualHardware.getDiskType();
- boolean equalDiskSize = insideThreshold(nodeRepoHardwareInfo.getMinDiskAvailableGb(), actualHardware.getMinDiskAvailableGb(), PERCENTAGE_THRESHOLD);
- specReportDimensions.setDiskTypeMatch(equalDiskType);
- specReportDimensions.setDiskAvailableMatch(equalDiskSize);
- return equalDiskType && equalDiskSize;
- }
-
- private static boolean outsideThreshold(double value1, double value2 , double thresholdPercentage) {
+ private static boolean insideThreshold(double value1, double value2 , double thresholdPercentage) {
double lowerThresholdPercentage = 1 - thresholdPercentage;
double upperThresholdPercentage = 1 + thresholdPercentage;
return value1 < lowerThresholdPercentage * value2 || value1 > upperThresholdPercentage * value2;
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 8789fa53d4f..bf5469f3a7c 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
@@ -36,9 +36,9 @@ public class SpecVerifier {
}
VerifierSettings verifierSettings = new VerifierSettings(nodeRepoJsonModel);
HardwareInfo actualHardware = HardwareInfoRetriever.retrieve(commandExecutor, verifierSettings);
- YamasSpecReport yamasSpecReport = makeYamasSpecReport(actualHardware, nodeRepoJsonModel);
- printResults(yamasSpecReport);
- return yamasSpecReport.getMetrics().isMatch();
+ VerificationReport verificationReport = makeVerificationReport(actualHardware, nodeRepoJsonModel);
+ printResults(verificationReport);
+ return isValidSpec(verificationReport);
}
private static boolean isValidSpec(VerificationReport verificationReport) throws JsonProcessingException {
@@ -59,7 +59,7 @@ public class SpecVerifier {
}
private static void printResults(VerificationReport verificationReport) {
- //TODO: Instead of println, report JSON to node repo
+ //TODO: Instead of println, report JSON to YAMAS
ObjectMapper om = new ObjectMapper();
try {
System.out.println(om.writeValueAsString(verificationReport));
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 f219546cd31..2ff2e41d9bc 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
@@ -9,23 +9,23 @@ import com.yahoo.vespa.hosted.node.verification.spec.noderepo.NodeRepoJsonModel;
public class VerifierSettings {
- private final boolean ipv6;
+ private final boolean checkIPv6;
public VerifierSettings(){
- this.ipv6 = true;
+ this.checkIPv6 = true;
}
public VerifierSettings(NodeRepoJsonModel nodeRepoJsonModel){
if (nodeRepoJsonModel.getIpv6Address() != null){
- ipv6 = true;
+ checkIPv6 = true;
}
else {
- ipv6 = false;
+ checkIPv6 = false;
}
}
- public boolean isIpv6() {
- return ipv6;
+ public boolean isCheckIPv6() {
+ return checkIPv6;
}
}
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/spec/report/VerificationReport.java
index ede4b0fc73a..66ac99dd065 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/spec/report/VerificationReport.java
@@ -4,12 +4,6 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.yahoo.vespa.hosted.node.verification.spec.retrievers.HardwareInfo;
-
-/**
- * Stores results of caomparing node repo spec and actual hardware info.
- * In case of divergent values, set the corresponding attribute to the actual hardware info value.
- * Attributes of equal value remain null.
- */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class VerificationReport {
diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/NetRetriever.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/NetRetriever.java
index 33b9ba722e7..85bd585d595 100644
--- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/NetRetriever.java
+++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/NetRetriever.java
@@ -50,7 +50,7 @@ public class NetRetriever implements HardwareRetriever {
public void updateInfo() {
ArrayList<ParseResult> parseResults = findInterface();
findInterfaceSpeed(parseResults);
- if (verifierSettings.isIpv6()) {
+ if (verifierSettings.isCheckIPv6()) {
testPingResponse(parseResults);
}
updateHardwareInfoWithNet(parseResults);
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 58af3dcebd0..6d6708f938f 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
@@ -49,7 +49,7 @@ public class SpecVerifierTest {
@Test
public void verifySpec_equal_nodeRepoInfo_and_hardware_should_return_true() throws Exception {
- ArrayList<URL> nodeInfoUrls = new ArrayList(Arrays.asList(new URL(URL_RESOURCE_PATH + "/nodeRepo.json")));
+ nodeInfoUrls.add(new URL(URL_RESOURCE_PATH + "/nodeRepo.json"));
mockCommandExecutor.addCommand("cat " + CPU_INFO_PATH);
mockCommandExecutor.addCommand("cat " + MEMORY_INFO_PATH);
mockCommandExecutor.addCommand("cat " + FAST_DISK_TYPE_INFO_PATH);
@@ -62,13 +62,13 @@ public class SpecVerifierTest {
@Test
public void verifySpec_environment_is_virtual_machine_should_return_true() throws Exception {
- ArrayList<URL> nodeInfoUrls = new ArrayList(Arrays.asList(new URL(URL_RESOURCE_PATH + "/nodeRepoVirtualMachine.json")));
+ nodeInfoUrls.add(new URL(URL_RESOURCE_PATH + "/nodeRepoVirtualMachine.json"));
assertTrue(SpecVerifier.verifySpec(mockCommandExecutor, nodeInfoUrls));
}
@Test
public void verifySpec_unequal_nodeRepoInfo_and_hardware_should_return_false() throws Exception {
- ArrayList<URL> nodeInfoUrls = new ArrayList(Arrays.asList(new URL(URL_RESOURCE_PATH + "/nodeRepo.json")));
+ nodeInfoUrls.add(new URL(URL_RESOURCE_PATH + "/nodeRepo.json"));
mockCommandExecutor.addCommand("cat " + CPU_INFO_PATH);
mockCommandExecutor.addCommand("cat " + MEMORY_INFO_PATH);
mockCommandExecutor.addCommand("cat " + NON_FAST_DISK_TYPE_INFO_PATH);
@@ -101,7 +101,7 @@ public class SpecVerifierTest {
@Test
public void getNodeRepositoryJSON_should_return_valid_nodeRepoJSONModel() throws Exception {
- ArrayList<URL> nodeInfoUrls = new ArrayList(Arrays.asList(new URL(URL_RESOURCE_PATH + "/nodeRepo.json")));
+ nodeInfoUrls.add(new URL(URL_RESOURCE_PATH + "/nodeRepo.json"));
NodeRepoJsonModel actualNodeRepoJsonModel = SpecVerifier.getNodeRepositoryJSON(nodeInfoUrls);
double expectedMinCpuCores = 4D;
double expectedMinMainMemoryAvailableGb = 4.04D;
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/VerificationReportTest.java
index 2f7bc75af75..b061966d445 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/VerificationReportTest.java
@@ -11,30 +11,23 @@ import static org.junit.Assert.*;
public class VerificationReportTest {
private VerificationReport verificationReport;
- private static final String REPORT_PATH = "src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/reportJSON";
+ private static final String YAMAS_REPORT_PATH = "src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/reportJSON";
+
@Before
public void setup() {
verificationReport = new VerificationReport();
- }
-
- @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);
- 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"});
- String expectedJson = MockCommandExecutor.readFromFile(REPORT_PATH).get(0);
+ }
+
+ @Test
+ public void Json_is_in_wanted_format() throws Exception {
+
+ String expectedJson = MockCommandExecutor.readFromFile(YAMAS_REPORT_PATH).get(0);
ObjectMapper om = new ObjectMapper();
String actualJson = om.writeValueAsString(verificationReport);
assertEquals(expectedJson, actualJson);
diff --git a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/reportJSON b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/reportJSON
index 9b874f1be68..c9e07ddcaa9 100644
--- a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/reportJSON
+++ b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/reportJSON
@@ -1 +1 @@
-{"actualMemoryAvailable":123.0,"actualDiskType":"FAST","actualDiskSpaceAvailable":500.0,"actualInterfaceSpeed":100.0,"actualcpuCores":4,"faultyIpAddresses":["2001:4998:44:505d:0:0:0:2618"]} \ No newline at end of file
+{"actualMemoryAvailable":123.0,"actualDiskType":"FAST","actualDiskSpaceAvailable":500.0,"actualInterfaceSpeed":100.0,"actualcpuCores":4} \ No newline at end of file
diff --git a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/HardwareInfoRetrieverTest.java b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/HardwareInfoRetrieverTest.java
index 65bf93a9ac6..c068ca83de9 100644
--- a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/HardwareInfoRetrieverTest.java
+++ b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/HardwareInfoRetrieverTest.java
@@ -49,7 +49,7 @@ public class HardwareInfoRetrieverTest {
@Test
public void retriever_should_return_valid_HardwareInfo() {
- doReturn(true).when(verifierSettings).isIpv6();
+ doReturn(true).when(verifierSettings).isCheckIPv6();
HardwareInfo actualHardwareInfo = HardwareInfoRetriever.retrieve(mockCommandExecutor, verifierSettings);
assertEquals(expectedHardwareInfo.getMinDiskAvailableGb(), actualHardwareInfo.getMinDiskAvailableGb(), DELTA);
assertEquals(expectedHardwareInfo.getMinMainMemoryAvailableGb(), actualHardwareInfo.getMinMainMemoryAvailableGb(), DELTA);
diff --git a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/NetRetrieverTest.java b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/NetRetrieverTest.java
index 9e670519294..365e2f2f9d4 100644
--- a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/NetRetrieverTest.java
+++ b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/NetRetrieverTest.java
@@ -39,7 +39,7 @@ public class NetRetrieverTest {
public void setup() {
hardwareInfo = new HardwareInfo();
commandExecutor = new MockCommandExecutor();
- doReturn(true).when(verifierSettings).isIpv6();
+ doReturn(true).when(verifierSettings).isCheckIPv6();
net = new NetRetriever(hardwareInfo, commandExecutor, verifierSettings);
parseResults = new ArrayList<>();
}