Browse Source
* let quartz use the same datasource * move master/worker config from dao.properties to each config add master/worker registry test * move mybatis config from application.properties to SpringConnectionFactory * move mybatis-plus config from application.properties to SpringConnectionFactory * refactor TaskCallbackService * add ZookeeperNodeManagerTest * add NettyExecutorManagerTest * refactor TaskKillProcessor * add RandomSelectorTest, RoundRobinSelectorTest, TaskCallbackServiceTest * add RoundRobinHostManagerTest, ExecutorDispatcherTest * refactor task response service * add TaskResponseServiceTestpull/2/head
Tboy
5 years ago
committed by
GitHub
2 changed files with 129 additions and 37 deletions
@ -0,0 +1,66 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.apache.dolphinscheduler.server.master.processor.queue; |
||||
|
||||
|
||||
import org.apache.dolphinscheduler.common.enums.ExecutionStatus; |
||||
import org.apache.dolphinscheduler.server.registry.DependencyConfig; |
||||
import org.apache.dolphinscheduler.server.registry.ZookeeperNodeManager; |
||||
import org.apache.dolphinscheduler.server.registry.ZookeeperRegistryCenter; |
||||
import org.apache.dolphinscheduler.server.zk.SpringZKServer; |
||||
import org.apache.dolphinscheduler.service.zk.ZookeeperCachedOperator; |
||||
import org.apache.dolphinscheduler.service.zk.ZookeeperConfig; |
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
import org.junit.runner.RunWith; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.test.context.ContextConfiguration; |
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; |
||||
|
||||
import java.util.Date; |
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class) |
||||
@ContextConfiguration(classes={DependencyConfig.class, SpringZKServer.class, TaskResponseService.class, ZookeeperRegistryCenter.class, |
||||
ZookeeperCachedOperator.class, ZookeeperConfig.class, ZookeeperNodeManager.class, TaskResponseService.class}) |
||||
public class TaskResponseServiceTest { |
||||
|
||||
@Autowired |
||||
private TaskResponseService taskResponseService; |
||||
|
||||
@Test |
||||
public void testAdd(){ |
||||
TaskResponseEvent taskResponseEvent = TaskResponseEvent.newAck(ExecutionStatus.RUNNING_EXEUTION, new Date(), |
||||
"", "", "", 1); |
||||
taskResponseService.addResponse(taskResponseEvent); |
||||
Assert.assertTrue(taskResponseService.getEventQueue().size() == 1); |
||||
try { |
||||
Thread.sleep(10); |
||||
} catch (InterruptedException ignore) { |
||||
} |
||||
//after sleep, inner worker will take the event
|
||||
Assert.assertTrue(taskResponseService.getEventQueue().size() == 0); |
||||
} |
||||
|
||||
@Test |
||||
public void testStop(){ |
||||
TaskResponseEvent taskResponseEvent = TaskResponseEvent.newAck(ExecutionStatus.RUNNING_EXEUTION, new Date(), |
||||
"", "", "", 1); |
||||
taskResponseService.addResponse(taskResponseEvent); |
||||
taskResponseService.stop(); |
||||
Assert.assertTrue(taskResponseService.getEventQueue().size() == 0); |
||||
} |
||||
} |
Loading…
Reference in new issue