summaryrefslogtreecommitdiffstats
path: root/node-maintainer
diff options
context:
space:
mode:
authorArne H Juul <arnej@yahoo-inc.com>2017-06-28 12:09:34 +0200
committerArne H Juul <arnej@yahoo-inc.com>2017-06-28 12:09:34 +0200
commitb7cd71c9a269e3acc96503f929bcf1257431615f (patch)
tree9d438c5918371b805189b33f0b6b5bbfd802fe38 /node-maintainer
parentf556ca70768f62163f11ec143770c201160b7af1 (diff)
use underVespaHome
Diffstat (limited to 'node-maintainer')
-rw-r--r--node-maintainer/pom.xml5
-rw-r--r--node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/maintainer/CoreCollector.java8
-rw-r--r--node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/maintainer/CoreCollectorTest.java21
3 files changed, 22 insertions, 12 deletions
diff --git a/node-maintainer/pom.xml b/node-maintainer/pom.xml
index 1725e42d955..6e54afe2d90 100644
--- a/node-maintainer/pom.xml
+++ b/node-maintainer/pom.xml
@@ -19,6 +19,11 @@
<dependencies>
<dependency>
<groupId>com.yahoo.vespa</groupId>
+ <artifactId>defaults</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.yahoo.vespa</groupId>
<artifactId>vespajlib</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/maintainer/CoreCollector.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/maintainer/CoreCollector.java
index d30c53a6af6..eb77e75ce66 100644
--- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/maintainer/CoreCollector.java
+++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/maintainer/CoreCollector.java
@@ -2,6 +2,7 @@
package com.yahoo.vespa.hosted.node.maintainer;
import com.yahoo.collections.Pair;
+import static com.yahoo.vespa.defaults.Defaults.getDefaults;
import com.yahoo.system.ProcessExecuter;
import java.io.IOException;
@@ -24,7 +25,8 @@ import java.util.regex.Pattern;
* @author freva
*/
public class CoreCollector {
- private static final String GDB_PATH = "/home/y/bin64/gdb";
+ private static final String GDB_PATH = getDefaults().underVespaHome("bin64/gdb");
+ private static final String LZ4_PATH = getDefaults().underVespaHome("bin64/lz4");
private static final Pattern CORE_GENERATOR_PATH_PATTERN = Pattern.compile("^Core was generated by `(?<path>.*?)'.$");
private static final Pattern EXECFN_PATH_PATTERN = Pattern.compile("^.* execfn: '(?<path>.*?)'");
private static final Pattern FROM_PATH_PATTERN = Pattern.compile("^.* from '(?<path>.*?)'");
@@ -146,7 +148,7 @@ public class CoreCollector {
private Path compressCoredump(Path coredumpPath) throws IOException, InterruptedException {
if (! coredumpPath.toString().endsWith(".lz4")) {
processExecuter.exec(
- new String[]{"/home/y/bin64/lz4", coredumpPath.toString(), coredumpPath.toString() + ".lz4"});
+ new String[]{LZ4_PATH, coredumpPath.toString(), coredumpPath.toString() + ".lz4"});
return coredumpPath;
} else {
@@ -156,7 +158,7 @@ public class CoreCollector {
Path decompressedPath = Paths.get(coredumpPath.toString().replaceFirst("\\.lz4$", ""));
Pair<Integer, String> result = processExecuter.exec(
- new String[]{"/home/y/bin64/lz4", "-d", coredumpPath.toString(), decompressedPath.toString()});
+ new String[]{LZ4_PATH, "-d", coredumpPath.toString(), decompressedPath.toString()});
if (result.getFirst() != 0) {
throw new RuntimeException("Failed to decompress file " + coredumpPath + ": " + result);
}
diff --git a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/maintainer/CoreCollectorTest.java b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/maintainer/CoreCollectorTest.java
index f832a5fee7b..c2e6a274dd1 100644
--- a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/maintainer/CoreCollectorTest.java
+++ b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/maintainer/CoreCollectorTest.java
@@ -1,7 +1,8 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.node.maintainer;
import com.yahoo.collections.Pair;
+import static com.yahoo.vespa.defaults.Defaults.getDefaults;
import com.yahoo.system.ProcessExecuter;
import org.junit.Rule;
import org.junit.Test;
@@ -60,6 +61,8 @@ public class CoreCollectorTest {
when(processExecuter.exec(cmd)).thenReturn(new Pair<Integer, String>(error.isEmpty() ? 0 : 1, output + error));
}
+ static final String GDB_PATH = getDefaults().underVespaHome("bin64/gdb");
+
@Test
public void extractsBinaryPathTest() throws IOException, InterruptedException {
final String[] cmd = {"file", TEST_CORE_PATH.toString()};
@@ -87,7 +90,7 @@ public class CoreCollectorTest {
Path fallbackResponse = Paths.get("/response/from/fallback");
- mockExec(new String[]{"sh", "-c", "/home/y/bin64/gdb -n -batch -core /tmp/core.1234 | grep '^Core was generated by'"},
+ mockExec(new String[]{"sh", "-c", GDB_PATH + " -n -batch -core /tmp/core.1234 | grep '^Core was generated by'"},
"Core was generated by `/response/from/fallback'.");
mockExec(cmd,
"/tmp/core.1234: ELF 64-bit LSB core file x86-64, version 1 (SYSV), SVR4-style");
@@ -100,7 +103,7 @@ public class CoreCollectorTest {
@Test
public void extractsBinaryPathUsingGdbTest() throws IOException, InterruptedException {
final String[] cmd = new String[]{"sh", "-c",
- "/home/y/bin64/gdb -n -batch -core /tmp/core.1234 | grep '^Core was generated by'"};
+ GDB_PATH + " -n -batch -core /tmp/core.1234 | grep '^Core was generated by'"};
mockExec(cmd, "Core was generated by `/usr/bin/program-from-gdb --identity foo/search/cluster.content_'.");
assertEquals(Paths.get("/usr/bin/program-from-gdb"), coreCollector.readBinPathFallback(TEST_CORE_PATH));
@@ -116,11 +119,11 @@ public class CoreCollectorTest {
@Test
public void extractsBacktraceUsingGdb() throws IOException, InterruptedException {
- mockExec(new String[]{"/home/y/bin64/gdb", "-n", "-ex", "bt", "-batch", "/usr/bin/program", "/tmp/core.1234"},
+ mockExec(new String[]{GDB_PATH, "-n", "-ex", "bt", "-batch", "/usr/bin/program", "/tmp/core.1234"},
String.join("\n", GDB_BACKTRACE));
assertEquals(GDB_BACKTRACE, coreCollector.readBacktrace(TEST_CORE_PATH, TEST_BIN_PATH, false));
- mockExec(new String[]{"/home/y/bin64/gdb", "-n", "-ex", "bt", "-batch", "/usr/bin/program", "/tmp/core.1234"},
+ mockExec(new String[]{GDB_PATH, "-n", "-ex", "bt", "-batch", "/usr/bin/program", "/tmp/core.1234"},
"", "Failure");
try {
coreCollector.readBacktrace(TEST_CORE_PATH, TEST_BIN_PATH, false);
@@ -132,7 +135,7 @@ public class CoreCollectorTest {
@Test
public void extractsBacktraceFromAllThreadsUsingGdb() throws IOException, InterruptedException {
- mockExec(new String[]{"/home/y/bin64/gdb", "-n", "-ex", "thread apply all bt", "-batch",
+ mockExec(new String[]{GDB_PATH, "-n", "-ex", "thread apply all bt", "-batch",
"/usr/bin/program", "/tmp/core.1234"},
String.join("\n", GDB_BACKTRACE));
assertEquals(GDB_BACKTRACE, coreCollector.readBacktrace(TEST_CORE_PATH, TEST_BIN_PATH, true));
@@ -143,9 +146,9 @@ public class CoreCollectorTest {
mockExec(new String[]{"file", TEST_CORE_PATH.toString()},
"/tmp/core.1234: ELF 64-bit LSB core file x86-64, version 1 (SYSV), SVR4-style, from " +
"'/usr/bin/program'");
- mockExec(new String[]{"/home/y/bin64/gdb", "-n", "-ex", "bt", "-batch", "/usr/bin/program", "/tmp/core.1234"},
+ mockExec(new String[]{GDB_PATH, "-n", "-ex", "bt", "-batch", "/usr/bin/program", "/tmp/core.1234"},
String.join("\n", GDB_BACKTRACE));
- mockExec(new String[]{"/home/y/bin64/gdb", "-n", "-ex", "thread apply all bt", "-batch",
+ mockExec(new String[]{GDB_PATH, "-n", "-ex", "thread apply all bt", "-batch",
"/usr/bin/program", "/tmp/core.1234"},
String.join("\n", GDB_BACKTRACE));
mockExec(new String[]{"cat", YINST_STATE_PATH.toString()}, String.join("\n", YINST_STATE));
@@ -175,7 +178,7 @@ public class CoreCollectorTest {
mockExec(new String[]{"file", TEST_CORE_PATH.toString()},
"/tmp/core.1234: ELF 64-bit LSB core file x86-64, version 1 (SYSV), SVR4-style, from " +
"'/usr/bin/program'");
- mockExec(new String[]{"/home/y/bin64/gdb -n -ex bt -batch /usr/bin/program /tmp/core.1234"},
+ mockExec(new String[]{GDB_PATH + " -n -ex bt -batch /usr/bin/program /tmp/core.1234"},
"", "Failure");
Map<String, Object> expectedData = new HashMap<>();