use of org.apache.gobblin.runtime.troubleshooter.Issue in project gobblin by apache.
the class MySqlMultiContextIssueRepositoryTest method canRemoveIssuesAboveSpecifiedCount.
@Test
public void canRemoveIssuesAboveSpecifiedCount() throws Exception {
String contextId = "context-" + testId;
for (int i = 0; i < 100; i++) {
Issue issue = getTestIssue("test-" + i, "code-" + i);
repository.put(contextId, issue);
}
repository.deleteOldIssuesOverTheCount(20);
List<Issue> retrievedIssues = repository.getAll(contextId);
assertThat(retrievedIssues).hasSize(20);
assertThat(retrievedIssues.get(0).getCode()).isEqualTo("code-80");
assertThat(retrievedIssues.get(19).getCode()).isEqualTo("code-99");
}
use of org.apache.gobblin.runtime.troubleshooter.Issue in project gobblin by apache.
the class MySqlMultiContextIssueRepositoryTest method canPutAndGetFullIssue.
@Test
public void canPutAndGetFullIssue() throws Exception {
HashMap<String, String> properties = new HashMap<>();
properties.put("test.prop1", "test value 1");
properties.put("test.prop2", "test value 2");
// Mysql date has less precision than Java date, so we zero sub-second component of the date to get the same
// value after retrieval from db
Issue issue = Issue.builder().summary("Test summary \" ' -- ").code("CODE1").time(ZonedDateTime.now().withNano(0).withZoneSameInstant(ZoneOffset.UTC)).severity(IssueSeverity.ERROR).details("details for test issue").exceptionClass("java.io.IOException").sourceClass("org.apache.gobblin.service.modules.troubleshooter.AutoTroubleshooterLogAppender").properties(properties).build();
String contextId = "context-" + testId;
repository.put(contextId, issue);
List<Issue> issues = repository.getAll(contextId);
assertThat(issues).hasSize(1);
assertThat(issues.get(0)).usingRecursiveComparison().isEqualTo(issue);
}
use of org.apache.gobblin.runtime.troubleshooter.Issue in project incubator-gobblin by apache.
the class AutomaticTroubleshooterImpl method getIssueSummaryMessage.
@Override
public String getIssueSummaryMessage() throws TroubleshooterException {
List<Issue> issues = issueRepository.getAll();
TextStringBuilder sb = new TextStringBuilder();
sb.appendln("");
sb.appendln("vvvvv============= Issues (summary) =============vvvvv");
for (int i = 0; i < issues.size(); i++) {
Issue issue = issues.get(i);
sb.appendln("%s) %s %s %s | source: %s", i + 1, issue.getSeverity().toString(), issue.getCode(), issue.getSummary(), issue.getSourceClass());
}
sb.append("^^^^^=============================================^^^^^");
return sb.toString();
}
use of org.apache.gobblin.runtime.troubleshooter.Issue in project incubator-gobblin by apache.
the class AutomaticTroubleshooterImpl method getIssueDetailsMessage.
@Override
public String getIssueDetailsMessage() throws TroubleshooterException {
List<Issue> issues = issueRepository.getAll();
TextStringBuilder sb = new TextStringBuilder();
sb.appendln("");
sb.appendln("vvvvv============= Issues (detailed) =============vvvvv");
for (int i = 0; i < issues.size(); i++) {
Issue issue = issues.get(i);
sb.appendln("%s) %s %s %s", i + 1, issue.getSeverity().toString(), issue.getCode(), issue.getSummary());
sb.appendln("\tsource: %s", issue.getSourceClass());
if (issue.getDetails() != null) {
sb.appendln("\t" + issue.getDetails().replaceAll(System.lineSeparator(), System.lineSeparator() + "\t"));
}
if (issue.getProperties() != null) {
issue.getProperties().forEach((key, value) -> {
sb.appendln("\t%s: %s", key, value);
});
}
}
sb.append("^^^^^================================================^^^^^");
return sb.toString();
}
use of org.apache.gobblin.runtime.troubleshooter.Issue in project incubator-gobblin by apache.
the class AutoTroubleshooterLogAppenderTest method canLogWarning.
@Test
public void canLogWarning() throws Exception {
appender.append(new LoggingEvent(log.getName(), log, System.currentTimeMillis(), Level.WARN, "test", null));
Issue issue = issueRepository.getAll().get(0);
Assert.assertEquals(issue.getSeverity(), IssueSeverity.WARN);
Assert.assertEquals(issue.getSummary(), "test");
Assert.assertEquals(issue.getSourceClass(), getClass().getName());
Assert.assertTrue(issue.getTime().isAfter(ZonedDateTime.now().minus(1, ChronoUnit.MINUTES)));
Assert.assertTrue(issue.getTime().isBefore(ZonedDateTime.now().plus(1, ChronoUnit.MINUTES)));
Assert.assertTrue(issue.getCode().length() > 1);
assertEquals(appender.getProcessedEventCount(), 1);
}
Aggregations