增加脚本平滑刷新的测试用例

This commit is contained in:
bryan31
2021-11-11 13:05:39 +08:00
parent 263fcd857b
commit 4387155d6e
4 changed files with 88 additions and 0 deletions

View File

@@ -67,4 +67,26 @@ public class LiteflowJsonScriptFileGroovyTest extends BaseTest {
Assert.assertTrue(responseNew.isSuccess());
Assert.assertEquals("d==>s2[条件脚本_改]==>b==>s3[普通脚本_新增]", responseNew.getSlot().printStep());
}
//测试脚本&规则平滑重载刷新
@Test
public void testScript4() throws Exception{
new Thread(() -> {
try{
Thread.sleep(1000L);
//更改规则重新加载更改的规则内容从flow_update.xml里读取这里只是为了模拟下获取新的内容。不一定是从文件中读取
String newContent = ResourceUtil.readUtf8Str("classpath: /json-script-file/flow_update.json");
//进行刷新
FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_JSON, newContent);
}catch (Exception e){
e.printStackTrace();
}
}).start();
for (int i = 0; i < 500; i++) {
LiteflowResponse<DefaultSlot> responseNew = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(responseNew.isSuccess());
Thread.sleep(10L);
}
}
}

View File

@@ -67,4 +67,26 @@ public class LiteflowXmlScriptFileGroovyTest extends BaseTest {
Assert.assertTrue(responseNew.isSuccess());
Assert.assertEquals("d==>s2[条件脚本_改]==>b==>s3[普通脚本_新增]", responseNew.getSlot().printStep());
}
//测试脚本&规则平滑重载刷新
@Test
public void testScript4() throws Exception{
new Thread(() -> {
try{
Thread.sleep(1000L);
//更改规则重新加载更改的规则内容从flow_update.xml里读取这里只是为了模拟下获取新的内容。不一定是从文件中读取
String newContent = ResourceUtil.readUtf8Str("classpath: /xml-script-file/flow_update.xml");
//进行刷新
FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_XML, newContent);
}catch (Exception e){
e.printStackTrace();
}
}).start();
for (int i = 0; i < 500; i++) {
LiteflowResponse<DefaultSlot> responseNew = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(responseNew.isSuccess());
Thread.sleep(10L);
}
}
}

View File

@@ -66,4 +66,26 @@ public class LiteflowJsonScriptFileQLExpressTest extends BaseTest {
Assert.assertTrue(responseNew.isSuccess());
Assert.assertEquals("d==>s2[条件脚本_改]==>a==>s3[普通脚本_新增]", responseNew.getSlot().printStep());
}
//测试脚本&规则平滑重载刷新
@Test
public void testScript4() throws Exception{
new Thread(() -> {
try{
Thread.sleep(1000L);
//更改规则重新加载更改的规则内容从flow_update.xml里读取这里只是为了模拟下获取新的内容。不一定是从文件中读取
String newContent = ResourceUtil.readUtf8Str("classpath: /json-script-file/flow_update.json");
//进行刷新
FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_JSON, newContent);
}catch (Exception e){
e.printStackTrace();
}
}).start();
for (int i = 0; i < 500; i++) {
LiteflowResponse<DefaultSlot> responseNew = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(responseNew.isSuccess());
Thread.sleep(10L);
}
}
}

View File

@@ -66,4 +66,26 @@ public class LiteflowXmlScriptFileQLExpressTest extends BaseTest {
Assert.assertTrue(responseNew.isSuccess());
Assert.assertEquals("d==>s2[条件脚本_改]==>a==>s3[普通脚本_新增]", responseNew.getSlot().printStep());
}
//测试脚本&规则平滑重载刷新
@Test
public void testScript4() throws Exception{
new Thread(() -> {
try{
Thread.sleep(1000L);
//更改规则重新加载更改的规则内容从flow_update.xml里读取这里只是为了模拟下获取新的内容。不一定是从文件中读取
String newContent = ResourceUtil.readUtf8Str("classpath: /xml-script-file/flow_update.xml");
//进行刷新
FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_XML, newContent);
}catch (Exception e){
e.printStackTrace();
}
}).start();
for (int i = 0; i < 500; i++) {
LiteflowResponse<DefaultSlot> responseNew = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(responseNew.isSuccess());
Thread.sleep(10L);
}
}
}