Merge remote-tracking branch 'origin/v2.0.5_dev' into v2.0.5_dev

This commit is contained in:
HuangXin 2021-01-15 09:36:01 +08:00
commit c3552d4654
2 changed files with 10 additions and 10 deletions

View File

@ -33,9 +33,12 @@ public class TemplateServiceImpl implements TemplateService {
// 判断类型是否一致 // 判断类型是否一致
if (v.getType().equals(type)) { if (v.getType().equals(type)) {
// 当前带宽大于当前模板最小值 // 当前带宽大于当前模板最小值
if (bandWidth > v.getBandMin()) { if (bandWidth > v.getBandMin() || bandWidth == 0) {
// 模板最大值为-1或者带宽小于等于模板最小值返回模板名称 // 模板最大值为-1或者带宽小于等于模板最小值返回模板名称
if (v.getBandMax() == -1 || bandWidth <= v.getBandMax()) { if (v.getBandMax() == -1 && bandWidth != 0) {
log.debug("Template analyze: {}, {} match {}", type, bandWidth, v);
return v.getName();
} else if (bandWidth <= v.getBandMax() && bandWidth >= v.getBandMin()) {
log.debug("Template analyze: {}, {} match {}", type, bandWidth, v); log.debug("Template analyze: {}, {} match {}", type, bandWidth, v);
return v.getName(); return v.getName();
} }

View File

@ -32,32 +32,29 @@ public class TemplateServiceTest extends InitTestEnvironment {
public void getTemplateTest() { public void getTemplateTest() {
Assert.assertEquals("Game_Server_10G", templateService.getTemplate("GAME",1600L)); Assert.assertEquals("Game_Server_10G", templateService.getTemplate("GAME",1600L));
Assert.assertEquals("Game_Server_10G", templateService.getTemplate("GAME", (long) 1500.5));
Assert.assertEquals("Game_Server_1G", templateService.getTemplate("GAME",1500L)); Assert.assertEquals("Game_Server_1G", templateService.getTemplate("GAME",1500L));
Assert.assertEquals("Game_Server_1G", templateService.getTemplate("GAME",(long) 1499.5));
Assert.assertEquals("Game_Server_1G", templateService.getTemplate("GAME", 1L));
Assert.assertEquals("Game_Server_1G", templateService.getTemplate("GAME", 100L)); Assert.assertEquals("Game_Server_1G", templateService.getTemplate("GAME", 100L));
Assert.assertEquals("Game_Server_1G", templateService.getTemplate("GAME", 1L));
Assert.assertEquals("Game_Server_1G", templateService.getTemplate("GAME", 0L));
Assert.assertNull(templateService.getTemplate("GAME",-1L)); Assert.assertNull(templateService.getTemplate("GAME",-1L));
log.info("GAME, 0L-----------template: {}", templateService.getTemplate("GAME", 0L));
log.info("GAME, 0.9-----------template: {}", templateService.getTemplate("GAME", (long) 0.9));
Assert.assertEquals("DNS_Server_10G", templateService.getTemplate("DNS",1600L)); Assert.assertEquals("DNS_Server_10G", templateService.getTemplate("DNS",1600L));
Assert.assertEquals("DNS_Server_1G", templateService.getTemplate("DNS",1500L)); Assert.assertEquals("DNS_Server_1G", templateService.getTemplate("DNS",1500L));
Assert.assertEquals("DNS_Server_1G", templateService.getTemplate("DNS",1L)); Assert.assertEquals("DNS_Server_1G", templateService.getTemplate("DNS",1L));
//Assert.assertEquals("Game_Server_1G", templateService.getTemplate("DNS",0L)); Assert.assertEquals("DNS_Server_1G", templateService.getTemplate("DNS",0L));
Assert.assertNull(templateService.getTemplate("DNS",-1L)); Assert.assertNull(templateService.getTemplate("DNS",-1L));
Assert.assertEquals("WEB_Server_10G", templateService.getTemplate("WEB",1600L)); Assert.assertEquals("WEB_Server_10G", templateService.getTemplate("WEB",1600L));
Assert.assertEquals("WEB_Server_1G", templateService.getTemplate("WEB",1500L)); Assert.assertEquals("WEB_Server_1G", templateService.getTemplate("WEB",1500L));
Assert.assertEquals("WEB_Server_1G", templateService.getTemplate("WEB",1L)); Assert.assertEquals("WEB_Server_1G", templateService.getTemplate("WEB",1L));
//Assert.assertEquals("Game_Server_1G", templateService.getTemplate("WEB",0L)); Assert.assertEquals("WEB_Server_1G", templateService.getTemplate("WEB",0L));
Assert.assertNull(templateService.getTemplate("WEB",-1L)); Assert.assertNull(templateService.getTemplate("WEB",-1L));
Assert.assertEquals("General_Server_10G", templateService.getTemplate("GENERAL",1600L)); Assert.assertEquals("General_Server_10G", templateService.getTemplate("GENERAL",1600L));
Assert.assertEquals("General_Server_1G", templateService.getTemplate("GENERAL",1500L)); Assert.assertEquals("General_Server_1G", templateService.getTemplate("GENERAL",1500L));
Assert.assertEquals("General_Server_100M", templateService.getTemplate("GENERAL",500L)); Assert.assertEquals("General_Server_100M", templateService.getTemplate("GENERAL",500L));
Assert.assertEquals("General_Server_100M", templateService.getTemplate("GENERAL",1L)); Assert.assertEquals("General_Server_100M", templateService.getTemplate("GENERAL",1L));
//Assert.assertEquals("General_Server_100M", templateService.getTemplate("GENERAL",0L)); Assert.assertEquals("General_Server_100M", templateService.getTemplate("GENERAL",0L));
Assert.assertNull(templateService.getTemplate("GENERAL",-1L)); Assert.assertNull(templateService.getTemplate("GENERAL",-1L));
Assert.assertNull(templateService.getTemplate("ALL",100L)); Assert.assertNull(templateService.getTemplate("ALL",100L));