REM:
1. 处理浩瀚设备测试用例在jenkins中无法访问设备报错问题
This commit is contained in:
HuangXin 2020-07-08 08:44:18 +08:00
parent d888e61d8e
commit 121c94a5ba
1 changed files with 201 additions and 163 deletions

View File

@ -1,6 +1,8 @@
package com.dispose.test.haohan; package com.dispose.test.haohan;
import com.dispose.common.GlobalVar;
import com.dispose.common.Http; import com.dispose.common.Http;
import com.dispose.test.Global.InitTestEnvironment;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -18,12 +20,17 @@ import javax.annotation.Resource;
@Slf4j @Slf4j
@SpringBootTest @SpringBootTest
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class HaoHanInterfaceTestCase { public class HaoHanInterfaceTestCase extends InitTestEnvironment {
@Resource @Resource
private ObjectMapper objectMapper; private ObjectMapper objectMapper;
@Override
public void userLogin(){
}
@Test @Test
public void a1_sendTowWhitelistTest() throws JsonProcessingException { public void a1_sendTowWhitelistTest() throws JsonProcessingException {
if (!GlobalVar.USED_VIRTUAL_DISPOSE_MODE) {
String jsonRequest = "{\"ip\":\"192.168.1.1\",\"orderFrom\":\"hangyan\"}"; String jsonRequest = "{\"ip\":\"192.168.1.1\",\"orderFrom\":\"hangyan\"}";
String svrReturn = Http.postJson("http://10.88.77.88:18080/DDoSClean/clean/sendTow", String svrReturn = Http.postJson("http://10.88.77.88:18080/DDoSClean/clean/sendTow",
null, null,
@ -36,9 +43,11 @@ public class HaoHanInterfaceTestCase {
Assert.assertEquals(result.getMsg(), HaoHanErrorCode.ERR_WHITELIST.getMsg()); Assert.assertEquals(result.getMsg(), HaoHanErrorCode.ERR_WHITELIST.getMsg());
Assert.assertEquals(result.getState(), Integer.valueOf(1)); Assert.assertEquals(result.getState(), Integer.valueOf(1));
} }
}
@Test @Test
public void a2_sendTowWhitelistContainsDurationTest() throws JsonProcessingException { public void a2_sendTowWhitelistContainsDurationTest() throws JsonProcessingException {
if (!GlobalVar.USED_VIRTUAL_DISPOSE_MODE) {
String jsonRequest = "{\"ip\":\"192.168.1.1\",\"duration\":20, \"orderFrom\":\"hangyan\"}"; String jsonRequest = "{\"ip\":\"192.168.1.1\",\"duration\":20, \"orderFrom\":\"hangyan\"}";
String svrReturn = Http.postJson("http://10.88.77.88:18080/DDoSClean/clean/sendTow", String svrReturn = Http.postJson("http://10.88.77.88:18080/DDoSClean/clean/sendTow",
null, null,
@ -51,9 +60,11 @@ public class HaoHanInterfaceTestCase {
Assert.assertEquals(result.getMsg(), HaoHanErrorCode.ERR_WHITELIST.getMsg()); Assert.assertEquals(result.getMsg(), HaoHanErrorCode.ERR_WHITELIST.getMsg());
Assert.assertEquals(result.getState(), Integer.valueOf(1)); Assert.assertEquals(result.getState(), Integer.valueOf(1));
} }
}
@Test @Test
public void a3_normalSendTowTest() throws JsonProcessingException { public void a3_normalSendTowTest() throws JsonProcessingException {
if (!GlobalVar.USED_VIRTUAL_DISPOSE_MODE) {
String jsonRequest = "{\"ip\":\"192.168.1.2\",\"orderFrom\":\"hangyan\"}"; String jsonRequest = "{\"ip\":\"192.168.1.2\",\"orderFrom\":\"hangyan\"}";
String svrReturn = Http.postJson("http://10.88.77.88:18080/DDoSClean/clean/sendTow", String svrReturn = Http.postJson("http://10.88.77.88:18080/DDoSClean/clean/sendTow",
null, null,
@ -70,9 +81,11 @@ public class HaoHanInterfaceTestCase {
Assert.assertNotEquals(result.getMsg(), HaoHanErrorCode.ERR_OK.getMsg()); Assert.assertNotEquals(result.getMsg(), HaoHanErrorCode.ERR_OK.getMsg());
} }
} }
}
@Test @Test
public void a4_normalSendTowContainsDurationTest() throws JsonProcessingException { public void a4_normalSendTowContainsDurationTest() throws JsonProcessingException {
if (!GlobalVar.USED_VIRTUAL_DISPOSE_MODE) {
String jsonRequest = "{\"ip\":\"192.168.1.20\",\"duration\":20,\"orderFrom\":\"hangyan\"}"; String jsonRequest = "{\"ip\":\"192.168.1.20\",\"duration\":20,\"orderFrom\":\"hangyan\"}";
String svrReturn = Http.postJson("http://10.88.77.88:18080/DDoSClean/clean/sendTow", String svrReturn = Http.postJson("http://10.88.77.88:18080/DDoSClean/clean/sendTow",
null, null,
@ -89,9 +102,11 @@ public class HaoHanInterfaceTestCase {
Assert.assertNotEquals(result.getMsg(), HaoHanErrorCode.ERR_OK.getMsg()); Assert.assertNotEquals(result.getMsg(), HaoHanErrorCode.ERR_OK.getMsg());
} }
} }
}
@Test @Test
public void a5_sendTowIpErrorTest() throws JsonProcessingException { public void a5_sendTowIpErrorTest() throws JsonProcessingException {
if (!GlobalVar.USED_VIRTUAL_DISPOSE_MODE) {
String jsonRequest = "{\"ip\":\"192.168.120\",\"duration\":20,\"orderFrom\":\"hangyan\"}"; String jsonRequest = "{\"ip\":\"192.168.120\",\"duration\":20,\"orderFrom\":\"hangyan\"}";
String svrReturn = Http.postJson("http://10.88.77.88:18080/DDoSClean/clean/sendTow", String svrReturn = Http.postJson("http://10.88.77.88:18080/DDoSClean/clean/sendTow",
null, null,
@ -104,9 +119,11 @@ public class HaoHanInterfaceTestCase {
Assert.assertEquals(result.getMsg(), HaoHanErrorCode.ERR_DISPOSEIPFORMAT.getMsg()); Assert.assertEquals(result.getMsg(), HaoHanErrorCode.ERR_DISPOSEIPFORMAT.getMsg());
Assert.assertEquals(result.getState(), Integer.valueOf(1)); Assert.assertEquals(result.getState(), Integer.valueOf(1));
} }
}
@Test @Test
public void a6_sendTowDurationErrorTest() throws JsonProcessingException { public void a6_sendTowDurationErrorTest() throws JsonProcessingException {
if (!GlobalVar.USED_VIRTUAL_DISPOSE_MODE) {
String jsonRequest = "{\"ip\":\"192.168.1.20\",\"duration\":\"20\",\"orderFrom\":\"hangyan\"}"; String jsonRequest = "{\"ip\":\"192.168.1.20\",\"duration\":\"20\",\"orderFrom\":\"hangyan\"}";
String svrReturn = Http.postJson("http://10.88.77.88:18080/DDoSClean/clean/sendTow", String svrReturn = Http.postJson("http://10.88.77.88:18080/DDoSClean/clean/sendTow",
null, null,
@ -119,9 +136,11 @@ public class HaoHanInterfaceTestCase {
Assert.assertEquals(result.getMsg(), HaoHanErrorCode.ERR_DURATIONFORMAT.getMsg()); Assert.assertEquals(result.getMsg(), HaoHanErrorCode.ERR_DURATIONFORMAT.getMsg());
Assert.assertEquals(result.getState(), Integer.valueOf(1)); Assert.assertEquals(result.getState(), Integer.valueOf(1));
} }
}
@Test @Test
public void a7_sendTowOrderFromErrorTest() throws JsonProcessingException { public void a7_sendTowOrderFromErrorTest() throws JsonProcessingException {
if (!GlobalVar.USED_VIRTUAL_DISPOSE_MODE) {
String jsonRequest = "{\"ip\":\"192.168.1.20\",\"duration\":20,\"orderFrom\":123}"; String jsonRequest = "{\"ip\":\"192.168.1.20\",\"duration\":20,\"orderFrom\":123}";
String svrReturn = Http.postJson("http://10.88.77.88:18080/DDoSClean/clean/sendTow", String svrReturn = Http.postJson("http://10.88.77.88:18080/DDoSClean/clean/sendTow",
null, null,
@ -134,10 +153,12 @@ public class HaoHanInterfaceTestCase {
Assert.assertEquals(result.getMsg(), HaoHanErrorCode.ERR_ORDERFROMFORMA.getMsg()); Assert.assertEquals(result.getMsg(), HaoHanErrorCode.ERR_ORDERFROMFORMA.getMsg());
Assert.assertEquals(result.getState(), Integer.valueOf(1)); Assert.assertEquals(result.getState(), Integer.valueOf(1));
} }
}
@Test @Test
public void b1_delTowTest() throws JsonProcessingException { public void b1_delTowTest() throws JsonProcessingException {
if (!GlobalVar.USED_VIRTUAL_DISPOSE_MODE) {
String jsonRequest = "{\"cleanTaskId\":105,\"orderFrom\":\"hangyan\"}"; String jsonRequest = "{\"cleanTaskId\":105,\"orderFrom\":\"hangyan\"}";
String svrReturn = Http.postJson("http://10.88.77.88:18080/DDoSClean/clean/delTow", String svrReturn = Http.postJson("http://10.88.77.88:18080/DDoSClean/clean/delTow",
null, null,
@ -153,9 +174,11 @@ public class HaoHanInterfaceTestCase {
Assert.assertNotEquals(result.getMsg(), HaoHanErrorCode.ERR_OK.getMsg()); Assert.assertNotEquals(result.getMsg(), HaoHanErrorCode.ERR_OK.getMsg());
} }
} }
}
@Test @Test
public void b2_delTowCleanTaskIdErrorTest() throws JsonProcessingException { public void b2_delTowCleanTaskIdErrorTest() throws JsonProcessingException {
if (!GlobalVar.USED_VIRTUAL_DISPOSE_MODE) {
String jsonRequest = "{\"cleanTaskId\":\"105\",\"orderFrom\":\"hangyan\"}"; String jsonRequest = "{\"cleanTaskId\":\"105\",\"orderFrom\":\"hangyan\"}";
String svrReturn = Http.postJson("http://10.88.77.88:18080/DDoSClean/clean/delTow", String svrReturn = Http.postJson("http://10.88.77.88:18080/DDoSClean/clean/delTow",
null, null,
@ -168,9 +191,11 @@ public class HaoHanInterfaceTestCase {
Assert.assertEquals(result.getMsg(), HaoHanErrorCode.ERR_CLEANTASKIDFORMA.getMsg()); Assert.assertEquals(result.getMsg(), HaoHanErrorCode.ERR_CLEANTASKIDFORMA.getMsg());
Assert.assertEquals(result.getState(), Integer.valueOf(1)); Assert.assertEquals(result.getState(), Integer.valueOf(1));
} }
}
@Test @Test
public void b3_delTowOrderFromErrorTest() throws JsonProcessingException { public void b3_delTowOrderFromErrorTest() throws JsonProcessingException {
if (!GlobalVar.USED_VIRTUAL_DISPOSE_MODE) {
String jsonRequest = "{\"cleanTaskId\":105,\"orderFrom\":123}"; String jsonRequest = "{\"cleanTaskId\":105,\"orderFrom\":123}";
String svrReturn = Http.postJson("http://10.88.77.88:18080/DDoSClean/clean/delTow", String svrReturn = Http.postJson("http://10.88.77.88:18080/DDoSClean/clean/delTow",
null, null,
@ -183,9 +208,11 @@ public class HaoHanInterfaceTestCase {
Assert.assertEquals(result.getMsg(), HaoHanErrorCode.ERR_ORDERFROMFORMA.getMsg()); Assert.assertEquals(result.getMsg(), HaoHanErrorCode.ERR_ORDERFROMFORMA.getMsg());
Assert.assertEquals(result.getState(), Integer.valueOf(1)); Assert.assertEquals(result.getState(), Integer.valueOf(1));
} }
}
@Test @Test
public void c1_allIpFlowTest() throws JsonProcessingException { public void c1_allIpFlowTest() throws JsonProcessingException {
if (!GlobalVar.USED_VIRTUAL_DISPOSE_MODE) {
String jsonRequest = "{\"orderFrom\":\"hangyan\"}"; String jsonRequest = "{\"orderFrom\":\"hangyan\"}";
String svrReturn = Http.postJson("http://10.88.77.88:18080/DDoSClean/clean/allIpFlow", String svrReturn = Http.postJson("http://10.88.77.88:18080/DDoSClean/clean/allIpFlow",
null, null,
@ -205,9 +232,11 @@ public class HaoHanInterfaceTestCase {
Assert.assertEquals(result.getMsg(), HaoHanErrorCode.ERR_NORUNNINGTASK.getMsg()); Assert.assertEquals(result.getMsg(), HaoHanErrorCode.ERR_NORUNNINGTASK.getMsg());
} }
} }
}
@Test @Test
public void c2_allIpFlowTest() throws JsonProcessingException { public void c2_allIpFlowTest() throws JsonProcessingException {
if (!GlobalVar.USED_VIRTUAL_DISPOSE_MODE) {
String jsonRequest = "{\"orderFrom\":123}"; String jsonRequest = "{\"orderFrom\":123}";
String svrReturn = Http.postJson("http://10.88.77.88:18080/DDoSClean/clean/allIpFlow", String svrReturn = Http.postJson("http://10.88.77.88:18080/DDoSClean/clean/allIpFlow",
null, null,
@ -220,9 +249,11 @@ public class HaoHanInterfaceTestCase {
Assert.assertEquals(result.getMsg(), HaoHanErrorCode.ERR_ORDERFROMFORMA.getMsg()); Assert.assertEquals(result.getMsg(), HaoHanErrorCode.ERR_ORDERFROMFORMA.getMsg());
Assert.assertEquals(result.getState(), Integer.valueOf(1)); Assert.assertEquals(result.getState(), Integer.valueOf(1));
} }
}
@Test @Test
public void d1_cleanTaskFlowTest() throws JsonProcessingException { public void d1_cleanTaskFlowTest() throws JsonProcessingException {
if (!GlobalVar.USED_VIRTUAL_DISPOSE_MODE) {
String jsonRequest = "{\"cleanTaskId\":119}"; String jsonRequest = "{\"cleanTaskId\":119}";
String svrReturn = Http.postJson("http://10.88.77.88:18080/DDoSClean/clean/cleanTaskFlow", String svrReturn = Http.postJson("http://10.88.77.88:18080/DDoSClean/clean/cleanTaskFlow",
null, null,
@ -242,9 +273,11 @@ public class HaoHanInterfaceTestCase {
Assert.assertEquals(result.getMsg(), HaoHanErrorCode.ERR_TASKNOEND.getMsg()); Assert.assertEquals(result.getMsg(), HaoHanErrorCode.ERR_TASKNOEND.getMsg());
} }
} }
}
@Test @Test
public void d2_cleanTaskFlowTest() throws JsonProcessingException { public void d2_cleanTaskFlowTest() throws JsonProcessingException {
if (!GlobalVar.USED_VIRTUAL_DISPOSE_MODE) {
String jsonRequest = "{\"cleanTaskId\":\"abc\"}"; String jsonRequest = "{\"cleanTaskId\":\"abc\"}";
String svrReturn = Http.postJson("http://10.88.77.88:18080/DDoSClean/clean/cleanTaskFlow", String svrReturn = Http.postJson("http://10.88.77.88:18080/DDoSClean/clean/cleanTaskFlow",
null, null,
@ -255,9 +288,11 @@ public class HaoHanInterfaceTestCase {
Assert.assertNotNull(result); Assert.assertNotNull(result);
Assert.assertEquals(result.getMsg(), HaoHanErrorCode.ERR_CLEANTASKIDFORMA.getMsg()); Assert.assertEquals(result.getMsg(), HaoHanErrorCode.ERR_CLEANTASKIDFORMA.getMsg());
} }
}
@Test @Test
public void e1_getCleanTaskStateTest() throws JsonProcessingException { public void e1_getCleanTaskStateTest() throws JsonProcessingException {
if (!GlobalVar.USED_VIRTUAL_DISPOSE_MODE) {
String jsonRequest = "{\"cleanTaskId\":119}"; String jsonRequest = "{\"cleanTaskId\":119}";
String svrReturn = Http.postJson("http://10.88.77.88:18080/DDoSClean/clean/getCleanTaskState", String svrReturn = Http.postJson("http://10.88.77.88:18080/DDoSClean/clean/getCleanTaskState",
null, null,
@ -273,9 +308,11 @@ public class HaoHanInterfaceTestCase {
Assert.assertEquals(result.getMsg(), HaoHanErrorCode.ERR_NOTASK.getMsg()); Assert.assertEquals(result.getMsg(), HaoHanErrorCode.ERR_NOTASK.getMsg());
} }
} }
}
@Test @Test
public void e2_getCleanTaskStateTest() throws JsonProcessingException { public void e2_getCleanTaskStateTest() throws JsonProcessingException {
if (!GlobalVar.USED_VIRTUAL_DISPOSE_MODE) {
String jsonRequest = "{\"cleanTaskId\":\"adb\"}"; String jsonRequest = "{\"cleanTaskId\":\"adb\"}";
String svrReturn = Http.postJson("http://10.88.77.88:18080/DDoSClean/clean/getCleanTaskState", String svrReturn = Http.postJson("http://10.88.77.88:18080/DDoSClean/clean/getCleanTaskState",
null, null,
@ -287,4 +324,5 @@ public class HaoHanInterfaceTestCase {
Assert.assertEquals(result.getMsg(), HaoHanErrorCode.ERR_CLEANTASKIDFORMA.getMsg()); Assert.assertEquals(result.getMsg(), HaoHanErrorCode.ERR_CLEANTASKIDFORMA.getMsg());
} }
} }
}