use of com.vip.saturn.it.utils.LogbackListAppender in project Saturn by vipshop.
the class LocalModeIT method test_D_fixIssue441.
@Test
public void test_D_fixIssue441() throws Exception {
LogbackListAppender logbackListAppender = new LogbackListAppender();
logbackListAppender.addToLogger(AbstractAsyncShardingTask.class);
logbackListAppender.start();
final int items = 4;
final String jobName = "test_D_fixIssue441";
JobConfig jobConfig = new JobConfig();
jobConfig.setJobName(jobName);
jobConfig.setCron("*/1 * * * * ?");
jobConfig.setJobType(JobType.JAVA_JOB.toString());
jobConfig.setProcessCountIntervalSeconds(1);
jobConfig.setJobClass(SimpleJavaJob.class.getCanonicalName());
jobConfig.setShardingItemParameters("*=0");
jobConfig.setLocalMode(true);
addJob(jobConfig);
Thread.sleep(1000);
enableJob(jobName);
Thread.sleep(1000);
startExecutorList(items);
waitForFinish(new FinishCheck() {
@Override
public boolean isOk() {
for (int i = 0; i < items; i++) {
if (SimpleJavaJob.statusMap.get(jobName + "_" + i) <= 0) {
return false;
}
}
return true;
}
}, 30);
// 下线0,1,2
stopExecutorGracefully(0);
stopExecutorGracefully(1);
stopExecutorGracefully(2);
// 上线一个executor
startOneNewExecutorList();
List<ILoggingEvent> allLogs = logbackListAppender.getAllLogs();
Iterator<ILoggingEvent> iterator = allLogs.iterator();
while (iterator.hasNext()) {
ILoggingEvent event = iterator.next();
if (event != null) {
IThrowableProxy throwableProxy = event.getThrowableProxy();
if (throwableProxy != null) {
assertThat(throwableProxy.getClassName()).isNotEqualTo("java.lang.ArrayIndexOutOfBoundsException");
}
}
}
disableJob(jobName);
Thread.sleep(1000);
removeJob(jobName);
}
Aggregations