summaryrefslogtreecommitdiffstats
path: root/node-maintainer
diff options
context:
space:
mode:
authorsindre <sindre.grostad@icloud.com>2017-08-09 13:00:16 +0200
committerOla Aunrønning <olaa@yahoo-inc.com>2017-08-15 12:29:38 +0200
commitc2f9eea750352710b951456053a06d1c6f1c8b6e (patch)
tree584eeb07e0b7977869ce9539412115bb8ebab8a4 /node-maintainer
parent273275dc6ec9f0f9b4cd6b3d36716089dbb8afb4 (diff)
change of format for reporting
Diffstat (limited to 'node-maintainer')
-rw-r--r--node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/report/BenchmarkReportTest.java27
-rw-r--r--node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/report/SpecVerificationReportTest.java44
-rw-r--r--node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/hardware/resources/nodeRepoWithoutHardwareDivergence.json78
3 files changed, 149 insertions, 0 deletions
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
new file mode 100644
index 00000000000..ef642335db5
--- /dev/null
+++ b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/report/BenchmarkReportTest.java
@@ -0,0 +1,27 @@
+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;
+
+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));
+ }
+
+} \ 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
new file mode 100644
index 00000000000..07d4bf4e5c1
--- /dev/null
+++ b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/commons/report/SpecVerificationReportTest.java
@@ -0,0 +1,44 @@
+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.*;
+
+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);
+ }
+
+} \ No newline at end of file
diff --git a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/hardware/resources/nodeRepoWithoutHardwareDivergence.json b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/hardware/resources/nodeRepoWithoutHardwareDivergence.json
new file mode 100644
index 00000000000..ad2444c9076
--- /dev/null
+++ b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/hardware/resources/nodeRepoWithoutHardwareDivergence.json
@@ -0,0 +1,78 @@
+{
+ "url": "https://example.com:4443/zone/v2/prod/us-west-1/nodes/v2/node/host.name",
+ "state": "active",
+ "type": "host",
+ "hostname": "host.name",
+ "openStackId": "653c39c1-bda4-47ee-a277-d5319eb57af7",
+ "flavor": "C-77E/256/960",
+ "canonicalFlavor": "C-77E/256/960",
+ "minDiskAvailableGb": 1759.84,
+ "minMainMemoryAvailableGb": 4.042128,
+ "description": "BARE_METAL with 48.0 CPUs, 256.0 Gb memory and 1920.0 Gb ssd",
+ "minCpuCores": 4.0,
+ "cost": 150,
+ "fastDisk": true,
+ "environment": "BARE_METAL",
+ "owner": {
+ "tenant": "hosted-vespa",
+ "application": "routing",
+ "instance": "default"
+ },
+ "membership": {
+ "clustertype": "container",
+ "clusterid": "node-admin",
+ "group": "0",
+ "index": 77,
+ "retired": false
+ },
+ "restartGeneration": 0,
+ "currentRestartGeneration": 0,
+ "wantedDockerImage": "docker-registry:4443/vespa/ci:6.128.19",
+ "wantedVespaVersion": "6.128.19",
+ "rebootGeneration": 3,
+ "currentRebootGeneration": 3,
+ "vespaVersion": "6.130.27",
+ "currentDockerImage": "docker-registry:4443/vespa/ci:6.130.27",
+ "hostedVersion": "6.130.27",
+ "convergedStateVersion": "6.130.27",
+ "failCount": 1,
+ "hardwareFailure": false,
+ "wantToRetire": false,
+ "wantToDeprovision": false,
+ "history": [
+ {
+ "event": "failed",
+ "at": 1499293603487,
+ "agent": "system"
+ },
+ {
+ "event": "rebooted",
+ "at": 1499351267086,
+ "agent": "system"
+ },
+ {
+ "event": "readied",
+ "at": 1499351270674,
+ "agent": "system"
+ },
+ {
+ "event": "requested",
+ "at": 1499350936347,
+ "agent": "system"
+ },
+ {
+ "event": "reserved",
+ "at": 1499353058227,
+ "agent": "application"
+ },
+ {
+ "event": "activated",
+ "at": 1499353080459,
+ "agent": "application"
+ }
+ ],
+ "ipAddresses": [
+ ],
+ "additionalIpAddresses": [
+ ]
+} \ No newline at end of file