diff options
Diffstat (limited to 'node-maintainer/src/test/java/com/yahoo')
26 files changed, 319 insertions, 141 deletions
diff --git a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/CommandExecutorTest.java b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/CommandExecutorTest.java index ce4156b5960..5f5aca825c0 100644 --- a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/CommandExecutorTest.java +++ b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/CommandExecutorTest.java @@ -5,15 +5,16 @@ import org.junit.Before; import org.junit.Test; import java.io.IOException; -import java.util.ArrayList; import java.util.List; import static java.util.Arrays.asList; import static org.junit.Assert.assertEquals; /** - * Created by sgrostad on 12/07/2017. + * @author sgrostad + * @author olaaun */ + public class CommandExecutorTest { private CommandExecutor commandExecutor; @@ -26,7 +27,7 @@ public class CommandExecutorTest { @Test public void test_if_executeAString_reads_testReadFile_correct() throws IOException { String command = "cat src/test/java/com/yahoo/vespa/hosted/node/verification/hardware/resources/testReadFile.txt"; - ArrayList<String> commandOutput = commandExecutor.executeCommand(command); + List<String> commandOutput = commandExecutor.executeCommand(command); List<String> expectedOutput = asList("This test file tests apache commons exec", "Second line"); assertEquals(expectedOutput, commandOutput); } 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 1519e4e52fa..773172de807 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 @@ -7,15 +7,17 @@ import org.junit.Test; import java.io.IOException; import java.net.URL; -import java.util.ArrayList; -import java.util.stream.Collectors; +import java.util.List; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; /** - * Created by olaa on 14/07/2017. + * @author sgrostad + * @author olaaun */ + public class HostURLGeneratorTest { private MockCommandExecutor mockCommandExecutor; @@ -35,7 +37,7 @@ public class HostURLGeneratorTest { @Test public void generateNodeInfoUrl_find_config_server_test_if_url_is_formatted_correctly() throws Exception { mockCommandExecutor.addCommand(CAT_NODE_HOST_NAME_PATH); - ArrayList<URL> urls = HostURLGenerator.generateNodeInfoUrl(mockCommandExecutor, CONFIG_SERVER_HOSTNAME_1 + "," + CONFIG_SERVER_HOSTNAME_2); + 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()); @@ -58,7 +60,7 @@ public class HostURLGeneratorTest { 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"; - ArrayList<URL> actualUrls = HostURLGenerator.generateNodeInfoUrl(mockCommandExecutor, configServerHostname); + 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); diff --git a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/IPAddressVerifierTest.java b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/IPAddressVerifierTest.java index d0b378af4b8..197b4836bc8 100644 --- a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/IPAddressVerifierTest.java +++ b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/noderepo/IPAddressVerifierTest.java @@ -14,6 +14,11 @@ import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.spy; +/** + * @author sgrostad + * @author olaaun + */ + public class IPAddressVerifierTest { private IPAddressVerifier ipAddressVerifier = spy(new IPAddressVerifier()); 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 index c23d29c4076..0940efd08d3 100644 --- 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 @@ -8,21 +8,24 @@ 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; /** - * Created by olaa on 07/07/2017. + * @author sgrostad + * @author olaaun */ + public class NodeJsonConverterTest { private static final double DELTA = 0.1; @Test public void convertJsonModel_should_return_correct_HardwareInfo() throws Exception { - ArrayList<URL> urls = new ArrayList<>(Arrays.asList(new File("src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/nodeInfoTest.json").toURI().toURL())); + List<URL> urls = new ArrayList<>(Arrays.asList(new File("src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/nodeInfoTest.json").toURI().toURL())); NodeRepoJsonModel nodeRepoJsonModel = NodeRepoInfoRetriever.retrieve(urls); HardwareInfo hardwareInfo = NodeJsonConverter.convertJsonModelToHardwareInfo(nodeRepoJsonModel); double expectedMinDiskAvailable = 500.0; 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 index 49792963a05..97bf3fdeb11 100644 --- 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 @@ -9,14 +9,20 @@ 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 ArrayList<URL> urls; + 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"; diff --git a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/parser/OutputParserTest.java b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/parser/OutputParserTest.java index dc43fcd2e47..09286f4e61a 100644 --- a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/parser/OutputParserTest.java +++ b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/parser/OutputParserTest.java @@ -1,20 +1,20 @@ // 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.parser; -import com.yahoo.vespa.hosted.node.verification.commons.parser.OutputParser; -import com.yahoo.vespa.hosted.node.verification.commons.parser.ParseInstructions; -import com.yahoo.vespa.hosted.node.verification.commons.parser.ParseResult; import org.junit.Before; import org.junit.Test; import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import static org.junit.Assert.assertEquals; /** - * Created by sgrostad on 21/07/2017. + * @author sgrostad + * @author olaaun */ + public class OutputParserTest { private static final String RETURN_VALUE = "#returnValue#"; @@ -24,8 +24,8 @@ public class OutputParserTest { private static final String SEARCH_WORD_1 = "Parsing"; private static final String SEARCH_WORD_2 = "this"; private static final String REGEX_SEARCH_WORD = ".*S.*"; - private ArrayList<String> commandOutput; - private ArrayList<String> searchWords; + private List<String> commandOutput; + private List<String> searchWords; @Before public void setup() { @@ -36,7 +36,7 @@ public class OutputParserTest { public void parseOutput_searching_for_two_normal_words() { searchWords = new ArrayList<>(Arrays.asList(SEARCH_WORD_1, SEARCH_WORD_2)); ParseInstructions parseInstructions = new ParseInstructions(6, 8, " ", searchWords); - ArrayList<ParseResult> parseResults = OutputParser.parseOutput(parseInstructions, commandOutput); + List<ParseResult> parseResults = OutputParser.parseOutput(parseInstructions, commandOutput); ParseResult expectedParseResult1 = new ParseResult(SEARCH_WORD_1, RETURN_VALUE); ParseResult expectedParseResult2 = new ParseResult(SEARCH_WORD_2, RETURN_VALUE); assertEquals(expectedParseResult1, parseResults.get(0)); @@ -47,7 +47,7 @@ public class OutputParserTest { public void parseOutput_searching_for_two_normal_words_with_semicolon_as_line_split() { searchWords = new ArrayList<>(Arrays.asList(SEARCH_WORD_1, SEARCH_WORD_2)); ParseInstructions parseInstructions = new ParseInstructions(4, 5, ";", searchWords); - ArrayList<ParseResult> parseResults = OutputParser.parseOutput(parseInstructions, commandOutput); + List<ParseResult> parseResults = OutputParser.parseOutput(parseInstructions, commandOutput); ParseResult expectedParseResult1 = new ParseResult(SEARCH_WORD_1, RETURN_VALUE); ParseResult expectedParseResult2 = new ParseResult(SEARCH_WORD_2, RETURN_VALUE); assertEquals(expectedParseResult1, parseResults.get(0)); @@ -58,7 +58,7 @@ public class OutputParserTest { public void parseOutput_searching_for_word_containing_capital_s() { searchWords = new ArrayList<>(Arrays.asList(REGEX_SEARCH_WORD)); ParseInstructions parseInstructions = new ParseInstructions(1, 8, " ", searchWords); - ArrayList<ParseResult> parseResults = OutputParser.parseOutput(parseInstructions, commandOutput); + List<ParseResult> parseResults = OutputParser.parseOutput(parseInstructions, commandOutput); ParseResult expectedParseResult1 = new ParseResult("Should", RETURN_VALUE); ParseResult expectedParseResult2 = new ParseResult("thiS", RETURN_VALUE); assertEquals(expectedParseResult1, parseResults.get(0)); 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 index 2963b57110c..931b42bb2a0 100644 --- 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 @@ -6,6 +6,11 @@ import org.junit.Test; import static org.junit.Assert.assertEquals; +/** + * @author sgrostad + * @author olaaun + */ + public class BenchmarkReportTest { private BenchmarkReport benchmarkReport = new BenchmarkReport(); 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 deleted file mode 100644 index bc6d1d6d089..00000000000 --- a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/report/ReportSenderTest.java +++ /dev/null @@ -1,70 +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.ArrayList; -import java.util.Arrays; - -import static org.junit.Assert.assertEquals; - -public class ReportSenderTest { - - private final ByteArrayOutputStream println = new ByteArrayOutputStream(); - 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/nodeInfoTest.json"; - private static final String URL_RESOURCE_PATH = "file://" + ABSOLUTE_PATH + "/" + RESOURCE_PATH; - private static ArrayList<URL> nodeInfoUrls; - - @Before - public void setup() throws IOException { - System.setOut(new PrintStream(println)); - URL nodeInfoUrlWithAlreadyExistingHardwareDivergence = new URL(URL_RESOURCE_PATH); - nodeInfoUrls = new ArrayList<>(Arrays.asList(nodeInfoUrlWithAlreadyExistingHardwareDivergence)); - } - - @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}}"; - ReportSender.reportBenchmarkResults(benchmarkReport,nodeInfoUrls); - 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"; - ReportSender.reportBenchmarkResults(benchmarkReport, nodeInfoUrls); - 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}}"; - ReportSender.reportSpecVerificationResults(specVerificationReport, nodeInfoUrls); - assertEquals(expectedReport, println.toString()); - } - -} 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 new file mode 100644 index 00000000000..5f469db7f53 --- /dev/null +++ b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/report/ReporterTest.java @@ -0,0 +1,104 @@ +// 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 index 0b19e1b758c..72629cc565d 100644 --- 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 @@ -2,13 +2,17 @@ package com.yahoo.vespa.hosted.node.verification.commons.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; import org.junit.Test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; + +/** + * @author sgrostad + * @author olaaun + */ public class SpecVerificationReportTest { 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 b1a98acd78a..4c999dba35d 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,17 +1,18 @@ // 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.hardware; -import com.yahoo.vespa.hosted.node.verification.hardware.benchmarks.BenchmarkResults; import com.yahoo.vespa.hosted.node.verification.commons.report.BenchmarkReport; +import com.yahoo.vespa.hosted.node.verification.hardware.benchmarks.BenchmarkResults; import org.junit.Before; import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +/** + * @author sgrostad + * @author olaaun + */ public class BenchmarkResultInspectorTest { 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 7b4ad9b967b..6848fc045e2 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 @@ -12,6 +12,11 @@ import java.util.Arrays; import static org.junit.Assert.assertTrue; +/** + * @author sgrostad + * @author olaaun + */ + public class HardwareBenchmarkerTest { private MockCommandExecutor mockCommandExecutor; diff --git a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/hardware/benchmarks/CPUBenchmarkTest.java b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/hardware/benchmarks/CPUBenchmarkTest.java index b2655aca26e..04e9057b44e 100644 --- a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/hardware/benchmarks/CPUBenchmarkTest.java +++ b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/hardware/benchmarks/CPUBenchmarkTest.java @@ -9,14 +9,17 @@ import org.junit.Test; import java.io.IOException; import java.util.ArrayList; +import java.util.List; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; /** - * Created by sgrostad on 11/07/2017. + * @author sgrostad + * @author olaaun */ + public class CPUBenchmarkTest { private static final String cpuEuropeanDelimiters = "src/test/java/com/yahoo/vespa/hosted/node/verification/hardware/resources/cpuCyclesWithDotsTimeWithCommaTest.txt"; @@ -56,8 +59,8 @@ public class CPUBenchmarkTest { @Test public void parseCpuCyclesPerSec_return_correct_ArrayList() throws IOException { - ArrayList<String> mockCommandOutput = MockCommandExecutor.readFromFile(cpuEuropeanDelimiters); - ArrayList<ParseResult> parseResults = cpu.parseCpuCyclesPerSec(mockCommandOutput); + List<String> mockCommandOutput = MockCommandExecutor.readFromFile(cpuEuropeanDelimiters); + List<ParseResult> parseResults = cpu.parseCpuCyclesPerSec(mockCommandOutput); ParseResult expectedParseCyclesResult = new ParseResult("cycles", "2.066.201.729"); ParseResult expectedParseSecondsResult = new ParseResult("seconds", "0,957617512"); assertEquals(expectedParseCyclesResult, parseResults.get(0)); @@ -66,7 +69,7 @@ public class CPUBenchmarkTest { @Test public void test_if_setCpuCyclesPerSec_reads_output_correctly() throws IOException { - ArrayList<ParseResult> parseResults = new ArrayList<>(); + List<ParseResult> parseResults = new ArrayList<>(); parseResults.add(new ParseResult("cycles", "2.066.201.729")); parseResults.add(new ParseResult("seconds", "0,957617512")); cpu.setCpuCyclesPerSec(parseResults); diff --git a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/hardware/benchmarks/DiskBenchmarkTest.java b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/hardware/benchmarks/DiskBenchmarkTest.java index 8bc0266e3b5..8254718f36d 100644 --- a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/hardware/benchmarks/DiskBenchmarkTest.java +++ b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/hardware/benchmarks/DiskBenchmarkTest.java @@ -7,14 +7,17 @@ import org.junit.Before; import org.junit.Test; import java.util.ArrayList; +import java.util.List; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; /** - * Created by sgrostad on 12/07/2017. + * @author sgrostad + * @author olaaun */ + public class DiskBenchmarkTest { private DiskBenchmark diskBenchmark; @@ -54,7 +57,7 @@ public class DiskBenchmarkTest { @Test public void parseDiskSpeed_valid_input() throws Exception { - ArrayList<String> mockCommandOutput = MockCommandExecutor.readFromFile(VALID_OUTPUT_FILE); + List<String> mockCommandOutput = MockCommandExecutor.readFromFile(VALID_OUTPUT_FILE); ParseResult parseResult = diskBenchmark.parseDiskSpeed(mockCommandOutput); ParseResult expectedParseResult = new ParseResult("MB/s", "243"); assertEquals(expectedParseResult, parseResult); @@ -62,7 +65,7 @@ public class DiskBenchmarkTest { @Test public void parseDiskSpeed_invalid_input() throws Exception { - ArrayList<String> mockCommandOutput = MockCommandExecutor.readFromFile(INVALID_OUTPUT_FILE); + List<String> mockCommandOutput = MockCommandExecutor.readFromFile(INVALID_OUTPUT_FILE); ParseResult parseResult = diskBenchmark.parseDiskSpeed(mockCommandOutput); ParseResult expectedParseResult = new ParseResult("invalid", "invalid"); assertEquals(expectedParseResult, parseResult); diff --git a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/hardware/benchmarks/MemoryBenchmarkTest.java b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/hardware/benchmarks/MemoryBenchmarkTest.java index b44fcd8903e..e2c5cdfa555 100644 --- a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/hardware/benchmarks/MemoryBenchmarkTest.java +++ b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/hardware/benchmarks/MemoryBenchmarkTest.java @@ -6,15 +6,17 @@ import com.yahoo.vespa.hosted.node.verification.mock.MockCommandExecutor; import org.junit.Before; import org.junit.Test; -import java.util.ArrayList; +import java.util.List; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; /** - * Created by olaa on 14/07/2017. + * @author sgrostad + * @author olaaun */ + public class MemoryBenchmarkTest { private MemoryBenchmark memoryBenchmark; @@ -48,7 +50,7 @@ public class MemoryBenchmarkTest { public void parseMemorySpeed_valid_output() throws Exception { Double expectedSpeed = 12.1; String mockOutput = "This is a test \n the memory speed to be found is " + expectedSpeed + " GB/s"; - ArrayList<String> mockCommandOutput = commandExecutor.outputFromString(mockOutput); + List<String> mockCommandOutput = commandExecutor.outputFromString(mockOutput); ParseResult parseResult = memoryBenchmark.parseMemorySpeed(mockCommandOutput); ParseResult expectedParseResult = new ParseResult("GB/s", expectedSpeed.toString()); assertEquals(expectedParseResult, parseResult); @@ -56,7 +58,7 @@ public class MemoryBenchmarkTest { @Test public void parseMemorySpeed_invalid_output() throws Exception { - ArrayList<String> mockCommandOutput = commandExecutor.outputFromString(""); + List<String> mockCommandOutput = commandExecutor.outputFromString(""); ParseResult parseResult = memoryBenchmark.parseMemorySpeed(mockCommandOutput); ParseResult expectedParseResult = new ParseResult("invalid", "invalid"); assertEquals(expectedParseResult, parseResult); diff --git a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/mock/MockCommandExecutor.java b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/mock/MockCommandExecutor.java index 83f542e7142..6e89b91aa94 100644 --- a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/mock/MockCommandExecutor.java +++ b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/mock/MockCommandExecutor.java @@ -8,10 +8,13 @@ import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; +import java.util.List; /** - * Created by olaa on 17/07/2017. + * @author sgrostad + * @author olaaun */ + public class MockCommandExecutor extends CommandExecutor { private ArrayList<String> mockCommands; @@ -24,7 +27,7 @@ public class MockCommandExecutor extends CommandExecutor { } @Override - public ArrayList<String> executeCommand(String command) throws IOException { + public List<String> executeCommand(String command) throws IOException { String mockCommand = mockCommands.get(counter++); if (mockCommand.equals(DUMMY_COMMAND)) return null; return super.executeCommand(mockCommand); @@ -38,11 +41,11 @@ public class MockCommandExecutor extends CommandExecutor { mockCommands.add(DUMMY_COMMAND); } - public static ArrayList<String> readFromFile(String filepath) throws IOException { + public static List<String> readFromFile(String filepath) throws IOException { return new ArrayList<>(Arrays.asList(new String(Files.readAllBytes(Paths.get(filepath))).split("\n"))); } - public ArrayList<String> outputFromString(String output) { + public List<String> outputFromString(String output) { return new ArrayList<>(Arrays.asList(output.split("\n"))); } diff --git a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/HardwareNodeComparatorTest.java b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/HardwareNodeComparatorTest.java index 6113ce315c1..22d1a167a13 100644 --- a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/HardwareNodeComparatorTest.java +++ b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/HardwareNodeComparatorTest.java @@ -8,12 +8,12 @@ import org.junit.Before; import org.junit.Test; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; /** - * Created by olaa on 07/07/2017. + * @author sgrostad + * @author olaaun */ + public class HardwareNodeComparatorTest { private HardwareInfo actualHardware; 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 61f52537e74..16e72521853 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,11 +2,11 @@ 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.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.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; import org.junit.Test; @@ -14,11 +14,17 @@ import java.io.File; 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.assertFalse; import static org.junit.Assert.assertTrue; +/** + * @author sgrostad + * @author olaaun + */ + public class SpecVerifierTest { private MockCommandExecutor mockCommandExecutor; @@ -36,7 +42,7 @@ public class SpecVerifierTest { private static final String PING_RESPONSE = RESOURCE_PATH + "/validpingresponse"; private static final String INVALID_PING_RESPONSE = RESOURCE_PATH + "/pingresponse-all-packets-lost"; private static final double DELTA = 0.1; - ArrayList<URL> nodeInfoUrls; + List<URL> nodeInfoUrls; @Before public void setup() { diff --git a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/IPAddressVerifierTest.json b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/IPAddressVerifierTest.json index 4fcb5efed9e..a3bd4957467 100644 --- a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/IPAddressVerifierTest.json +++ b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/IPAddressVerifierTest.json @@ -77,6 +77,5 @@ "2001:db8:0:1234:0:567:8:1" ], "additionalIpAddresses": [ - ] }
\ No newline at end of file diff --git a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/nodeInfoNotInterpretableHardwareDivergence.json b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/nodeInfoNotInterpretableHardwareDivergence.json new file mode 100644 index 00000000000..0faf1873446 --- /dev/null +++ b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/nodeInfoNotInterpretableHardwareDivergence.json @@ -0,0 +1,82 @@ +{ + "url": "https://api.vespayahoo.com", + "id": "id.prod.yahoo.com", + "state": "failed", + "type": "host", + "hostname": "hostname", + "openStackId": "4a8689e1-3a8e-4f50-b99f-d33b245a9661", + "flavor": "C-2T/24/500", + "canonicalFlavor": "C-2B/24/500", + "minDiskAvailableGb": 500.0, + "minMainMemoryAvailableGb": 24.0, + "description": "BARE_METAL with 24.0 CPUs, 24.0 Gb memory and 500.0 Gb disk", + "minCpuCores": 24.0, + "cost": 70, + "fastDisk": false, + "environment": "BARE_METAL", + "owner": { + "tenant": "hosted-vespa", + "application": "routing", + "instance": "default" + }, + "membership": { + "clustertype": "container", + "clusterid": "node-admin", + "group": "0", + "index": 32, + "retired": false + }, + "restartGeneration": 0, + "currentRestartGeneration": 0, + "wantedDockerImage": "docker-registry.ops.yahoo.com:4443/vespa/ci:6.138.1", + "wantedVespaVersion": "6.138.1", + "rebootGeneration": 49, + "currentRebootGeneration": 49, + "vespaVersion": "6.138.18", + "currentDockerImage": "docker-registry.ops.yahoo.com:4443/vespa/ci:6.138.18", + "hostedVersion": "6.138.18", + "convergedStateVersion": "6.138.18", + "failCount": 44, + "hardwareFailure": true, + "hardwareFailureType": "disk_smart", + "hardwareFailureDescription": "disk_smart", + "wantToRetire": false, + "wantToDeprovision": false, + "history": [ + { + "event": "readied", + "at": 1501070910372, + "agent": "system" + }, + { + "event": "reserved", + "at": 1501070952692, + "agent": "application" + }, + { + "event": "activated", + "at": 1501070958698, + "agent": "application" + }, + { + "event": "rebooted", + "at": 1501656469859, + "agent": "system" + }, + { + "event": "down", + "at": 1502809344596, + "agent": "system" + }, + { + "event": "failed", + "at": 1502812976621, + "agent": "system" + } + ], + "ipAddresses": [ + ], + "additionalIpAddresses": [ + ], + "hardwareDivergence": "{\"hardwareDivergence\": null - it will not manage to parse this}" +}
\ No newline at end of file diff --git a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/nodeInfoTest.json b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/nodeInfoTest.json index 216991846b0..c557afb3256 100644 --- a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/nodeInfoTest.json +++ b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/nodeInfoTest.json @@ -45,6 +45,5 @@ "10.200.66.16" ], "additionalIpAddresses": [], - "hardwareDivergence": "{\"benchmarkReport\": {\"cpuCyclesPerSec\": 0.5}}" }
\ No newline at end of file diff --git a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/CPURetrieverTest.java b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/CPURetrieverTest.java index cda8066734d..d878d6614f7 100644 --- a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/CPURetrieverTest.java +++ b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/CPURetrieverTest.java @@ -8,12 +8,15 @@ import org.junit.Test; import java.io.IOException; import java.util.ArrayList; +import java.util.List; import static org.junit.Assert.assertEquals; /** - * Created by olaa on 03/07/2017. + * @author sgrostad + * @author olaaun */ + public class CPURetrieverTest { private static final String FILENAME = "src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/cpuinfoTest"; @@ -39,8 +42,8 @@ public class CPURetrieverTest { @Test public void parseCPUInfoFile_should_return_valid_ArrayList() throws IOException { - ArrayList<String> commandOutput = MockCommandExecutor.readFromFile(FILENAME); - ArrayList<ParseResult> ParseResults = cpu.parseCPUInfoFile(commandOutput); + List<String> commandOutput = MockCommandExecutor.readFromFile(FILENAME); + List<ParseResult> ParseResults = cpu.parseCPUInfoFile(commandOutput); String expectedSearchWord = "cpu MHz"; String expectedValue = "2493.821"; @@ -59,7 +62,7 @@ public class CPURetrieverTest { @Test public void setCpuCores_counts_cores_correctly() { - ArrayList<ParseResult> parseResults = new ArrayList<>(); + List<ParseResult> parseResults = new ArrayList<>(); parseResults.add(new ParseResult("cpu MHz", "2000")); parseResults.add(new ParseResult("cpu MHz", "2000")); parseResults.add(new ParseResult("cpu MHz", "2000")); diff --git a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/DiskRetrieverTest.java b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/DiskRetrieverTest.java index 6cd29ab8f64..de4bf946d59 100644 --- a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/DiskRetrieverTest.java +++ b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/DiskRetrieverTest.java @@ -8,14 +8,16 @@ import org.junit.Before; import org.junit.Test; import java.io.IOException; -import java.util.ArrayList; +import java.util.List; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; /** - * Created by olaa on 06/07/2017. + * @author sgrostad + * @author olaaun */ + public class DiskRetrieverTest { private MockCommandExecutor commandExecutor; @@ -59,7 +61,7 @@ public class DiskRetrieverTest { @Test public void parseDiskType_should_find_fast_disk() throws Exception { diskRetriever = new DiskRetriever(hardwareInfo, commandExecutor); - ArrayList<String> mockOutput = commandExecutor.outputFromString("Name Rota \nsda 0"); + List<String> mockOutput = commandExecutor.outputFromString("Name Rota \nsda 0"); ParseResult parseResult = diskRetriever.parseDiskType(mockOutput); ParseResult expectedParseResult = new ParseResult("sda", "0"); assertEquals(expectedParseResult, parseResult); @@ -67,7 +69,7 @@ public class DiskRetrieverTest { @Test public void parseDiskType_should_not_find_fast_disk() throws Exception { - ArrayList<String> mockOutput = commandExecutor.outputFromString("Name Rota \nsda 1"); + List<String> mockOutput = commandExecutor.outputFromString("Name Rota \nsda 1"); ParseResult parseResult = diskRetriever.parseDiskType(mockOutput); ParseResult expectedParseResult = new ParseResult("sda", "1"); assertEquals(expectedParseResult, parseResult); @@ -75,7 +77,7 @@ public class DiskRetrieverTest { @Test public void parseDiskType_with_invalid_outputstream_does_not_contain_searchword_should_throw_exception() throws Exception { - ArrayList<String> mockOutput = commandExecutor.outputFromString("Name Rota"); + List<String> mockOutput = commandExecutor.outputFromString("Name Rota"); try { ParseResult parseResult = diskRetriever.parseDiskType(mockOutput); fail("Should have thrown IOException when outputstream doesn't contain search word"); @@ -89,8 +91,8 @@ public class DiskRetrieverTest { @Test public void parseDiskSize_should_find_size_from_file_and_insert_into_parseResult() throws Exception { String filepath = "src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/filesize"; - ArrayList<String> mockOutput = MockCommandExecutor.readFromFile(filepath); - ArrayList<ParseResult> parseResults = diskRetriever.parseDiskSize(mockOutput); + List<String> mockOutput = MockCommandExecutor.readFromFile(filepath); + List<ParseResult> parseResults = diskRetriever.parseDiskSize(mockOutput); ParseResult expectedParseResult1 = new ParseResult("Size", "799.65"); assertEquals(expectedParseResult1, parseResults.get(0)); ParseResult expectedParseResult2 = new ParseResult("Size", "960.19"); 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 ae131e0c4e8..552d57d2b59 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 @@ -6,10 +6,15 @@ import com.yahoo.vespa.hosted.node.verification.mock.MockCommandExecutor; import com.yahoo.vespa.hosted.node.verification.spec.VerifierSettings; import org.junit.Before; import org.junit.Test; + +import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.spy; -import static org.junit.Assert.assertEquals; +/** + * @author sgrostad + * @author olaaun + */ public class HardwareInfoRetrieverTest { diff --git a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/MemoryRetrieverTest.java b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/MemoryRetrieverTest.java index 9d20acbc762..6b0b5f6d24a 100644 --- a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/MemoryRetrieverTest.java +++ b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/retrievers/MemoryRetrieverTest.java @@ -7,13 +7,15 @@ import org.junit.Before; import org.junit.Test; import java.io.IOException; -import java.util.ArrayList; +import java.util.List; import static org.junit.Assert.assertEquals; /** - * Created by sgrostad on 06/07/2017. + * @author sgrostad + * @author olaaun */ + public class MemoryRetrieverTest { private static final String FILENAME = "src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/meminfoTest"; @@ -39,7 +41,7 @@ public class MemoryRetrieverTest { @Test public void parseMemInfoFile_should_return_valid_parseResult() throws IOException { - ArrayList<String> commandOutput = MockCommandExecutor.readFromFile(FILENAME); + List<String> commandOutput = MockCommandExecutor.readFromFile(FILENAME); ParseResult parseResult = memory.parseMemInfoFile(commandOutput); ParseResult expectedParseResult = new ParseResult("MemTotal", "4042128 kB"); assertEquals(expectedParseResult, parseResult); 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 893f23d6133..565712608f5 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 @@ -10,6 +10,7 @@ import org.junit.Test; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -19,8 +20,10 @@ import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.spy; /** - * Created by sgrostad on 07/07/2017. + * @author sgrostad + * @author olaaun */ + public class NetRetrieverTest { private static final String RESOURCE_PATH = "src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/"; @@ -32,7 +35,7 @@ public class NetRetrieverTest { private HardwareInfo hardwareInfo; private MockCommandExecutor commandExecutor; private NetRetriever net; - private ArrayList<ParseResult> parseResults; + private List<ParseResult> parseResults; private VerifierSettings verifierSettings = spy(new VerifierSettings()); private static final double DELTA = 0.1; @@ -70,7 +73,7 @@ public class NetRetrieverTest { @Test public void parseNetInterface_get_ipv_from_ifconfig_testFile() throws IOException { - ArrayList<String> mockOutput = MockCommandExecutor.readFromFile(NET_FIND_INTERFACE); + List<String> mockOutput = MockCommandExecutor.readFromFile(NET_FIND_INTERFACE); parseResults = net.parseNetInterface(mockOutput); net.updateHardwareInfoWithNet(parseResults); assertTrue(hardwareInfo.getIpv4Interface()); @@ -79,7 +82,7 @@ public class NetRetrieverTest { @Test public void parseNetInterface_get_ipv_from_ifconfigNotIpv6_testFile() throws IOException { - ArrayList<String> mockOutput = MockCommandExecutor.readFromFile(NET_FIND_INTERFACE + "NoIpv6"); + List<String> mockOutput = MockCommandExecutor.readFromFile(NET_FIND_INTERFACE + "NoIpv6"); parseResults = net.parseNetInterface(mockOutput); ArrayList<ParseResult> expextedParseResults = new ArrayList<>(Arrays.asList( new ParseResult("inet", "inet"))); @@ -88,7 +91,7 @@ public class NetRetrieverTest { @Test public void parseInterfaceSpeed_get_interfaceSpeed_from_eth0_testFile() throws IOException { - ArrayList<String> mockOutput = MockCommandExecutor.readFromFile("src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/eth0"); + List<String> mockOutput = MockCommandExecutor.readFromFile("src/test/java/com/yahoo/vespa/hosted/node/verification/spec/resources/eth0"); ParseResult parseResult = net.parseInterfaceSpeed(mockOutput); ParseResult expectedParseResult = new ParseResult("Speed", "1000Mb/s"); assertEquals(expectedParseResult, parseResult); @@ -117,7 +120,7 @@ public class NetRetrieverTest { @Test public void parsePingResponse_valid_ping_response_should_return_ipv6_connectivity() throws IOException { - ArrayList<String> mockCommandOutput = MockCommandExecutor.readFromFile(VALID_PING_RESPONSE); + List<String> mockCommandOutput = MockCommandExecutor.readFromFile(VALID_PING_RESPONSE); ParseResult parseResult = net.parsePingResponse(mockCommandOutput); String expectedPing = "0"; assertEquals(expectedPing, parseResult.getValue()); @@ -125,7 +128,7 @@ public class NetRetrieverTest { @Test public void parsePingResponse_invalid_ping_response_should_throw_IOException() throws IOException { - ArrayList<String> mockCommandOutput = MockCommandExecutor.readFromFile(INVALID_PING_RESPONSE); + List<String> mockCommandOutput = MockCommandExecutor.readFromFile(INVALID_PING_RESPONSE); try { ParseResult parseResult = net.parsePingResponse(mockCommandOutput); fail("Expected an IOException to be thrown"); |