diff --git a/escheduler-api/src/test/java/cn/escheduler/api/HttpClientTest.java b/escheduler-api/src/test/java/cn/escheduler/api/HttpClientTest.java index b2495a2f9d..1e7c6cb08f 100644 --- a/escheduler-api/src/test/java/cn/escheduler/api/HttpClientTest.java +++ b/escheduler-api/src/test/java/cn/escheduler/api/HttpClientTest.java @@ -26,6 +26,7 @@ import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.message.BasicNameValuePair; import org.apache.http.util.EntityUtils; +import org.junit.Ignore; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,6 +35,7 @@ import java.net.URI; import java.util.ArrayList; import java.util.List; +@Ignore public class HttpClientTest { private static final Logger logger = LoggerFactory.getLogger(HttpClientTest.class); diff --git a/escheduler-api/src/test/java/cn/escheduler/api/controller/AbstractControllerTest.java b/escheduler-api/src/test/java/cn/escheduler/api/controller/AbstractControllerTest.java index 2299a58de2..5b2554250b 100644 --- a/escheduler-api/src/test/java/cn/escheduler/api/controller/AbstractControllerTest.java +++ b/escheduler-api/src/test/java/cn/escheduler/api/controller/AbstractControllerTest.java @@ -44,6 +44,7 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +@Ignore @RunWith(SpringRunner.class) @SpringBootTest(classes = ApiApplicationServer.class) public class AbstractControllerTest { diff --git a/escheduler-api/src/test/java/cn/escheduler/api/controller/ExecutorControllerTest.java b/escheduler-api/src/test/java/cn/escheduler/api/controller/ExecutorControllerTest.java index a199c8ba73..e89653fc95 100644 --- a/escheduler-api/src/test/java/cn/escheduler/api/controller/ExecutorControllerTest.java +++ b/escheduler-api/src/test/java/cn/escheduler/api/controller/ExecutorControllerTest.java @@ -20,6 +20,7 @@ import cn.escheduler.api.enums.Status; import cn.escheduler.api.utils.Result; import cn.escheduler.common.utils.JSONUtils; import org.junit.Assert; +import org.junit.Ignore; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,6 +37,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. /** * executor controller test */ +@Ignore public class ExecutorControllerTest extends AbstractControllerTest{ private static Logger logger = LoggerFactory.getLogger(ExecutorControllerTest.class); @@ -44,7 +46,7 @@ public class ExecutorControllerTest extends AbstractControllerTest{ public void startCheckProcessDefinition() throws Exception { MvcResult mvcResult = mockMvc.perform(post("/projects/{projectName}/executors/start-check","project_test1") - .header("sessionId", "08fae8bf-fe2d-4fc0-8129-23c37fbfac82") + .header(SESSION_ID, sessionId) .param("processDefinitionId","226")) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) @@ -59,9 +61,8 @@ public class ExecutorControllerTest extends AbstractControllerTest{ MultiValueMap paramsMap = new LinkedMultiValueMap<>(); //paramsMap.add("processDefinitionId","4"); paramsMap.add("processInstanceId","13"); - //paramsMap.add("processInstanceId","13"); MvcResult mvcResult = mockMvc.perform(get("/projects/{projectName}/executors/get-receiver-cc","li_sql_test") - .header("sessionId", "e79b3353-e227-4680-88c0-544194e64025") + .header(SESSION_ID, sessionId) .params(paramsMap)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) diff --git a/escheduler-api/src/test/java/cn/escheduler/api/controller/ProjectControllerTest.java b/escheduler-api/src/test/java/cn/escheduler/api/controller/ProjectControllerTest.java index de04b072b1..8a122ab035 100644 --- a/escheduler-api/src/test/java/cn/escheduler/api/controller/ProjectControllerTest.java +++ b/escheduler-api/src/test/java/cn/escheduler/api/controller/ProjectControllerTest.java @@ -41,10 +41,10 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -@Ignore -@RunWith(SpringRunner.class) -@SpringBootTest -public class ProjectControllerTest { +/** + * project controller + */ +public class ProjectControllerTest extends AbstractControllerTest{ private static Logger logger = LoggerFactory.getLogger(ProcessInstanceControllerTest.class); private MockMvc mockMvc; diff --git a/escheduler-api/src/test/java/cn/escheduler/api/service/ProcessInstanceServiceTest.java b/escheduler-api/src/test/java/cn/escheduler/api/service/ProcessInstanceServiceTest.java index 638a9ee0f0..32030cb020 100644 --- a/escheduler-api/src/test/java/cn/escheduler/api/service/ProcessInstanceServiceTest.java +++ b/escheduler-api/src/test/java/cn/escheduler/api/service/ProcessInstanceServiceTest.java @@ -45,7 +45,7 @@ public class ProcessInstanceServiceTest { ProcessInstanceService processInstanceService; @Test - public void viewVariables() throws Exception { + public void viewVariables() { try { Map map = processInstanceService.viewVariables(-1); Assert.assertEquals(Status.SUCCESS, map.get(Constants.STATUS)); diff --git a/escheduler-common/src/test/java/cn/escheduler/common/utils/HttpUtilsTestInner.java b/escheduler-common/src/test/java/cn/escheduler/common/utils/HttpUtilsTest.java similarity index 94% rename from escheduler-common/src/test/java/cn/escheduler/common/utils/HttpUtilsTestInner.java rename to escheduler-common/src/test/java/cn/escheduler/common/utils/HttpUtilsTest.java index 4db398d386..df0f78405d 100644 --- a/escheduler-common/src/test/java/cn/escheduler/common/utils/HttpUtilsTestInner.java +++ b/escheduler-common/src/test/java/cn/escheduler/common/utils/HttpUtilsTest.java @@ -18,6 +18,7 @@ package cn.escheduler.common.utils; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import org.junit.Ignore; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -25,13 +26,13 @@ import org.slf4j.LoggerFactory; /** * HttpClient utils test */ -public class HttpUtilsTestInner { +public class HttpUtilsTest { - public static final Logger logger = LoggerFactory.getLogger(HttpUtilsTestInner.class); - + public static final Logger logger = LoggerFactory.getLogger(HttpUtilsTest.class); + @Ignore @Test public void getTest(){ diff --git a/escheduler-common/src/test/resources/dao/data_source.properties b/escheduler-common/src/test/resources/dao/data_source.properties new file mode 100644 index 0000000000..bee1f08f58 --- /dev/null +++ b/escheduler-common/src/test/resources/dao/data_source.properties @@ -0,0 +1,53 @@ +# base spring data source configuration +spring.datasource.type=com.alibaba.druid.pool.DruidDataSource +spring.datasource.driver-class-name=com.mysql.jdbc.Driver +spring.datasource.url=jdbc:mysql://192.168.10.32:3306/escheduler?characterEncoding=UTF-8 +spring.datasource.username=root +spring.datasource.password=root@123 + +# connection configuration +spring.datasource.initialSize=5 +# min connection number +spring.datasource.minIdle=5 +# max connection number +spring.datasource.maxActive=50 + +# max wait time for get a connection in milliseconds. if configuring maxWait, fair locks are enabled by default and concurrency efficiency decreases. +# If necessary, unfair locks can be used by configuring the useUnfairLock attribute to true. +spring.datasource.maxWait=60000 + +# milliseconds for check to close free connections +spring.datasource.timeBetweenEvictionRunsMillis=60000 + +# the Destroy thread detects the connection interval and closes the physical connection in milliseconds if the connection idle time is greater than or equal to minEvictableIdleTimeMillis. +spring.datasource.timeBetweenConnectErrorMillis=60000 + +# the longest time a connection remains idle without being evicted, in milliseconds +spring.datasource.minEvictableIdleTimeMillis=300000 + +#the SQL used to check whether the connection is valid requires a query statement. If validation Query is null, testOnBorrow, testOnReturn, and testWhileIdle will not work. +spring.datasource.validationQuery=SELECT 1 +#check whether the connection is valid for timeout, in seconds +spring.datasource.validationQueryTimeout=3 + +# when applying for a connection, if it is detected that the connection is idle longer than time Between Eviction Runs Millis, +# validation Query is performed to check whether the connection is valid +spring.datasource.testWhileIdle=true + +#execute validation to check if the connection is valid when applying for a connection +spring.datasource.testOnBorrow=true +#execute validation to check if the connection is valid when the connection is returned +spring.datasource.testOnReturn=false +spring.datasource.defaultAutoCommit=true +spring.datasource.keepAlive=true + +# open PSCache, specify count PSCache for every connection +spring.datasource.poolPreparedStatements=true +spring.datasource.maxPoolPreparedStatementPerConnectionSize=20 + +# data quality analysis is not currently in use. please ignore the following configuration +# task record flag +task.record.flag=false +task.record.datasource.url=jdbc:mysql://192.168.xx.xx:3306/etl?characterEncoding=UTF-8 +task.record.datasource.username=xx +task.record.datasource.password=xx \ No newline at end of file diff --git a/escheduler-dao/src/test/java/cn/escheduler/dao/mapper/UserMapperTest.java b/escheduler-dao/src/test/java/cn/escheduler/dao/mapper/UserMapperTest.java index a85ffef1c3..eb4a1df468 100644 --- a/escheduler-dao/src/test/java/cn/escheduler/dao/mapper/UserMapperTest.java +++ b/escheduler-dao/src/test/java/cn/escheduler/dao/mapper/UserMapperTest.java @@ -20,6 +20,7 @@ import cn.escheduler.common.enums.UserType; import cn.escheduler.dao.datasource.ConnectionFactory; import cn.escheduler.dao.model.AccessToken; import cn.escheduler.dao.model.User; +import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -43,6 +44,14 @@ public class UserMapperTest { accessTokenMapper = ConnectionFactory.getSqlSession().getMapper(AccessTokenMapper.class); } + + @After + public void testDelete() { + int delete = userMapper.delete(userId); + Assert.assertTrue(delete >= 0); + } + + @Test public void testInsert(){ User user = new User(); @@ -57,7 +66,7 @@ public class UserMapperTest { userMapper.insert(user); Assert.assertNotEquals(user.getId(), 0); - user.setUserName("Dr.chemistry" + new Random().nextInt(10)); + user.setUserName("Dr.chemistry" + new Date().getTime()); int update = userMapper.update(user); Assert.assertEquals(update, 1); @@ -88,9 +97,5 @@ public class UserMapperTest { } - @Test - public void testDelete() { - int delete = userMapper.delete(userId); - Assert.assertTrue(delete >= 0); - } + } diff --git a/escheduler-server/src/test/java/cn/escheduler/server/zk/StandaloneZKServerForTest.java b/escheduler-server/src/test/java/cn/escheduler/server/zk/StandaloneZKServerForTest.java index 07e5956151..078dbcff01 100644 --- a/escheduler-server/src/test/java/cn/escheduler/server/zk/StandaloneZKServerForTest.java +++ b/escheduler-server/src/test/java/cn/escheduler/server/zk/StandaloneZKServerForTest.java @@ -21,6 +21,7 @@ import org.apache.zookeeper.server.ServerConfig; import org.apache.zookeeper.server.ZooKeeperServerMain; import org.apache.zookeeper.server.quorum.QuorumPeerConfig; import org.junit.Before; +import org.junit.Ignore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -31,6 +32,7 @@ import java.util.Properties; /** * just for test */ +@Ignore public class StandaloneZKServerForTest { private static final Logger logger = LoggerFactory.getLogger(StandaloneZKServerForTest.class); diff --git a/escheduler-server/src/test/resources/dao/data_source.properties b/escheduler-server/src/test/resources/dao/data_source.properties new file mode 100644 index 0000000000..bee1f08f58 --- /dev/null +++ b/escheduler-server/src/test/resources/dao/data_source.properties @@ -0,0 +1,53 @@ +# base spring data source configuration +spring.datasource.type=com.alibaba.druid.pool.DruidDataSource +spring.datasource.driver-class-name=com.mysql.jdbc.Driver +spring.datasource.url=jdbc:mysql://192.168.10.32:3306/escheduler?characterEncoding=UTF-8 +spring.datasource.username=root +spring.datasource.password=root@123 + +# connection configuration +spring.datasource.initialSize=5 +# min connection number +spring.datasource.minIdle=5 +# max connection number +spring.datasource.maxActive=50 + +# max wait time for get a connection in milliseconds. if configuring maxWait, fair locks are enabled by default and concurrency efficiency decreases. +# If necessary, unfair locks can be used by configuring the useUnfairLock attribute to true. +spring.datasource.maxWait=60000 + +# milliseconds for check to close free connections +spring.datasource.timeBetweenEvictionRunsMillis=60000 + +# the Destroy thread detects the connection interval and closes the physical connection in milliseconds if the connection idle time is greater than or equal to minEvictableIdleTimeMillis. +spring.datasource.timeBetweenConnectErrorMillis=60000 + +# the longest time a connection remains idle without being evicted, in milliseconds +spring.datasource.minEvictableIdleTimeMillis=300000 + +#the SQL used to check whether the connection is valid requires a query statement. If validation Query is null, testOnBorrow, testOnReturn, and testWhileIdle will not work. +spring.datasource.validationQuery=SELECT 1 +#check whether the connection is valid for timeout, in seconds +spring.datasource.validationQueryTimeout=3 + +# when applying for a connection, if it is detected that the connection is idle longer than time Between Eviction Runs Millis, +# validation Query is performed to check whether the connection is valid +spring.datasource.testWhileIdle=true + +#execute validation to check if the connection is valid when applying for a connection +spring.datasource.testOnBorrow=true +#execute validation to check if the connection is valid when the connection is returned +spring.datasource.testOnReturn=false +spring.datasource.defaultAutoCommit=true +spring.datasource.keepAlive=true + +# open PSCache, specify count PSCache for every connection +spring.datasource.poolPreparedStatements=true +spring.datasource.maxPoolPreparedStatementPerConnectionSize=20 + +# data quality analysis is not currently in use. please ignore the following configuration +# task record flag +task.record.flag=false +task.record.datasource.url=jdbc:mysql://192.168.xx.xx:3306/etl?characterEncoding=UTF-8 +task.record.datasource.username=xx +task.record.datasource.password=xx \ No newline at end of file