use of org.apache.gobblin.runtime.troubleshooter.Issue in project gobblin by apache.
the class AutoTroubleshooterLogAppenderTest method canLogExceptionWithSpecificErrorCode.
@Test
public void canLogExceptionWithSpecificErrorCode() throws Exception {
Exception exception;
try {
throw new TestException("test exception", "TestCode");
} catch (Exception e) {
exception = e;
}
appender.append(new LoggingEvent(log.getName(), log, System.currentTimeMillis(), Level.ERROR, "test message", exception));
Issue issue = issueRepository.getAll().get(0);
Assert.assertEquals(issue.getSeverity(), IssueSeverity.ERROR);
Assert.assertEquals(issue.getCode(), "TestCode");
}
use of org.apache.gobblin.runtime.troubleshooter.Issue in project gobblin by apache.
the class MySqlMultiContextIssueRepositoryTest method willGetMeaningfulErrorOnOversizedData.
@Test
public void willGetMeaningfulErrorOnOversizedData() throws Exception {
Issue issue = Issue.builder().summary("Test summary").code(StringUtils.repeat("c", Issue.MAX_ISSUE_CODE_LENGTH * 2)).time(ZonedDateTime.now().withNano(0).withZoneSameInstant(ZoneOffset.UTC)).severity(IssueSeverity.WARN).build();
String contextId = "context-" + testId;
assertThatThrownBy(() -> {
repository.put(contextId, issue);
}).isInstanceOf(TroubleshooterException.class).getRootCause().hasMessageContaining("Data too long for column 'code'");
}
use of org.apache.gobblin.runtime.troubleshooter.Issue in project gobblin by apache.
the class MySqlMultiContextIssueRepositoryTest method canPutAndGetMinimalIssue.
@Test
public void canPutAndGetMinimalIssue() throws Exception {
Issue issue = Issue.builder().summary("Test summary").code("CODE1").time(ZonedDateTime.now().withNano(0).withZoneSameInstant(ZoneOffset.UTC)).severity(IssueSeverity.WARN).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 gobblin by apache.
the class MySqlMultiContextIssueRepositoryTest method willRollbackWhenSomeIssuesAreInvalid.
@Test
public void willRollbackWhenSomeIssuesAreInvalid() throws Exception {
Issue validIssue = getTestIssue("test", "test1");
Issue invalidIssue = Issue.builder().summary("Test summary").code(StringUtils.repeat("c", Issue.MAX_ISSUE_CODE_LENGTH * 2)).time(ZonedDateTime.now().withNano(0).withZoneSameInstant(ZoneOffset.UTC)).severity(IssueSeverity.WARN).build();
String contextId = "context-" + testId;
try {
repository.put(contextId, Arrays.asList(validIssue, invalidIssue));
} catch (TroubleshooterException ex) {
// exception is expected
}
List<Issue> issues = repository.getAll(contextId);
assertThat(issues).isEmpty();
}
use of org.apache.gobblin.runtime.troubleshooter.Issue in project gobblin by apache.
the class MySqlMultiContextIssueRepositoryTest method willPreserveIssueOrder.
@Test
public void willPreserveIssueOrder() throws Exception {
Random random = new Random(1);
List<Issue> issues = new ArrayList<>();
String contextId = "context-" + testId;
for (int i = 0; i < 100; i++) {
Issue issue = getTestIssue("test-" + random.nextInt(), "code-" + random.nextInt());
issues.add(issue);
repository.put(contextId, issue);
}
List<Issue> retrievedIssues = repository.getAll(contextId);
assertThat(retrievedIssues).usingRecursiveComparison().isEqualTo(issues);
}
Aggregations