- [x] when condition下的线程池功能测试(基于springboot环境)

- [x] 线程池的基本功能点测试
  - [x] 线程池满了情况下基于errorResume参数的功能点测试
- [x] when并行组功能测试(基于springboot环境)
  - [x] 默认不配参数情况下并行组的功能点测试
  - [x] 配置相同并行组情况下的功能点测试
  - [x] 配置不同并行组情况下的功能点测试

测试用例提交
This commit is contained in:
meng.li
2021-04-08 11:49:06 +08:00
parent c1a495eea9
commit bb3638d583
3 changed files with 40 additions and 25 deletions

View File

@@ -4,6 +4,8 @@ import com.google.common.collect.Lists;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.entity.data.LiteflowResponse;
import com.yomahub.liteflow.entity.data.Slot;
import com.yomahub.liteflow.exception.FlowSystemException;
import com.yomahub.liteflow.exception.WhenExecuteException;
import com.yomahub.liteflow.test.BaseTest;
import org.junit.Assert;
import org.junit.Test;
@@ -35,9 +37,13 @@ public class BaseConditionFlowTest extends BaseTest {
@Resource
private FlowExecutor flowExecutor;
public static final List<String> RUN_TIME_SLOT = Lists.newArrayList();
public static List<String> RUN_TIME_SLOT = Lists.newArrayList();
//正常 then,when,多chain可以执行
/*****
* 标准chain 嵌套选择 嵌套子chain进行执行
* 验证了when情况下 多个node是并行执行
* 验证了默认参数情况下 when可以加载执行
* **/
@Test
public void testBaseConditionFlow() throws Exception {
LiteflowResponse<Slot> response = flowExecutor.execute("chain1", "it's a base request");
@@ -45,20 +51,31 @@ public class BaseConditionFlowTest extends BaseTest {
System.out.println(response.getData().printStep());
}
//正常 when 多个并联 合并 errorMessage参照上一组配置 导致error异常 都可以继续执行
/*****
* 标准chain
* 验证多层when 相同组 会合并node
* 验证多层when errorResume 合并 并参照最上层 errorResume配置
* **/
@Test
public void testBaseErrorResumeConditionFlow4() throws Exception {
RUN_TIME_SLOT.clear();
LiteflowResponse<Slot> response = flowExecutor.execute("chain4", "it's a base request");
Assert.assertTrue(response.isSuccess());
// 传递了slotIndex则set的size==2
Assert.assertEquals(2, RUN_TIME_SLOT.size());
// set中第一次设置的requestId和response中的requestId一致
Assert.assertTrue(RUN_TIME_SLOT.contains(response.getData().getRequestId()));
}
//正常 when 多个并联 合并 errorMessage参照上一组配置 导致error异常 直接第一组error 就拦截
/*****
* 标准chain
* 验证多层when 相同组 会合并node
* 验证多层when errorResume 合并 并参照最上层 errorResume配置
* **/
@Test
public void testBaseErrorResumeConditionFlow5() throws Exception {
RUN_TIME_SLOT.clear();
LiteflowResponse<Slot> response = flowExecutor.execute("chain5", "it's a base request");
System.out.println(response.isSuccess());
System.out.println(response.getData().printStep());
@@ -67,10 +84,17 @@ public class BaseConditionFlowTest extends BaseTest {
Assert.assertEquals(2, RUN_TIME_SLOT.size());
// set中第一次设置的requestId和response中的requestId一致
Assert.assertTrue(RUN_TIME_SLOT.contains(response.getData().getRequestId()));
}
@Test
/*****
* 标准chain
* 验证多层when 不同组 不会合并node
* 验证多层when errorResume 不同组 配置分开配置
* **/
@Test(expected = WhenExecuteException.class)
public void testBaseErrorResumeConditionFlow6() throws Exception {
RUN_TIME_SLOT.clear();
LiteflowResponse<Slot> response = flowExecutor.execute("chain6", "it's a base request");
System.out.println(response.isSuccess());
System.out.println(response.getData().printStep());
@@ -80,11 +104,17 @@ public class BaseConditionFlowTest extends BaseTest {
// set中第一次设置的requestId和response中的requestId一致
Assert.assertTrue(RUN_TIME_SLOT.contains(response.getData().getRequestId()));
ReflectionUtils.rethrowException(response.getCause());
}
@Test
/*****
* 标准chain
* 验证多层when 不同组 不会合并node
* 验证多层when errorResume 不同组 配置分开配置
* **/
@Test(expected = WhenExecuteException.class)
public void testBaseErrorResumeConditionFlow7() throws Exception {
RUN_TIME_SLOT.clear();
LiteflowResponse<Slot> response = flowExecutor.execute("chain7", "it's a base request");
System.out.println(response.isSuccess());
System.out.println(response.getData().printStep());
@@ -93,17 +123,7 @@ public class BaseConditionFlowTest extends BaseTest {
Assert.assertEquals(2, BaseConditionFlowTest.RUN_TIME_SLOT.size());
// set中第一次设置的requestId和response中的requestId一致
Assert.assertTrue(RUN_TIME_SLOT.contains(response.getData().getRequestId()));
}
ReflectionUtils.rethrowException(response.getCause());
@Test
public void testBaseErrorResumeConditionFlow8() throws Exception {
LiteflowResponse<Slot> response = flowExecutor.execute("chain8", "it's a base request");
System.out.println(response.isSuccess());
System.out.println(response.getData().printStep());
Assert.assertFalse(response.isSuccess());
// 传递了slotIndex则set的size==2
Assert.assertEquals(2, BaseConditionFlowTest.RUN_TIME_SLOT.size());
// set中第一次设置的requestId和response中的requestId一致
Assert.assertTrue(RUN_TIME_SLOT.contains(response.getData().getRequestId()));
}
}

View File

@@ -8,6 +8,7 @@ import org.springframework.stereotype.Component;
public class DCmp extends NodeComponent {
@Override
public void process() throws Exception {
Thread.sleep(3000);
System.out.println("Dcomp executed!");
}
}

View File

@@ -3,7 +3,6 @@
<!-- base test -->
<chain name="chain1">
<then value="a,b,c"/> <!-- a b c 串联执行-->
<then value="c"/>
<when value="d,e(f|g)"/> <!-- e d 并联执行-->
<then value="chain2"/>
</chain>
@@ -13,7 +12,7 @@
</chain>
<chain name="chain3">
<then value="f,g,h"/>
<when value="f,g,h"/>
</chain>
<chain name="chain4">
@@ -40,10 +39,5 @@
<when value="g,i,h" errorResume="false" group="2"/><!-- 此时 g i h 与 d i并联执行 并且默认异常抛出-->
</chain>
<chain name="chain8">
<then value="a,b,c"/> <!-- a b c 串联执行-->
<when value="d,i" errorResume="true" group="1"/> <!-- d i 并联执行-->
<when value="g,i,h" errorResume="false" group="2"/><!-- 此时 g i h 与 d i并联执行 并且默认异常抛出-->
</chain>
<!-- base test -->
</flow>