Search in sources :

Example 31 with Issue

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");
}
Also used : LoggingEvent(org.apache.log4j.spi.LoggingEvent) Issue(org.apache.gobblin.runtime.troubleshooter.Issue) IOException(java.io.IOException) InvalidOperationException(org.apache.hadoop.hive.metastore.api.InvalidOperationException) Test(org.testng.annotations.Test)

Example 32 with Issue

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'");
}
Also used : Issue(org.apache.gobblin.runtime.troubleshooter.Issue) Test(org.testng.annotations.Test)

Example 33 with Issue

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);
}
Also used : Issue(org.apache.gobblin.runtime.troubleshooter.Issue) Test(org.testng.annotations.Test)

Example 34 with 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();
}
Also used : TroubleshooterException(org.apache.gobblin.runtime.troubleshooter.TroubleshooterException) Issue(org.apache.gobblin.runtime.troubleshooter.Issue) Test(org.testng.annotations.Test)

Example 35 with Issue

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);
}
Also used : Issue(org.apache.gobblin.runtime.troubleshooter.Issue) Random(java.util.Random) ArrayList(java.util.ArrayList) Test(org.testng.annotations.Test)

Aggregations

Issue (org.apache.gobblin.runtime.troubleshooter.Issue)48 Test (org.testng.annotations.Test)32 TroubleshooterException (org.apache.gobblin.runtime.troubleshooter.TroubleshooterException)10 ArrayList (java.util.ArrayList)8 LoggingEvent (org.apache.log4j.spi.LoggingEvent)8 IOException (java.io.IOException)6 HashMap (java.util.HashMap)6 InvalidOperationException (org.apache.hadoop.hive.metastore.api.InvalidOperationException)6 Connection (java.sql.Connection)4 PreparedStatement (java.sql.PreparedStatement)4 SQLException (java.sql.SQLException)4 Random (java.util.Random)4 TextStringBuilder (org.apache.commons.text.TextStringBuilder)4 StringMap (com.linkedin.data.template.StringMap)2 Type (java.lang.reflect.Type)2 ResultSet (java.sql.ResultSet)2 Timestamp (java.sql.Timestamp)2 ZonedDateTime (java.time.ZonedDateTime)2 WorkUnitState (org.apache.gobblin.configuration.WorkUnitState)2 IssueEventBuilder (org.apache.gobblin.runtime.troubleshooter.IssueEventBuilder)2