diff options
author | valerijf <valerijf@yahoo-inc.com> | 2017-05-10 12:19:57 +0200 |
---|---|---|
committer | valerijf <valerijf@yahoo-inc.com> | 2017-05-10 12:19:57 +0200 |
commit | e94d46c9c072bb88533cc718c7541d4339d64b19 (patch) | |
tree | 191df8e0fc38e48b479e45d526d1ddbae065af47 /node-maintainer | |
parent | 4f36cf1ae65ceaac515c7a3828fef4bd093ddff7 (diff) |
Fix coredump reporting
Diffstat (limited to 'node-maintainer')
2 files changed, 6 insertions, 3 deletions
diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/maintainer/CoredumpHandler.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/maintainer/CoredumpHandler.java index c14667fb89c..2a641ae2356 100644 --- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/maintainer/CoredumpHandler.java +++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/maintainer/CoredumpHandler.java @@ -117,9 +117,11 @@ public class CoredumpHandler { return Files.move(coredumpPath, folder.resolve(coredumpPath.getFileName())); } - String collectMetadata(Path coredumpPath, Map<String, Object> nodeAttributes) throws IOException { - Path metadataPath = coredumpPath.resolve(METADATA_FILE_NAME); + String collectMetadata(Path coredumpDirectory, Map<String, Object> nodeAttributes) throws IOException { + Path metadataPath = coredumpDirectory.resolve(METADATA_FILE_NAME); if (!Files.exists(metadataPath)) { + Path coredumpPath = Files.list(coredumpDirectory).findFirst() + .orElseThrow(() -> new RuntimeException("No coredump file found in processing directory " + coredumpDirectory)); Map<String, Object> metadata = coreCollector.collect(coredumpPath, yinstStatePath); metadata.putAll(nodeAttributes); diff --git a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/maintainer/CoredumpHandlerTest.java b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/maintainer/CoredumpHandlerTest.java index c33f644138a..faf2e03d068 100644 --- a/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/maintainer/CoredumpHandlerTest.java +++ b/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/maintainer/CoredumpHandlerTest.java @@ -32,6 +32,7 @@ import java.util.stream.Collectors; import static org.junit.Assert.assertEquals; import static org.mockito.Matchers.any; +import static org.mockito.Matchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyZeroInteractions; @@ -109,11 +110,11 @@ public class CoredumpHandlerTest { @Test public void coredumpMetadataCollectAndWriteTest() throws IOException, InterruptedException { - when(coreCollector.collect(any(), any())).thenReturn(metadata); createCoredump("core.dump"); Path processingPath = coredumpHandler.processCoredumps(); Path processingCoredumpPath = Files.list(processingPath).findFirst().orElseThrow(() -> new RuntimeException("Expected to find directory with coredump in processing dir")); + when(coreCollector.collect(eq(processingCoredumpPath.resolve("core.dump")), any())).thenReturn(metadata); // Inside 'processing' directory, there should be a new directory containing 'core.dump' file String returnedMetadata = coredumpHandler.collectMetadata(processingCoredumpPath, attributes); |