use of org.apache.gobblin.runtime.troubleshooter.Issue in project incubator-gobblin by apache.
the class MySqlMultiContextIssueRepositoryTest method canPutIssueWithMaximumFieldLengths.
@Test
public void canPutIssueWithMaximumFieldLengths() throws Exception {
// summary and details are bounded at 16MB, so we just put reasonably large values there
Issue issue = Issue.builder().summary(StringUtils.repeat("s", 100000)).details(StringUtils.repeat("s", 100000)).code(StringUtils.repeat("c", Issue.MAX_ISSUE_CODE_LENGTH)).exceptionClass(StringUtils.repeat("e", Issue.MAX_CLASSNAME_LENGTH)).sourceClass(StringUtils.repeat("s", Issue.MAX_CLASSNAME_LENGTH)).time(ZonedDateTime.now().withNano(0).withZoneSameInstant(ZoneOffset.UTC)).severity(IssueSeverity.WARN).build();
String contextId = TroubleshooterUtils.getContextIdForJob(StringUtils.repeat("g", ServiceConfigKeys.MAX_FLOW_GROUP_LENGTH), StringUtils.repeat("f", ServiceConfigKeys.MAX_FLOW_NAME_LENGTH), String.valueOf(Long.MAX_VALUE), StringUtils.repeat("j", ServiceConfigKeys.MAX_JOB_NAME_LENGTH));
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 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 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 incubator-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 incubator-gobblin by apache.
the class MySqlMultiContextIssueRepositoryTest method canRemoveIssue.
@Test
public void canRemoveIssue() throws Exception {
Issue issue1 = getTestIssue("test-1", "code1");
Issue issue2 = getTestIssue("test-2", "code2");
Issue issue3 = getTestIssue("test-3", "code3");
String contextId = "context-1-" + testId;
repository.put(contextId, issue1);
repository.put(contextId, issue2);
repository.put(contextId, issue3);
repository.remove(contextId, issue2.getCode());
List<Issue> issues = repository.getAll(contextId);
assertThat(issues).hasSize(2);
assertThat(issues.get(0)).usingRecursiveComparison().isEqualTo(issue1);
assertThat(issues.get(1)).usingRecursiveComparison().isEqualTo(issue3);
}
Aggregations