summaryrefslogtreecommitdiffstats
path: root/node-maintainer
diff options
context:
space:
mode:
authorOla Aunrønning <olaa@yahoo-inc.com>2017-08-10 13:26:59 +0200
committerOla Aunrønning <olaa@yahoo-inc.com>2017-08-15 12:29:45 +0200
commit4c22842dc0a49bc6abef62966a6540bc011fcc38 (patch)
tree6a594d6d40f68a2de68cbec7ee33b1a7d3e78c70 /node-maintainer
parent42e01bd7f70dd7267d3ec4e1d0f2f53fa563e463 (diff)
Now requires config server URL as parameter
Diffstat (limited to 'node-maintainer')
-rw-r--r--node-maintainer/README.md5
-rw-r--r--node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/HostURLGenerator.java27
-rw-r--r--node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/report/ReportSender.java2
-rw-r--r--node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/hardware/HardwareBenchmarker.java14
-rw-r--r--node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/README.md3
-rw-r--r--node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/SpecVerifier.java11
-rw-r--r--node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/HostURLGeneratorTest.java23
-rw-r--r--node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/report/ReportSenderTest.java6
-rw-r--r--node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/nodeHostNameOutput1
9 files changed, 35 insertions, 57 deletions
diff --git a/node-maintainer/README.md b/node-maintainer/README.md
index eb7ec53bdaf..7743df2b0c2 100644
--- a/node-maintainer/README.md
+++ b/node-maintainer/README.md
@@ -8,15 +8,12 @@ Node verification for both hardware and spec. Hardware is verified by performing
while spec is verified by comparing information reported by the OS with the spec from node repository.
### Execute examples
-Spec verification and hardware benchmarks can both be executed with and without config server host name as parameter
-(if called without parameters it will use yinst to retrieve the host name):
+Spec verification and hardware benchmarks must be executed with config server host name as parameter
SpecVerifier:
-- sudo java -cp node-maintainer-jar-with-dependencies.jar com.yahoo.vespa.hosted.node.verification.spec.SpecVerifier
- sudo java -cp node-maintainer-jar-with-dependencies.jar com.yahoo.vespa.hosted.node.verification.spec.SpecVerifier cfg.1.hostname,cfg.2.hostname,...
HardwareBenchmarker:
-- sudo java -cp node-maintainer-jar-with-dependencies.jar com.yahoo.vespa.hosted.node.verification.hardware.HardwareBenchmarker
- sudo java -cp node-maintainer-jar-with-dependencies.jar com.yahoo.vespa.hosted.node.verification.hardware.HardwareBenchmarker cfg.1.hostname,cfg.2.hostname,...
Both programs have README explaining closer what it does. \ No newline at end of file
diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/HostURLGenerator.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/HostURLGenerator.java
index 42ac9cd4a45..005dd799586 100644
--- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/HostURLGenerator.java
+++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/HostURLGenerator.java
@@ -15,22 +15,10 @@ public class HostURLGenerator {
private static final String NODE_HOSTNAME_PREFIX = "/nodes/v2/node/";
private static final String PORT_NUMBER = ":4080";
- private static final String CONFIG_SERVER_HOST_NAME_COMMAND = "yinst set | grep cfg";
private static final String HTTP = "http://";
- private static final String PARSE_OUT_HOSTNAMES_REGEX = "\\s+";
private static final String PARSE_ALL_HOSTNAMES_REGEX = ",";
private static final String PROTOCOL_REGEX = "^(https?|file)://.*$";
- public static ArrayList<URL> generateNodeInfoUrl(CommandExecutor commandExecutor) throws IOException {
- String[] configServerHostNames = getConfigServerHostNames(commandExecutor);
- String nodeHostName = generateNodeHostName(commandExecutor);
- ArrayList<URL> nodeInfoUrls = new ArrayList<>();
- for (String configServerHostName : configServerHostNames) {
- nodeInfoUrls.add(buildNodeInfoURL(configServerHostName, nodeHostName));
- }
- return nodeInfoUrls;
- }
-
public static ArrayList<URL> generateNodeInfoUrl(CommandExecutor commandExecutor, String commaSeparatedUrls) throws IOException {
ArrayList<URL> nodeInfoUrls = new ArrayList<>();
String[] configServerHostNames = commaSeparatedUrls.split(PARSE_ALL_HOSTNAMES_REGEX);
@@ -41,21 +29,6 @@ public class HostURLGenerator {
return nodeInfoUrls;
}
- protected static String[] getConfigServerHostNames(CommandExecutor commandExecutor) throws IOException {
- ArrayList<String> output = commandExecutor.executeCommand(CONFIG_SERVER_HOST_NAME_COMMAND);
- if (output.size() != 1)
- throw new IOException("Expected one line return from the command: " + CONFIG_SERVER_HOST_NAME_COMMAND);
- String[] configServerHostNames = parseOutHostNames(output.get(0));
- return configServerHostNames;
- }
-
- private static String[] parseOutHostNames(String output) throws IOException {
- String[] outputSplit = output.trim().split(PARSE_OUT_HOSTNAMES_REGEX);
- if (outputSplit.length != 2) throw new IOException("Expected config server host names to have index 1");
- String[] configServerHostNames = outputSplit[1].split(PARSE_ALL_HOSTNAMES_REGEX);
- return configServerHostNames;
- }
-
protected static String generateNodeHostName(CommandExecutor commandExecutor) throws IOException {
String nodeHostName = getEnvironmentVariable(commandExecutor);
return nodeHostName;
diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/report/ReportSender.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/report/ReportSender.java
index 2dbb1ab7d9f..d123b5abcac 100644
--- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/report/ReportSender.java
+++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/report/ReportSender.java
@@ -18,7 +18,7 @@ public class ReportSender {
report = "{\"hardwareDivergence\": null}";
}
else {
- report = "{\"hardwareDivergence\": \"" + om.writeValueAsString(hardwareDivergenceReport) + "\"}";
+ report = "{\"hardwareDivergence\": " + om.writeValueAsString(hardwareDivergenceReport) + "}";
}
System.out.print(report);
}
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 d33b4100084..d9f6c6f06e2 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
@@ -14,12 +14,16 @@ import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.logging.Level;
+import java.util.logging.Logger;
/**
* Benchmarks different hardware components and creates report
*/
public class HardwareBenchmarker {
+ private static final Logger logger = Logger.getLogger(HardwareBenchmarker.class.getName());
+
public static boolean hardwareBenchmarks(CommandExecutor commandExecutor, ArrayList<URL> nodeInfoUrls) throws IOException {
BenchmarkResults benchmarkResults = new BenchmarkResults();
ArrayList<Benchmark> benchmarks = new ArrayList<>(Arrays.asList(
@@ -38,11 +42,15 @@ public class HardwareBenchmarker {
CommandExecutor commandExecutor = new CommandExecutor();
ArrayList<URL> nodeInfoUrls;
if (args.length == 0) {
- nodeInfoUrls = HostURLGenerator.generateNodeInfoUrl(commandExecutor);
- } else {
+ throw new IllegalStateException("Expected config server URL as parameter");
+ }
+ try {
nodeInfoUrls = HostURLGenerator.generateNodeInfoUrl(commandExecutor, args[0]);
+ HardwareBenchmarker.hardwareBenchmarks(commandExecutor, nodeInfoUrls);
+ } catch (IOException e) {
+ logger.log(Level.WARNING, e.getMessage());
}
- HardwareBenchmarker.hardwareBenchmarks(commandExecutor, nodeInfoUrls);
+
}
}
diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/README.md b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/README.md
index d335c0310a0..ff87c7358f1 100644
--- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/README.md
+++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/spec/README.md
@@ -4,8 +4,7 @@ Verifies that the spec information in node repo coincides with what found on the
## Code "walkthrough"
The main class SpecVerifier uses the "noderepo" package in "commons" to retrieve node spec from node repo.
-It can be called with one parameter, the config server hostname, or with none (it will in this case use yinst to
-retrieve config server host name). It finds hostname using "HostURLGenerator" in the "commons" package.
+It must be called with one parameter, the config server hostname. It finds hostname using "HostURLGenerator" in the "commons" package.
It then retrieves all the hardware information at the node with the "retrievers" package and stores the values as a
"HardwareInfo" object.
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 cbabe2224ca..4756929bc79 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
@@ -52,15 +52,18 @@ public class SpecVerifier {
return nodeRepoJsonModel;
}
- public static void main(String[] args) throws IOException {
+ public static void main(String[] args) {
CommandExecutor commandExecutor = new CommandExecutor();
ArrayList<URL> nodeInfoUrls;
if (args.length == 0) {
- nodeInfoUrls = HostURLGenerator.generateNodeInfoUrl(commandExecutor);
- } else {
+ throw new IllegalStateException("Expected config server URL as parameter");
+ }
+ try {
nodeInfoUrls = HostURLGenerator.generateNodeInfoUrl(commandExecutor, args[0]);
+ SpecVerifier.verifySpec(commandExecutor, nodeInfoUrls);
+ } catch (IOException e) {
+ logger.log(Level.WARNING, e.getMessage());
}
- SpecVerifier.verifySpec(commandExecutor, nodeInfoUrls);
}
}
diff --git a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/HostURLGeneratorTest.java b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/HostURLGeneratorTest.java
index 8fe1e20b63e..428f6c0b738 100644
--- a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/HostURLGeneratorTest.java
+++ b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/HostURLGeneratorTest.java
@@ -1,13 +1,13 @@
package com.yahoo.vespa.hosted.node.verification.commons;
import com.yahoo.vespa.hosted.node.verification.mock.MockCommandExecutor;
-import com.yahoo.vespa.hosted.node.verification.commons.HostURLGenerator;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.stream.Collectors;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
@@ -19,9 +19,9 @@ public class HostURLGeneratorTest {
private MockCommandExecutor mockCommandExecutor;
private static final String CAT_NODE_HOST_NAME_PATH = "cat src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/hostURLGeneratorTest";
- private static final String CAT_CONFIG_SERVER_HOST_NAME_PATH = "cat src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/nodeHostNameOutput";
private static final String CAT_WRONG_HOSTNAME_PATH = "cat src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/hostURLGeneratorExceptionTest";
- private static final String CONFIG_SERVER_HOSTNAME = "http://cfg1.prod.region1:4080";
+ private static final String CONFIG_SERVER_HOSTNAME_1 = "http://cfg1.prod.region1:4080";
+ private static final String CONFIG_SERVER_HOSTNAME_2 = "http://cfg2.prod.region1:4080";
private static final String NODE_HOSTNAME_PREFIX = "/nodes/v2/node/";
private static final String EXPECTED_HOSTNAME = "expected.hostname";
@@ -30,23 +30,22 @@ public class HostURLGeneratorTest {
mockCommandExecutor = new MockCommandExecutor();
}
+
@Test
public void generateNodeInfoUrl_find_config_server_test_if_url_is_formatted_correctly() throws Exception {
- mockCommandExecutor.addCommand(CAT_CONFIG_SERVER_HOST_NAME_PATH);
mockCommandExecutor.addCommand(CAT_NODE_HOST_NAME_PATH);
- ArrayList<URL> url = HostURLGenerator.generateNodeInfoUrl(mockCommandExecutor);
- String expectedUrl = CONFIG_SERVER_HOSTNAME + NODE_HOSTNAME_PREFIX + EXPECTED_HOSTNAME;
- String actualUrl = url.get(0).toString();
- assertEquals(expectedUrl, actualUrl);
-
+ ArrayList<URL> urls = HostURLGenerator.generateNodeInfoUrl(mockCommandExecutor, CONFIG_SERVER_HOSTNAME_1 + "," + CONFIG_SERVER_HOSTNAME_2);
+ String expectedUrl1 = CONFIG_SERVER_HOSTNAME_1 + NODE_HOSTNAME_PREFIX + EXPECTED_HOSTNAME;
+ String expectedUrl2 = CONFIG_SERVER_HOSTNAME_2 + NODE_HOSTNAME_PREFIX + EXPECTED_HOSTNAME;
+ assertEquals(expectedUrl1, urls.get(0).toString());
+ assertEquals(expectedUrl2, urls.get(1).toString());
}
@Test
public void generateNodeInfoURL_expected_IOException() {
try {
- mockCommandExecutor.addCommand(CAT_CONFIG_SERVER_HOST_NAME_PATH);
mockCommandExecutor.addCommand(CAT_WRONG_HOSTNAME_PATH);
- HostURLGenerator.generateNodeInfoUrl(mockCommandExecutor);
+ HostURLGenerator.generateNodeInfoUrl(mockCommandExecutor, CONFIG_SERVER_HOSTNAME_1);
fail("Expected an IOException to be thrown");
} catch (IOException e) {
String expectedExceptionMessage = "Unexpected output from \"hostname\" command.";
@@ -59,7 +58,7 @@ public class HostURLGeneratorTest {
mockCommandExecutor.addCommand(CAT_NODE_HOST_NAME_PATH);
String configServerHostname = "cfg1.prod.region1";
ArrayList<URL> actualUrls = HostURLGenerator.generateNodeInfoUrl(mockCommandExecutor, configServerHostname);
- String expectedUrl = CONFIG_SERVER_HOSTNAME + NODE_HOSTNAME_PREFIX + EXPECTED_HOSTNAME;
+ String expectedUrl = CONFIG_SERVER_HOSTNAME_1 + NODE_HOSTNAME_PREFIX + EXPECTED_HOSTNAME;
String actualUrl = actualUrls.get(0).toString();
assertEquals(expectedUrl, actualUrl);
}
diff --git a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/report/ReportSenderTest.java b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/report/ReportSenderTest.java
index 81c7dcd1291..1d0999f9463 100644
--- a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/report/ReportSenderTest.java
+++ b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/report/ReportSenderTest.java
@@ -12,7 +12,7 @@ import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
public class ReportSenderTest {
@@ -41,7 +41,7 @@ public class ReportSenderTest {
double memoryReadSpeedGBs = 0.1;
benchmarkReport.setCpuCyclesPerSec(cpuCyclesPerSec);
benchmarkReport.setMemoryReadSpeedGBs(memoryReadSpeedGBs);
- String expectedReport = "{\"hardwareDivergence\": \"{\"benchmarkReport\":{\"cpuCyclesPerSec\":0.3,\"memoryReadSpeedGBs\":0.1}}\"}";
+ String expectedReport = "{\"hardwareDivergence\": {\"benchmarkReport\":{\"cpuCyclesPerSec\":0.3,\"memoryReadSpeedGBs\":0.1}}}";
ReportSender.reportBenchmarkResults(benchmarkReport,nodeInfoUrls);
assertEquals(expectedReport, println.toString());
}
@@ -61,7 +61,7 @@ public class ReportSenderTest {
boolean actualIpv6Connection = false;
specVerificationReport.setActualDiskSpaceAvailable(actualDiskSpaceAvailable);
specVerificationReport.setActualIpv6Connection(actualIpv6Connection);
- String expectedReport = "{\"hardwareDivergence\": \"{\"specVerificationReport\":{\"actualDiskSpaceAvailable\":150.0,\"actualIpv6Connection\":false},\"benchmarkReport\":{\"cpuCyclesPerSec\":0.5}}\"}";
+ String expectedReport = "{\"hardwareDivergence\": {\"specVerificationReport\":{\"actualDiskSpaceAvailable\":150.0,\"actualIpv6Connection\":false},\"benchmarkReport\":{\"cpuCyclesPerSec\":0.5}}}";
ReportSender.reportSpecVerificationResults(specVerificationReport, nodeInfoUrls);
assertEquals(expectedReport, println.toString());
}
diff --git a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/nodeHostNameOutput b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/nodeHostNameOutput
deleted file mode 100644
index 4f8a4910690..00000000000
--- a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/nodeHostNameOutput
+++ /dev/null
@@ -1 +0,0 @@
-services.addr_configserver: cfg1.prod.region1,cfg2.prod.region1,cfg3.prod.region1 \ No newline at end of file