summaryrefslogtreecommitdiffstats
path: root/node-maintainer
diff options
context:
space:
mode:
authorValerij Fredriksen <valerijf@oath.com>2018-01-17 13:29:05 +0100
committerValerij Fredriksen <valerijf@oath.com>2018-01-17 13:29:05 +0100
commit8edad6876016efc7cffa619198c0ce46e3761916 (patch)
tree5187e07ee9fa24c0b6ef4de81b4f38345f4c98f1 /node-maintainer
parentf04d13f6ade7b7744ad08a262529b76b936a7d9f (diff)
Remove unused classes and their tests
Diffstat (limited to 'node-maintainer')
-rw-r--r--node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/HostURLGenerator.java54
-rw-r--r--node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeRepoInfoRetriever.java37
-rw-r--r--node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/report/Reporter.java62
-rw-r--r--node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/HostURLGeneratorTest.java88
-rw-r--r--node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeJsonConverterTest.java44
-rw-r--r--node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeRepoInfoRetrieverTest.java68
-rw-r--r--node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/report/BenchmarkReportTest.java33
-rw-r--r--node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/report/ReporterTest.java104
-rw-r--r--node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/report/SpecVerificationReportTest.java49
9 files changed, 0 insertions, 539 deletions
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
deleted file mode 100644
index 7e8b198428f..00000000000
--- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/HostURLGenerator.java
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.hosted.node.verification.commons;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Makes the URL used to retrieve the JSON from the node repository with information about the node's spec.
- *
- * @author olaaun
- * @author sgrostad
- */
-public class HostURLGenerator {
-
- private static final String NODE_HOSTNAME_PREFIX = "/nodes/v2/node/";
- private static final String PORT_NUMBER = ":4080";
- private static final String HTTP = "http://";
- private static final String PARSE_ALL_HOSTNAMES_REGEX = ",";
- private static final String PROTOCOL_REGEX = "^(https?|file)://.*$";
-
- public static List<URL> generateNodeInfoUrl(CommandExecutor commandExecutor, String commaSeparatedUrls) throws IOException {
- List<URL> nodeInfoUrls = new ArrayList<>();
- String[] configServerHostNames = commaSeparatedUrls.split(PARSE_ALL_HOSTNAMES_REGEX);
- String nodeHostName = generateNodeHostName(commandExecutor);
- for (String configServerHostName : configServerHostNames) {
- nodeInfoUrls.add(buildNodeInfoURL(configServerHostName, nodeHostName));
- }
- return nodeInfoUrls;
- }
-
- protected static String generateNodeHostName(CommandExecutor commandExecutor) throws IOException {
- String nodeHostName = getEnvironmentVariable(commandExecutor);
- return nodeHostName;
- }
-
- protected static String getEnvironmentVariable(CommandExecutor commandExecutor) throws IOException {
- List<String> output = commandExecutor.executeCommand("hostname");
- if (output.size() == 1) {
- return output.get(0);
- }
- throw new IOException("Unexpected output from \"hostname\" command.");
- }
-
- protected static URL buildNodeInfoURL(String configServerHostName, String nodeHostName) throws MalformedURLException {
- if (configServerHostName.matches(PROTOCOL_REGEX)) {
- return new URL(configServerHostName + NODE_HOSTNAME_PREFIX + nodeHostName);
- }
- return new URL(HTTP + configServerHostName + PORT_NUMBER + NODE_HOSTNAME_PREFIX + nodeHostName);
- }
-
-}
diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeRepoInfoRetriever.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeRepoInfoRetriever.java
deleted file mode 100644
index e2daf9014d4..00000000000
--- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeRepoInfoRetriever.java
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.hosted.node.verification.commons.noderepo;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Parse JSON from node repository and stores information as a NodeSpec object.
- *
- * @author olaaun
- * @author sgrostad
- */
-public class NodeRepoInfoRetriever {
-
- private static final Logger logger = Logger.getLogger(NodeRepoInfoRetriever.class.getName());
-
- public static NodeSpec retrieve(List<URL> nodeInfoUrls) throws IOException {
- NodeSpec nodeSpec;
- ObjectMapper objectMapper = new ObjectMapper();
- for (URL nodeInfoURL : nodeInfoUrls) {
- try {
- nodeSpec = objectMapper.readValue(nodeInfoURL, NodeSpec.class);
- return nodeSpec;
- } catch (IOException e) {
- logger.log(Level.WARNING, "Failed to parse JSON from config server: " + nodeInfoURL.toString(), e);
- }
- }
- throw new IOException("Failed to parse JSON from all possible config servers.");
- }
-
-}
-
diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/report/Reporter.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/report/Reporter.java
deleted file mode 100644
index cc9dee38dea..00000000000
--- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/verification/commons/report/Reporter.java
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.hosted.node.verification.commons.report;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.yahoo.vespa.hosted.node.verification.commons.noderepo.NodeRepoInfoRetriever;
-import com.yahoo.vespa.hosted.node.verification.commons.noderepo.NodeSpec;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Responsible for printing hardware divergence report to standard out
- *
- * @author sgrostad
- * @author olaaun
- */
-public class Reporter {
-
- private static final Logger logger = Logger.getLogger(Reporter.class.getName());
-
- private static void printHardwareDivergenceReport(HardwareDivergenceReport hardwareDivergenceReport) throws IOException {
- ObjectMapper om = new ObjectMapper();
- String report;
- if (hardwareDivergenceReport.isHardwareDivergenceReportEmpty()) {
- report = "null";
- } else {
- report = om.writeValueAsString(hardwareDivergenceReport);
- }
- System.out.print(report);
- }
-
- public static void reportBenchmarkResults(BenchmarkReport benchmarkReport, List<URL> nodeInfoUrls) throws IOException {
- HardwareDivergenceReport hardwareDivergenceReport = generateHardwareDivergenceReport(nodeInfoUrls);
- hardwareDivergenceReport.setBenchmarkReport(benchmarkReport);
- printHardwareDivergenceReport(hardwareDivergenceReport);
- }
-
- public static void reportSpecVerificationResults(SpecVerificationReport specVerificationReport, List<URL> nodeInfoUrls) throws IOException {
- HardwareDivergenceReport hardwareDivergenceReport = generateHardwareDivergenceReport(nodeInfoUrls);
- hardwareDivergenceReport.setSpecVerificationReport(specVerificationReport);
- printHardwareDivergenceReport(hardwareDivergenceReport);
- }
-
- private static HardwareDivergenceReport generateHardwareDivergenceReport(List<URL> nodeInfoUrls) throws IOException {
- NodeSpec nodeSpec = NodeRepoInfoRetriever.retrieve(nodeInfoUrls);
- ObjectMapper om = new ObjectMapper();
- if (nodeSpec.getHardwareDivergence() == null || nodeSpec.getHardwareDivergence().equals("null")) {
- return new HardwareDivergenceReport();
- }
- try {
- HardwareDivergenceReport hardwareDivergenceReport = om.readValue(nodeSpec.getHardwareDivergence(), HardwareDivergenceReport.class);
- return hardwareDivergenceReport;
- } catch (IOException e) {
- logger.log(Level.WARNING, "Failed to parse hardware divergence report from node repo. Report:\n" + nodeSpec.getHardwareDivergence(), e.getMessage());
- return new HardwareDivergenceReport();
- }
- }
-
-}
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
deleted file mode 100644
index 773172de807..00000000000
--- a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/HostURLGeneratorTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.hosted.node.verification.commons;
-
-import com.yahoo.vespa.hosted.node.verification.mock.MockCommandExecutor;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.List;
-
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-/**
- * @author sgrostad
- * @author olaaun
- */
-
-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_WRONG_HOSTNAME_PATH = "cat src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/hostURLGeneratorExceptionTest";
- 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";
-
- @Before
- public void setup() {
- mockCommandExecutor = new MockCommandExecutor();
- }
-
-
- @Test
- public void generateNodeInfoUrl_find_config_server_test_if_url_is_formatted_correctly() throws Exception {
- mockCommandExecutor.addCommand(CAT_NODE_HOST_NAME_PATH);
- List<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_WRONG_HOSTNAME_PATH);
- HostURLGenerator.generateNodeInfoUrl(mockCommandExecutor, CONFIG_SERVER_HOSTNAME_1);
- fail("Expected an IOException to be thrown");
- } catch (IOException e) {
- String expectedExceptionMessage = "Unexpected output from \"hostname\" command.";
- assertEquals(expectedExceptionMessage, e.getMessage());
- }
- }
-
- @Test
- public void generateNodeInfoUrl_retrieve_config_server_as_parameter_test_if_url_is_formatted_correctly() throws Exception {
- mockCommandExecutor.addCommand(CAT_NODE_HOST_NAME_PATH);
- String configServerHostname = "cfg1.prod.region1";
- List<URL> actualUrls = HostURLGenerator.generateNodeInfoUrl(mockCommandExecutor, configServerHostname);
- String expectedUrl = CONFIG_SERVER_HOSTNAME_1 + NODE_HOSTNAME_PREFIX + EXPECTED_HOSTNAME;
- String actualUrl = actualUrls.get(0).toString();
- assertEquals(expectedUrl, actualUrl);
- }
-
- @Test
- public void buildNodeInfoURL_should_add_protocol_and_port_in_front_when_protocol_is_absent() throws IOException {
- String configServerHostName = "www.yahoo.com";
- String nodeHostName = "index.html";
- String nodeHostnamePrefix = "/nodes/v2/node/";
- String portNumber = ":4080";
- String expectedUrl = "http://" + configServerHostName + portNumber + nodeHostnamePrefix + nodeHostName;
- assertEquals(expectedUrl, HostURLGenerator.buildNodeInfoURL(configServerHostName, nodeHostName).toString());
- }
-
- @Test
- public void buildNodeInfoURL_should_not_add_protocol_and_port_in_front_when_protocol_already_exists() throws IOException {
- String configServerHostName = "http://www.yahoo.com";
- String nodeHostName = "index.html";
- String nodeHostnamePrefix = "/nodes/v2/node/";
- String expectedUrl = configServerHostName + nodeHostnamePrefix + nodeHostName;
- assertEquals(expectedUrl, HostURLGenerator.buildNodeInfoURL(configServerHostName, nodeHostName).toString());
- }
-
-}
diff --git a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeJsonConverterTest.java b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeJsonConverterTest.java
deleted file mode 100644
index 0f27aeee098..00000000000
--- a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeJsonConverterTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.hosted.node.verification.commons.noderepo;
-
-import com.yahoo.vespa.hosted.node.verification.spec.retrievers.HardwareInfo;
-import org.junit.Test;
-
-import java.io.File;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-/**
- * @author sgrostad
- * @author olaaun
- */
-
-public class NodeJsonConverterTest {
-
- private static final double DELTA = 0.1;
-
- @Test
- public void convertJsonModel_should_return_correct_HardwareInfo() throws Exception {
- List<URL> urls = new ArrayList<>(Arrays.asList(new File("src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/nodeInfoTest.json").toURI().toURL()));
- NodeSpec nodeSpec = NodeRepoInfoRetriever.retrieve(urls);
- HardwareInfo hardwareInfo = NodeJsonConverter.convertJsonModelToHardwareInfo(nodeSpec);
- double expectedMinDiskAvailable = 500.0;
- double expectedMinMainMemoryAvailable = 24.0;
- double expectedMinCpuCores = 24.0;
- double expectedInterfaceSpeedMbs = 1000;
- assertEquals(expectedMinDiskAvailable, hardwareInfo.getMinDiskAvailableGb(), DELTA);
- assertEquals(expectedMinMainMemoryAvailable, hardwareInfo.getMinMainMemoryAvailableGb(), DELTA);
- assertEquals(expectedMinCpuCores, hardwareInfo.getMinCpuCores(), DELTA);
- assertTrue(hardwareInfo.getIpv4Interface());
- assertFalse(hardwareInfo.getIpv6Interface());
- assertEquals(expectedInterfaceSpeedMbs, hardwareInfo.getInterfaceSpeedMbs(), DELTA);
- assertEquals(hardwareInfo.getDiskType(), HardwareInfo.DiskType.SLOW);
- }
-
-}
diff --git a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeRepoInfoRetrieverTest.java b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeRepoInfoRetrieverTest.java
deleted file mode 100644
index 1e1bd7e71d6..00000000000
--- a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/NodeRepoInfoRetrieverTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.hosted.node.verification.commons.noderepo;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-/**
- * @author sgrostad
- * @author olaaun
- */
-
-public class NodeRepoInfoRetrieverTest {
-
- private NodeRepoInfoRetriever nodeRepoInfoRetriever;
- private List<URL> urls;
- private static final double DELTA = 0.1;
- private static final String ABSOLUTE_PATH = Paths.get(".").toAbsolutePath().normalize().toString();
- private static final String RESOURCE_PATH = "src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources";
- private static final String URL_RESOURCE_PATH = "file://" + ABSOLUTE_PATH + "/" + RESOURCE_PATH;
-
- @Before
- public void setup() {
- nodeRepoInfoRetriever = new NodeRepoInfoRetriever();
- urls = new ArrayList<>();
- }
-
- @Test
- public void retrieve_should_return_nodeJSONModel_when_parameter_contains_valid_url() throws IOException {
- urls.add(new URL(URL_RESOURCE_PATH + "/nodeInfoTest.json"));
- NodeSpec nodeSpec = NodeRepoInfoRetriever.retrieve(urls);
- double expectedMinDiskAvailable = 500.0;
- double expectedMinMainMemoryAvailable = 24.0;
- double expectedMinCpuCores = 24.0;
- assertEquals(expectedMinDiskAvailable, nodeSpec.getMinDiskAvailableGb(), DELTA);
- assertEquals(expectedMinMainMemoryAvailable, nodeSpec.getMinMainMemoryAvailableGb(), DELTA);
- assertEquals(expectedMinCpuCores, nodeSpec.getMinCpuCores(), DELTA);
- }
-
- @Test
- public void retrieve_should_throw_IOException_when_no_valid_URLs() throws MalformedURLException {
- urls = new ArrayList<>();
- String exceptionMessage = "Failed to parse JSON from all possible config servers.";
- try {
- NodeRepoInfoRetriever.retrieve(urls);
- fail("Retrieve should have thrown IOException");
- } catch (IOException e) {
- assertEquals(exceptionMessage, e.getMessage());
- }
- urls.add(new URL("file:///dev/null"));
- try {
- NodeRepoInfoRetriever.retrieve(urls);
- fail("Retrieve should have thrown IOException");
- } catch (IOException e) {
- assertEquals(exceptionMessage, e.getMessage());
- }
- }
-
-}
diff --git a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/report/BenchmarkReportTest.java b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/report/BenchmarkReportTest.java
deleted file mode 100644
index 931b42bb2a0..00000000000
--- a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/report/BenchmarkReportTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.hosted.node.verification.commons.report;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * @author sgrostad
- * @author olaaun
- */
-
-public class BenchmarkReportTest {
-
- private BenchmarkReport benchmarkReport = new BenchmarkReport();
-
- @Test
- public void create_report_from_BenchmarkResults_should_create_correct_report() throws Exception {
- double expectedCpuCyclesPerSec = 4;
- double expectedDiskSpeedMbps = 120;
- double expectedMemoryReadSpeedGBs = 7.1;
- double expectedMemoryWriteSpeedGBs = 5.9;
- benchmarkReport.setCpuCyclesPerSec(expectedCpuCyclesPerSec);
- benchmarkReport.setDiskSpeedMbs(expectedDiskSpeedMbps);
- benchmarkReport.setMemoryReadSpeedGBs(expectedMemoryReadSpeedGBs);
- benchmarkReport.setMemoryWriteSpeedGBs(expectedMemoryWriteSpeedGBs);
- ObjectMapper om = new ObjectMapper();
- String expectedResultJson = "{\"cpuCyclesPerSec\":4.0,\"diskSpeedMbs\":120.0,\"memoryWriteSpeedGBs\":5.9,\"memoryReadSpeedGBs\":7.1}";
- assertEquals(expectedResultJson, om.writeValueAsString(benchmarkReport));
- }
-
-}
diff --git a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/report/ReporterTest.java b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/report/ReporterTest.java
deleted file mode 100644
index 5f469db7f53..00000000000
--- a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/report/ReporterTest.java
+++ /dev/null
@@ -1,104 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.hosted.node.verification.commons.report;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.net.URL;
-import java.nio.file.Paths;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Arrays;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * @author sgrostad
- * @author olaaun
- */
-
-public class ReporterTest {
-
- private final ByteArrayOutputStream println = new ByteArrayOutputStream();
- private static final String ABSOLUTE_PATH = Paths.get(".").toAbsolutePath().normalize().toString();
- private static final String RESOURCE_PATH_TO_VALID_HARDWARE_DIVERGENCE = "src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/nodeInfoTest.json";
- private static final String RESOURCE_PATH_TO_INVALID_HARDWARE_DIVERGENCE = "src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/nodeInfoNotInterpretableHardwareDivergence.json";
- private static final String RESOURCE_PATH_TO_EMPTY_HARDWARE_DIVERGENCE = "src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/nodeRepo.json";
- private static final String URL_VALID_RESOURCE_PATH = "file://" + ABSOLUTE_PATH + "/" + RESOURCE_PATH_TO_VALID_HARDWARE_DIVERGENCE;
- private static final String URL_INVALID_RESOURCE_PATH = "file://" + ABSOLUTE_PATH + "/" + RESOURCE_PATH_TO_INVALID_HARDWARE_DIVERGENCE;
- private static final String URL_EMPTY_RESOURCE_PATH = "file://" + ABSOLUTE_PATH + "/" + RESOURCE_PATH_TO_EMPTY_HARDWARE_DIVERGENCE;
- private static List<URL> nodeInfoUrlsToValidHardwareDivergence;
- private static List<URL> nodeInfoUrlsToNOTValidHardwareDivergence;
- private static List<URL> nodeInfoUrlsWithNoHardwareDivergence;
-
- @Before
- public void setup() throws IOException {
- System.setOut(new PrintStream(println));
- URL nodeInfoUrlWithAlreadyExistingHardwareDivergence = new URL(URL_VALID_RESOURCE_PATH);
- nodeInfoUrlsToValidHardwareDivergence = new ArrayList<>(Arrays.asList(nodeInfoUrlWithAlreadyExistingHardwareDivergence));
- URL nodeInfoUrlWithExistingButWrongHardwareDivergence = new URL(URL_INVALID_RESOURCE_PATH);
- nodeInfoUrlsToNOTValidHardwareDivergence = new ArrayList<>(Arrays.asList(nodeInfoUrlWithExistingButWrongHardwareDivergence));
- URL nodeInfoUrlWithNoHardwareDivergence = new URL(URL_EMPTY_RESOURCE_PATH);
- nodeInfoUrlsWithNoHardwareDivergence = new ArrayList<>(Arrays.asList(nodeInfoUrlWithNoHardwareDivergence));
- }
-
- @After
- public void cleanUpStream() {
- System.setOut(System.out);
- }
-
- @Test
- public void reportBenchmarkResults_should_update_already_existing_hardwareDivergence_changing_existing_values() throws Exception {
- BenchmarkReport benchmarkReport = new BenchmarkReport();
- double cpuCyclesPerSec = 0.3;
- double memoryReadSpeedGBs = 0.1;
- benchmarkReport.setCpuCyclesPerSec(cpuCyclesPerSec);
- benchmarkReport.setMemoryReadSpeedGBs(memoryReadSpeedGBs);
- String expectedReport = "{\"benchmarkReport\":{\"cpuCyclesPerSec\":0.3,\"memoryReadSpeedGBs\":0.1}}";
- Reporter.reportBenchmarkResults(benchmarkReport, nodeInfoUrlsToValidHardwareDivergence);
- assertEquals(expectedReport, println.toString());
- }
-
- @Test
- public void reportBenchmarkResults_should_should_update_already_existing_hardwareDivergence_prints_null_when_empty_benchmarkReport() throws Exception {
- BenchmarkReport benchmarkReport = new BenchmarkReport();
- String expectedReport = "null";
- Reporter.reportBenchmarkResults(benchmarkReport, nodeInfoUrlsToValidHardwareDivergence);
- assertEquals(expectedReport, println.toString());
- }
-
- @Test
- public void reportSpecVerificationResults_should_update_already_existing_hardwareDivergence_adding_report_type() throws Exception {
- SpecVerificationReport specVerificationReport = new SpecVerificationReport();
- double actualDiskSpaceAvailable = 150D;
- boolean actualIpv6Connection = false;
- specVerificationReport.setActualDiskSpaceAvailable(actualDiskSpaceAvailable);
- specVerificationReport.setActualIpv6Connection(actualIpv6Connection);
- String expectedReport = "{\"specVerificationReport\":{\"actualDiskSpaceAvailable\":150.0,\"actualIpv6Connection\":false},\"benchmarkReport\":{\"cpuCyclesPerSec\":0.5}}";
- Reporter.reportSpecVerificationResults(specVerificationReport, nodeInfoUrlsToValidHardwareDivergence);
- assertEquals(expectedReport, println.toString());
- }
-
- @Test
- public void reportSpecVerificationResults_make_new_correct_hardwareDivergence_because_old_is_wrong() throws Exception {
- SpecVerificationReport specVerificationReport = new SpecVerificationReport();
- double actualDiskSpaceAvailable = 150D;
- specVerificationReport.setActualDiskSpaceAvailable(actualDiskSpaceAvailable);
- String expectedReport = "{\"specVerificationReport\":{\"actualDiskSpaceAvailable\":150.0}}";
- Reporter.reportSpecVerificationResults(specVerificationReport, nodeInfoUrlsToNOTValidHardwareDivergence);
- assertEquals(expectedReport, println.toString());
- }
-
- @Test
- public void reportSpecVerificationResults_make_new_empty_hardwareDivergence_because_there_is_no_old() throws Exception {
- SpecVerificationReport specVerificationReport = new SpecVerificationReport();
- String expectedReport = "null";
- Reporter.reportSpecVerificationResults(specVerificationReport, nodeInfoUrlsWithNoHardwareDivergence);
- assertEquals(expectedReport, println.toString());
- }
-
-} \ No newline at end of file
diff --git a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/report/SpecVerificationReportTest.java b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/report/SpecVerificationReportTest.java
deleted file mode 100644
index 72629cc565d..00000000000
--- a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/report/SpecVerificationReportTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.hosted.node.verification.commons.report;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.yahoo.vespa.hosted.node.verification.mock.MockCommandExecutor;
-import com.yahoo.vespa.hosted.node.verification.spec.retrievers.HardwareInfo;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * @author sgrostad
- * @author olaaun
- */
-
-public class SpecVerificationReportTest {
-
- 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() {
- 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(specVerificationReport);
- assertEquals(expectedJson, actualJson);
- }
-
- @Test
- public void Json_is_in_wanted_format_when_all_specs_are_wrong() throws Exception {
- specVerificationReport.setActualInterfaceSpeed(100D);
- specVerificationReport.setActualDiskSpaceAvailable(500D);
- specVerificationReport.setActualDiskType(HardwareInfo.DiskType.FAST);
- specVerificationReport.setActualMemoryAvailable(123D);
- specVerificationReport.setActualcpuCores(4);
- specVerificationReport.setFaultyIpAddresses(new String[]{"2001:db8:0:1234:0:567:8:1"});
- String expectedJson = MockCommandExecutor.readFromFile(REPORT_PATH).get(0);
- ObjectMapper om = new ObjectMapper();
- String actualJson = om.writeValueAsString(specVerificationReport);
- assertEquals(expectedJson, actualJson);
- }
-
-}