Browse Source

Fix datasource not work in tests and standalone server, and run all tests by default (#6743)

3.0.0/version-upgrade
kezhenxu94 3 years ago committed by GitHub
parent
commit
02350ea37b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      .github/workflows/unit-test.yml
  2. 2
      .licenserc.yaml
  3. 5
      dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/plugin/AlertPluginManagerTest.java
  4. 7
      dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/plugin/EmailAlertPluginTest.java
  5. 221
      dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/utils/PropertyUtilsTest.java
  6. 12
      dolphinscheduler-api/pom.xml
  7. 157
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/HttpClientTest.java
  8. 17
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AbstractControllerTest.java
  9. 7
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/EnvironmentControllerTest.java
  10. 45
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/security/SecurityConfigLDAPTest.java~HEAD
  11. 45
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/security/SecurityConfigLDAPTest.java~dev
  12. 1
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/security/impl/ldap/LdapAuthenticatorTest.java
  13. 5
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/security/impl/ldap/LdapServiceTest.java
  14. 1
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/security/impl/pwd/PasswordAuthenticatorTest.java
  15. 25
      dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java
  16. 46
      dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/CommonTest.java
  17. 9
      dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/threadutils/ThreadPoolExecutorsTest.java
  18. 20
      dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/NetUtilsTest.java
  19. 112
      dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/OSUtilsTest.java
  20. 7
      dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/placeholder/TimePlaceholderUtilsTest.java
  21. 2
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/datasource/SpringConnectionFactory.java
  22. 1
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/UpgradeDao.java
  23. 0
      dolphinscheduler-dao/src/main/resources/sql/create/release-1.0.0_schema/mysql/dolphinscheduler_ddl.sql
  24. 0
      dolphinscheduler-dao/src/main/resources/sql/create/release-1.0.0_schema/mysql/dolphinscheduler_dml.sql
  25. 0
      dolphinscheduler-dao/src/main/resources/sql/create/release-1.2.0_schema/postgresql/dolphinscheduler_ddl.sql
  26. 0
      dolphinscheduler-dao/src/main/resources/sql/create/release-1.2.0_schema/postgresql/dolphinscheduler_dml.sql
  27. 0
      dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql
  28. 0
      dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql
  29. 0
      dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgre.sql
  30. 0
      dolphinscheduler-dao/src/main/resources/sql/soft_version
  31. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/1.0.1_schema/mysql/dolphinscheduler_ddl.sql
  32. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/1.0.1_schema/mysql/dolphinscheduler_dml.sql
  33. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/1.0.2_schema/mysql/dolphinscheduler_ddl.sql
  34. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/1.0.2_schema/mysql/dolphinscheduler_dml.sql
  35. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/1.1.0_schema/mysql/dolphinscheduler_ddl.sql
  36. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/1.1.0_schema/mysql/dolphinscheduler_dml.sql
  37. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/1.2.0_schema/mysql/dolphinscheduler_ddl.sql
  38. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/1.2.0_schema/mysql/dolphinscheduler_dml.sql
  39. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/1.2.0_schema/postgresql/dolphinscheduler_ddl.sql
  40. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/1.2.0_schema/postgresql/dolphinscheduler_dml.sql
  41. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.0_schema/mysql/dolphinscheduler_ddl.sql
  42. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.0_schema/mysql/dolphinscheduler_dml.sql
  43. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.0_schema/postgresql/dolphinscheduler_ddl.sql
  44. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.0_schema/postgresql/dolphinscheduler_dml.sql
  45. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.2_schema/mysql/dolphinscheduler_ddl.sql
  46. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.2_schema/mysql/dolphinscheduler_dml.sql
  47. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.2_schema/postgresql/dolphinscheduler_ddl.sql
  48. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.2_schema/postgresql/dolphinscheduler_dml.sql
  49. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.3_schema/mysql/dolphinscheduler_ddl.sql
  50. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.3_schema/mysql/dolphinscheduler_dml.sql
  51. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.3_schema/postgresql/dolphinscheduler_ddl.sql
  52. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.3_schema/postgresql/dolphinscheduler_dml.sql
  53. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.5_schema/mysql/dolphinscheduler_ddl.sql
  54. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.5_schema/mysql/dolphinscheduler_dml.sql
  55. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.5_schema/postgresql/dolphinscheduler_ddl.sql
  56. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.5_schema/postgresql/dolphinscheduler_dml.sql
  57. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.6_schema/mysql/dolphinscheduler_ddl.sql
  58. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.6_schema/mysql/dolphinscheduler_dml.sql
  59. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.6_schema/postgresql/dolphinscheduler_ddl.sql
  60. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.6_schema/postgresql/dolphinscheduler_dml.sql
  61. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.7_schema/mysql/dolphinscheduler_ddl.sql
  62. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.7_schema/mysql/dolphinscheduler_dml.sql
  63. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.7_schema/postgresql/dolphinscheduler_ddl.sql
  64. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.7_schema/postgresql/dolphinscheduler_dml.sql
  65. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.0_schema/mysql/dolphinscheduler_ddl.sql
  66. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.0_schema/mysql/dolphinscheduler_ddl_post.sql
  67. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.0_schema/mysql/dolphinscheduler_dml.sql
  68. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.0_schema/postgresql/dolphinscheduler_ddl.sql
  69. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.0_schema/postgresql/dolphinscheduler_ddl_post.sql
  70. 0
      dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.0_schema/postgresql/dolphinscheduler_dml.sql
  71. 6
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/AlertDaoTest.java
  72. 17
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ConnectionFactoryTest.java
  73. 8
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/upgrade/ProcessDefinitionDaoTest.java
  74. 7
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/upgrade/UpgradeDaoTest.java
  75. 14
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/upgrade/WorkerGroupDaoTest.java
  76. 4
      dolphinscheduler-dist/pom.xml
  77. 2
      dolphinscheduler-dist/src/main/assembly/dolphinscheduler-bin.xml
  78. 54
      dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/master/WorkflowExecuteThreadTest.java
  79. 2
      dolphinscheduler-standalone-server/src/main/java/org/apache/dolphinscheduler/server/StandaloneServer.java
  80. 264
      pom.xml
  81. 5
      script/dolphinscheduler-daemon.sh

7
.github/workflows/unit-test.yml

@ -57,13 +57,6 @@ jobs:
with: with:
path: ~/.m2/repository path: ~/.m2/repository
key: ${{ runner.os }}-maven key: ${{ runner.os }}-maven
- name: Bootstrap database
run: |
sed -i "/image: bitnami\/postgresql/a\ ports:\n - 5432:5432" $(pwd)/docker/docker-swarm/docker-compose.yml
sed -i "/image: bitnami\/zookeeper/a\ ports:\n - 2181:2181" $(pwd)/docker/docker-swarm/docker-compose.yml
docker-compose -f $(pwd)/docker/docker-swarm/docker-compose.yml up -d dolphinscheduler-zookeeper dolphinscheduler-postgresql
until docker logs docker-swarm_dolphinscheduler-postgresql_1 2>&1 | grep 'listening on IPv4 address'; do echo "waiting for postgresql ready ..."; sleep 1; done
docker run --rm --network docker-swarm_dolphinscheduler -v $(pwd)/sql/dolphinscheduler_postgre.sql:/docker-entrypoint-initdb.d/dolphinscheduler_postgre.sql bitnami/postgresql:11.11.0 bash -c "PGPASSWORD=root psql -h docker-swarm_dolphinscheduler-postgresql_1 -U root -d dolphinscheduler -v ON_ERROR_STOP=1 -f /docker-entrypoint-initdb.d/dolphinscheduler_postgre.sql"
- name: Run Unit tests - name: Run Unit tests
run: ./mvnw clean verify -B -Dmaven.test.skip=false run: ./mvnw clean verify -B -Dmaven.test.skip=false

2
.licenserc.yaml

@ -27,7 +27,7 @@ header:
- DISCLAIMER - DISCLAIMER
- dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/ScriptRunner.java - dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/ScriptRunner.java
- mvnw.cmd - mvnw.cmd
- sql/soft_version - dolphinscheduler-dao/src/main/resources/sql/soft_version
- .mvn - .mvn
- .gitattributes - .gitattributes
- '**/licenses/**/LICENSE-*' - '**/licenses/**/LICENSE-*'

5
dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/plugin/AlertPluginManagerTest.java

@ -28,6 +28,7 @@ import java.util.Objects;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -39,8 +40,8 @@ public class AlertPluginManagerTest {
private static final Logger logger = LoggerFactory.getLogger(AlertPluginManagerTest.class); private static final Logger logger = LoggerFactory.getLogger(AlertPluginManagerTest.class);
@Before @BeforeClass
public void setUp() { public static void setUp() {
System.setProperty("spring.profiles.active", "h2"); System.setProperty("spring.profiles.active", "h2");
} }

7
dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/plugin/EmailAlertPluginTest.java

@ -51,6 +51,7 @@ import java.util.List;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -63,9 +64,13 @@ public class EmailAlertPluginTest {
private AlertDao alertDao; private AlertDao alertDao;
private PluginDao pluginDao; private PluginDao pluginDao;
@BeforeClass
public static void setUpClass() {
System.setProperty("spring.profiles.active", "h2");
}
@Before @Before
public void setUp() { public void setUp() {
System.setProperty("spring.profiles.active", "h2");
alertDao = DaoFactory.getDaoInstance(AlertDao.class); alertDao = DaoFactory.getDaoInstance(AlertDao.class);
pluginDao = DaoFactory.getDaoInstance(PluginDao.class); pluginDao = DaoFactory.getDaoInstance(PluginDao.class);
} }

221
dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/utils/PropertyUtilsTest.java

@ -1,221 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.alert.utils;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import org.apache.dolphinscheduler.common.enums.NodeType;
import org.apache.dolphinscheduler.common.utils.PropertyUtils;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Test PropertyUtils
* and the resource path is src/test/resources/alert.properties.
*/
public class PropertyUtilsTest {
private static final Logger logger = LoggerFactory.getLogger(PropertyUtilsTest.class);
/**
* Test getString
*/
@Test
public void testGetString() {
//Expected "EMAIL"
String result = PropertyUtils.getString("alert.type");
logger.info(result);
assertEquals("EMAIL", result);
//Expected "xxx.xxx.test"
result = PropertyUtils.getString("mail.server.host");
assertEquals("xxx.xxx.test", result);
//If key is undefine in alert.properties, then return null
result = PropertyUtils.getString("abc");
assertNull(result);
//If key is null, then return null
result = PropertyUtils.getString(null);
assertNull(result);
}
/**
* Test getBoolean
*/
@Test
public void testGetBoolean() {
//Expected true
Boolean result = PropertyUtils.getBoolean("mail.smtp.starttls.enable");
assertTrue(result);
//Expected false
result = PropertyUtils.getBoolean("mail.smtp.ssl.enable");
assertFalse(result);
//If key is undefine in alert.properties, then return null
result = PropertyUtils.getBoolean("abc");
assertFalse(result);
//If key is null, then return false
result = PropertyUtils.getBoolean(null);
assertFalse(result);
}
/**
* Test getLong
*/
@Test
public void testGetLong() {
//Expected 25
long result = PropertyUtils.getLong("mail.server.port");
assertSame(25L, result);
//If key is null, then return -1
result = PropertyUtils.getLong(null);
assertSame(-1L, result);
//If key is undefine in alert.properties, then return -1
result = PropertyUtils.getLong("abc");
assertSame(-1L, result);
//If key is undefine in alert.properties, and there is a defaultval, then return defaultval
result = PropertyUtils.getLong("abc", 200);
assertEquals(200L, result);
//If the value can not parse to long ,it will log the error and return -1L
result = PropertyUtils.getLong("test.server.testnumber");
assertSame(-1L, result);
}
/**
* Test getDouble
*/
@Test
public void testGetDouble() {
//Expected 3.0
double result = PropertyUtils.getDouble("test.server.factor", 3.0);
assertEquals(3.0, result, 0);
//If key is null, then return -1.0
result = PropertyUtils.getDouble(null, -1.0);
assertEquals(-1.0, result, 0);
//If key is undefine in alert.properties, then return -1
result = PropertyUtils.getDouble("abc", -1.0);
assertEquals(-1.0, result, 0);
//If key is undefine in alert.properties, and there is a defaultval, then return defaultval
result = PropertyUtils.getDouble("abc", 5.0);
assertEquals(5.0, result, 0);
//If the value can not parse to double ,it will log the error and return -1.0
result = PropertyUtils.getDouble("test.server.testnumber", -1.0);
assertEquals(-1.0, result, 0);
}
/**
* Test getArray
*/
@Test
public void testGetArray() {
//Expected length 3
String[] result = PropertyUtils.getArray("test.server.list", ",");
assertEquals(result.length, 3);
//Equal array values
assertEquals("xxx.xxx.test1", result[0]);
assertEquals("xxx.xxx.test2", result[1]);
assertEquals("xxx.xxx.test3", result[2]);
//If key is null, then return -1
result = PropertyUtils.getArray(null, ",");
assertNull(result);
//If key is undefine in alert.properties, then return null
result = PropertyUtils.getArray("abc", ",");
assertNull(result);
//If splitStr is null, then return null
result = PropertyUtils.getArray("test.server.list", null);
assertNull(result);
}
/**
* test getInt
*/
@Test
public void testGetInt() {
//Expected 25
int result = PropertyUtils.getInt("mail.server.port");
assertSame(25, result);
//If key is null, then return -1
result = PropertyUtils.getInt(null);
assertSame(-1, result);
//If key is undefine in alert.properties, then return -1
result = PropertyUtils.getInt("abc");
assertSame(-1, result);
//If key is undefine in alert.properties, and there is a defaultval, then return defaultval
result = PropertyUtils.getInt("abc", 300);
assertEquals(300, result);
//If the value can not parse to int ,it will log the error and return -1
result = PropertyUtils.getInt("test.server.testnumber");
assertSame(-1, result);
}
/**
* Test getEnum
*/
@Test
public void testGetEnum() {
//Expected MASTER
NodeType nodeType = PropertyUtils.getEnum("test.server.enum1", NodeType.class, NodeType.WORKER);
assertEquals(NodeType.MASTER, nodeType);
//Expected DEAD_SERVER
nodeType = PropertyUtils.getEnum("test.server.enum2", NodeType.class, NodeType.WORKER);
assertEquals(NodeType.DEAD_SERVER, nodeType);
//If key is null, then return defaultval
nodeType = PropertyUtils.getEnum(null, NodeType.class, NodeType.WORKER);
assertEquals(NodeType.WORKER, nodeType);
//If the value doesn't define in enum ,it will log the error and return -1
nodeType = PropertyUtils.getEnum("test.server.enum3", NodeType.class, NodeType.WORKER);
assertEquals(NodeType.WORKER, nodeType);
}
}

12
dolphinscheduler-api/pom.xml

@ -254,5 +254,17 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-test</artifactId>
<version>${curator.test}</version>
<exclusions>
<exclusion>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

157
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/HttpClientTest.java

@ -1,157 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.api;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URIBuilder;
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.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
public class HttpClientTest {
private static final Logger logger = LoggerFactory.getLogger(HttpClientTest.class);
@Test
public void doPOSTParam()throws Exception{
// create HttpClient
CloseableHttpClient httpclient = HttpClients.createDefault();
// create http post request
HttpPost httpPost = new HttpPost("http://localhost:12345/dolphinscheduler/projects/create");
httpPost.setHeader("token", "123");
// set parameters
List<NameValuePair> parameters = new ArrayList<NameValuePair>();
parameters.add(new BasicNameValuePair("projectName", "qzw"));
parameters.add(new BasicNameValuePair("desc", "qzw"));
UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(parameters);
httpPost.setEntity(formEntity);
CloseableHttpResponse response = null;
try {
// execute
response = httpclient.execute(httpPost);
// response status code 200
if (response.getStatusLine().getStatusCode() == 200) {
String content = EntityUtils.toString(response.getEntity(), "UTF-8");
logger.info(content);
}
} finally {
if (response != null) {
response.close();
}
httpclient.close();
}
}
/**
* do get param path variables chinese
* @throws Exception
*/
@Test
public void doGETParamPathVariableAndChinese()throws Exception{
// create HttpClient
CloseableHttpClient httpclient = HttpClients.createDefault();
List<NameValuePair> parameters = new ArrayList<NameValuePair>();
// parameters.add(new BasicNameValuePair("pageSize", "10"));
// define the parameters of the request
URI uri = new URIBuilder("http://localhost:12345/dolphinscheduler/projects/%E5%85%A8%E9%83%A8%E6%B5%81%E7%A8%8B%E6%B5%8B%E8%AF%95/process/list")
.build();
// create http GET request
HttpGet httpGet = new HttpGet(uri);
httpGet.setHeader("token","10f5625a2a1cbf9aa710653796c5d764");
//response object
CloseableHttpResponse response = null;
try {
// execute http get request
response = httpclient.execute(httpGet);
// response status code 200
if (response.getStatusLine().getStatusCode() == 200) {
String content = EntityUtils.toString(response.getEntity(), "UTF-8");
logger.info("start--------------->");
logger.info(content);
logger.info("end----------------->");
}
} finally {
if (response != null) {
response.close();
}
httpclient.close();
}
}
/**
*
* do get param
* @throws Exception
*/
@Test
public void doGETParam()throws Exception{
// create HttpClient
CloseableHttpClient httpclient = HttpClients.createDefault();
List<NameValuePair> parameters = new ArrayList<NameValuePair>();
parameters.add(new BasicNameValuePair("startDate", "2018-04-22 19:30:08"));
parameters.add(new BasicNameValuePair("endDate", "2028-04-22 19:30:08"));
parameters.add(new BasicNameValuePair("projectId", "0"));
// define the parameters of the request
URI uri = new URIBuilder("http://localhost:12345/dolphinscheduler/projects/analysis/queue-count")
.setParameters(parameters)
.build();
// create http GET request
HttpGet httpGet = new HttpGet(uri);
httpGet.setHeader("token","2aef24c052c212fab9eec78848c2258b");
//response object
CloseableHttpResponse response = null;
try {
// execute http get request
response = httpclient.execute(httpGet);
// response status code 200
if (response.getStatusLine().getStatusCode() == 200) {
String content = EntityUtils.toString(response.getEntity(), "UTF-8");
logger.info("start--------------->");
logger.info(content);
logger.info("end----------------->");
}
} finally {
if (response != null) {
response.close();
}
httpclient.close();
}
}
}

17
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AbstractControllerTest.java

@ -26,17 +26,23 @@ import org.apache.dolphinscheduler.common.enums.ProfileType;
import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.curator.test.TestingServer;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import javax.annotation.PostConstruct;
import org.junit.After; import org.junit.After;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;
@ -49,6 +55,7 @@ import org.springframework.web.context.WebApplicationContext;
@ActiveProfiles(value = {ProfileType.H2}) @ActiveProfiles(value = {ProfileType.H2})
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = ApiApplicationServer.class) @SpringBootTest(classes = ApiApplicationServer.class)
@Ignore
public class AbstractControllerTest { public class AbstractControllerTest {
public static final String SESSION_ID = "sessionId"; public static final String SESSION_ID = "sessionId";
@ -105,4 +112,14 @@ public class AbstractControllerTest {
result.put(Constants.MSG, status.getMsg()); result.put(Constants.MSG, status.getMsg());
} }
} }
@Configuration
@Profile(ProfileType.H2)
public static class RegistryServer {
@PostConstruct
public void startEmbedRegistryServer() throws Exception {
final TestingServer server = new TestingServer(true);
System.setProperty("registry.servers", server.getConnectString());
}
}
} }

7
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/EnvironmentControllerTest.java

@ -40,12 +40,8 @@ import org.springframework.util.MultiValueMap;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
/**
* environment controller test
*/
public class EnvironmentControllerTest extends AbstractControllerTest { public class EnvironmentControllerTest extends AbstractControllerTest {
private static final Logger logger = LoggerFactory.getLogger(EnvironmentControllerTest.class);
private static Logger logger = LoggerFactory.getLogger(EnvironmentControllerTest.class);
private String environmentCode; private String environmentCode;
@ -60,6 +56,7 @@ public class EnvironmentControllerTest extends AbstractControllerTest {
testCreateEnvironment(); testCreateEnvironment();
} }
@Override
@After @After
public void after() throws Exception { public void after() throws Exception {
testDeleteEnvironment(); testDeleteEnvironment();

45
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/security/SecurityConfigLDAPTest.java~HEAD

@ -1,45 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.api.security;
import org.apache.dolphinscheduler.api.ApiApplicationServer;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = ApiApplicationServer.class)
@TestPropertySource(properties = {
"security.authentication.type=LDAP",
})
public class SecurityConfigLDAPTest {
@Autowired
private SecurityConfig securityConfig;
@Test
public void testAuthenticator() {
Authenticator authenticator = securityConfig.authenticator();
Assert.assertNotNull(authenticator);
}
}

45
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/security/SecurityConfigLDAPTest.java~dev

@ -1,45 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.api.security;
import org.apache.dolphinscheduler.api.ApiApplicationServer;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = ApiApplicationServer.class)
@TestPropertySource(properties = {
"security.authentication.type=LDAP",
})
public class SecurityConfigLDAPTest {
@Autowired
private SecurityConfig securityConfig;
@Test
public void testAuthenticator() {
Authenticator authenticator = securityConfig.authenticator();
Assert.assertNotNull(authenticator);
}
}

1
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/security/impl/ldap/LdapAuthenticatorTest.java

@ -79,6 +79,7 @@ public class LdapAuthenticatorTest extends AbstractControllerTest {
private String ip = "127.0.0.1"; private String ip = "127.0.0.1";
private UserType userType = UserType.GENERAL_USER; private UserType userType = UserType.GENERAL_USER;
@Override
@Before @Before
public void setUp() { public void setUp() {
ldapAuthenticator = new LdapAuthenticator(); ldapAuthenticator = new LdapAuthenticator();

5
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/security/impl/ldap/LdapServiceTest.java

@ -18,18 +18,23 @@
package org.apache.dolphinscheduler.api.security.impl.ldap; package org.apache.dolphinscheduler.api.security.impl.ldap;
import org.apache.dolphinscheduler.api.ApiApplicationServer; import org.apache.dolphinscheduler.api.ApiApplicationServer;
import org.apache.dolphinscheduler.common.enums.ProfileType;
import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.common.enums.UserType;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory; import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
@Ignore
@ActiveProfiles(ProfileType.H2)
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = ApiApplicationServer.class) @SpringBootTest(classes = ApiApplicationServer.class)
@TestPropertySource( @TestPropertySource(

1
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/security/impl/pwd/PasswordAuthenticatorTest.java

@ -57,6 +57,7 @@ public class PasswordAuthenticatorTest extends AbstractControllerTest {
private User mockUser; private User mockUser;
private Session mockSession; private Session mockSession;
@Override
@Before @Before
public void setUp() { public void setUp() {
authenticator = new PasswordAuthenticator(); authenticator = new PasswordAuthenticator();

25
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java

@ -1029,12 +1029,6 @@ public final class Constants {
*/ */
public static final int AUTHORIZE_READABLE_PERM = 4; public static final int AUTHORIZE_READABLE_PERM = 4;
/**
* plugin configurations
*/
public static final String PLUGIN_JAR_SUFFIX = ".jar";
public static final int NORMAL_NODE_STATUS = 0; public static final int NORMAL_NODE_STATUS = 0;
public static final int ABNORMAL_NODE_STATUS = 1; public static final int ABNORMAL_NODE_STATUS = 1;
public static final int BUSY_NODE_STATUE = 2; public static final int BUSY_NODE_STATUE = 2;
@ -1048,9 +1042,6 @@ public final class Constants {
*/ */
public static final String SYSTEM_LINE_SEPARATOR = System.getProperty("line.separator"); public static final String SYSTEM_LINE_SEPARATOR = System.getProperty("line.separator");
public static final String EXCEL_SUFFIX_XLS = ".xls";
/** /**
* datasource encryption salt * datasource encryption salt
*/ */
@ -1087,21 +1078,7 @@ public final class Constants {
* docker & kubernetes * docker & kubernetes
*/ */
public static final boolean DOCKER_MODE = !StringUtils.isEmpty(System.getenv("DOCKER")); public static final boolean DOCKER_MODE = !StringUtils.isEmpty(System.getenv("DOCKER"));
public static final boolean KUBERNETES_MODE = !StringUtils.isEmpty(System.getenv("KUBERNETES_SERVICE_HOST")) && !StringUtils.isEmpty(System.getenv("KUBERNETES_SERVICE_PORT")); public static final Boolean KUBERNETES_MODE = !StringUtils.isEmpty(System.getenv("KUBERNETES_SERVICE_HOST")) && !StringUtils.isEmpty(System.getenv("KUBERNETES_SERVICE_PORT"));
/**
* task parameter keys
*/
public static final String TASK_PARAMS = "params";
public static final String TASK_PARAMS_DATASOURCE = "datasource";
public static final String TASK_PARAMS_DATASOURCE_NAME = "datasourceName";
public static final String TASK_DEPENDENCE = "dependence";
public static final String TASK_DEPENDENCE_DEPEND_TASK_LIST = "dependTaskList";
public static final String TASK_DEPENDENCE_DEPEND_ITEM_LIST = "dependItemList";
public static final String TASK_DEPENDENCE_PROJECT_ID = "projectId";
public static final String TASK_DEPENDENCE_PROJECT_NAME = "projectName";
public static final String TASK_DEPENDENCE_DEFINITION_ID = "definitionId";
public static final String TASK_DEPENDENCE_DEFINITION_NAME = "definitionName";
/** /**
* dry run flag * dry run flag

46
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/CommonTest.java

@ -1,46 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.common;
import static org.junit.Assert.assertTrue;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import org.junit.Test;
/**
* CommonTest
*/
public class CommonTest {
public static void setFinalStatic(Field field, Object newValue) throws NoSuchFieldException, IllegalAccessException {
field.setAccessible(true);
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
field.set(null, newValue);
}
@Test
public void testSetFinalStatic() throws Exception {
setFinalStatic(Constants.class.getDeclaredField("KUBERNETES_MODE"), true);
assertTrue(Constants.KUBERNETES_MODE);
}
}

9
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/threadutils/ThreadPoolExecutorsTest.java

@ -25,13 +25,10 @@ import org.slf4j.LoggerFactory;
* Thread Pool Executor Test * Thread Pool Executor Test
*/ */
public class ThreadPoolExecutorsTest { public class ThreadPoolExecutorsTest {
private static final Logger logger = LoggerFactory.getLogger(ThreadPoolExecutors.class); private static final Logger logger = LoggerFactory.getLogger(ThreadPoolExecutors.class);
@Test @Test
public void testThreadPoolExecutors() throws InterruptedException { public void testThreadPoolExecutors() throws InterruptedException {
Thread2[] threadArr = new Thread2[10]; Thread2[] threadArr = new Thread2[10];
for (int i = 0; i < threadArr.length; i++) { for (int i = 0; i < threadArr.length; i++) {
@ -43,14 +40,10 @@ public class ThreadPoolExecutorsTest {
Thread.currentThread().join(40000l); Thread.currentThread().join(40000l);
} }
static class Thread2 extends Thread {
//test thread
class Thread2 extends Thread {
@Override @Override
public void run() { public void run() {
logger.info("ThreadPoolExecutors instance's hashcode is: {} ",ThreadPoolExecutors.getInstance("a",2).hashCode()); logger.info("ThreadPoolExecutors instance's hashcode is: {} ",ThreadPoolExecutors.getInstance("a",2).hashCode());
} }
} }
} }

20
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/NetUtilsTest.java

@ -23,17 +23,19 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import org.apache.dolphinscheduler.common.CommonTest;
import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.Constants;
import java.net.InetAddress; import java.net.InetAddress;
import org.junit.After;
import org.junit.Test; import org.junit.Test;
import org.powermock.reflect.Whitebox;
/**
* NetUtilsTest
*/
public class NetUtilsTest { public class NetUtilsTest {
@After
public void reset() {
Whitebox.setInternalState(Constants.class, "KUBERNETES_MODE", false);
}
@Test @Test
public void testGetAddr() { public void testGetAddr() {
@ -43,31 +45,31 @@ public class NetUtilsTest {
} }
@Test @Test
public void testGetHost() throws Exception { public void testGetHost() {
InetAddress address = mock(InetAddress.class); InetAddress address = mock(InetAddress.class);
when(address.getCanonicalHostName()).thenReturn("dolphinscheduler-worker-0.dolphinscheduler-worker-headless.default.svc.cluster.local"); when(address.getCanonicalHostName()).thenReturn("dolphinscheduler-worker-0.dolphinscheduler-worker-headless.default.svc.cluster.local");
when(address.getHostName()).thenReturn("dolphinscheduler-worker-0"); when(address.getHostName()).thenReturn("dolphinscheduler-worker-0");
when(address.getHostAddress()).thenReturn("172.17.0.15"); when(address.getHostAddress()).thenReturn("172.17.0.15");
assertEquals("172.17.0.15", NetUtils.getHost(address)); assertEquals("172.17.0.15", NetUtils.getHost(address));
CommonTest.setFinalStatic(Constants.class.getDeclaredField("KUBERNETES_MODE"), true); Whitebox.setInternalState(Constants.class, "KUBERNETES_MODE", true);
assertEquals("dolphinscheduler-worker-0.dolphinscheduler-worker-headless", NetUtils.getHost(address)); assertEquals("dolphinscheduler-worker-0.dolphinscheduler-worker-headless", NetUtils.getHost(address));
address = mock(InetAddress.class); address = mock(InetAddress.class);
when(address.getCanonicalHostName()).thenReturn("busybox-1.default-subdomain.my-namespace.svc.cluster-domain.example"); when(address.getCanonicalHostName()).thenReturn("busybox-1.default-subdomain.my-namespace.svc.cluster-domain.example");
when(address.getHostName()).thenReturn("busybox-1"); when(address.getHostName()).thenReturn("busybox-1");
CommonTest.setFinalStatic(Constants.class.getDeclaredField("KUBERNETES_MODE"), true); Whitebox.setInternalState(Constants.class, "KUBERNETES_MODE", true);
assertEquals("busybox-1.default-subdomain", NetUtils.getHost(address)); assertEquals("busybox-1.default-subdomain", NetUtils.getHost(address));
address = mock(InetAddress.class); address = mock(InetAddress.class);
when(address.getCanonicalHostName()).thenReturn("dolphinscheduler.cluster-domain.example"); when(address.getCanonicalHostName()).thenReturn("dolphinscheduler.cluster-domain.example");
when(address.getHostName()).thenReturn("dolphinscheduler"); when(address.getHostName()).thenReturn("dolphinscheduler");
CommonTest.setFinalStatic(Constants.class.getDeclaredField("KUBERNETES_MODE"), true); Whitebox.setInternalState(Constants.class, "KUBERNETES_MODE", true);
assertEquals("dolphinscheduler.cluster-domain.example", NetUtils.getHost(address)); assertEquals("dolphinscheduler.cluster-domain.example", NetUtils.getHost(address));
address = mock(InetAddress.class); address = mock(InetAddress.class);
when(address.getCanonicalHostName()).thenReturn("dolphinscheduler-worker-0"); when(address.getCanonicalHostName()).thenReturn("dolphinscheduler-worker-0");
when(address.getHostName()).thenReturn("dolphinscheduler-worker-0"); when(address.getHostName()).thenReturn("dolphinscheduler-worker-0");
CommonTest.setFinalStatic(Constants.class.getDeclaredField("KUBERNETES_MODE"), true); Whitebox.setInternalState(Constants.class, "KUBERNETES_MODE", true);
assertEquals("dolphinscheduler-worker-0", NetUtils.getHost(address)); assertEquals("dolphinscheduler-worker-0", NetUtils.getHost(address));
} }

112
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/OSUtilsTest.java

@ -1,112 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.common.utils;
import org.apache.commons.lang.SystemUtils;
import java.io.IOException;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class OSUtilsTest {
private static final Logger logger = LoggerFactory.getLogger(OSUtilsTest.class);
@Test
public void getUserList() {
List<String> userList = OSUtils.getUserList();
Assert.assertNotEquals("System user list should not be empty", userList.size(), 0);
logger.info("OS user list : {}", userList.toString());
}
@Test
public void testOSMetric() {
if (!SystemUtils.IS_OS_WINDOWS) {
double availablePhysicalMemorySize = OSUtils.availablePhysicalMemorySize();
Assert.assertTrue(availablePhysicalMemorySize >= 0.0d);
double loadAverage = OSUtils.loadAverage();
logger.info("loadAverage {}", loadAverage);
double memoryUsage = OSUtils.memoryUsage();
Assert.assertTrue(memoryUsage >= 0.0d);
double cpuUsage = OSUtils.cpuUsage();
Assert.assertTrue(cpuUsage >= 0.0d || cpuUsage == -1.0d);
} else {
// TODO window ut
}
}
@Test
public void getGroup() {
try {
String group = OSUtils.getGroup();
Assert.assertNotNull(group);
} catch (IOException e) {
Assert.fail("get group failed " + e.getMessage());
}
}
@Test
public void createUser() {
boolean result = OSUtils.createUser("test123");
if (result) {
Assert.assertTrue("create user test123 success", true);
} else {
Assert.assertTrue("create user test123 fail", true);
}
}
@Test
public void createUserIfAbsent() {
OSUtils.createUserIfAbsent("test123");
Assert.assertTrue("create user test123 success", true);
}
@Test
public void testGetSudoCmd() {
String cmd = "kill -9 1234";
String sudoCmd = OSUtils.getSudoCmd("test123", cmd);
Assert.assertEquals("sudo -u test123 " + cmd, sudoCmd);
}
@Test
public void exeCmd() {
if (SystemUtils.IS_OS_MAC || !SystemUtils.IS_OS_WINDOWS) {
try {
String result = OSUtils.exeCmd("echo helloWorld");
Assert.assertEquals("helloWorld\n",result);
} catch (IOException e) {
Assert.fail("exeCmd " + e.getMessage());
}
}
}
@Test
public void getProcessID() {
int processId = OSUtils.getProcessID();
Assert.assertNotEquals(0, processId);
}
@Test
public void checkResource() {
boolean resource = OSUtils.checkResource(100,0);
Assert.assertTrue(resource);
resource = OSUtils.checkResource(0,Double.MAX_VALUE);
Assert.assertFalse(resource);
}
}

7
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/placeholder/TimePlaceholderUtilsTest.java

@ -20,15 +20,22 @@ package org.apache.dolphinscheduler.common.utils.placeholder;
import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.common.utils.DateUtils;
import java.util.Date; import java.util.Date;
import java.util.TimeZone;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
public class TimePlaceholderUtilsTest { public class TimePlaceholderUtilsTest {
private Date date; private Date date;
@BeforeClass
public static void setup() {
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
}
@Before @Before
public void init() { public void init() {
date = DateUtils.parse("20170101010101", "yyyyMMddHHmmss"); date = DateUtils.parse("20170101010101", "yyyyMMddHHmmss");

2
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/datasource/SpringConnectionFactory.java

@ -152,7 +152,7 @@ public class SpringConnectionFactory {
.setType(EmbeddedDatabaseType.H2) .setType(EmbeddedDatabaseType.H2)
.setScriptEncoding(Constants.UTF_8) .setScriptEncoding(Constants.UTF_8)
.setName("dolphinscheduler;MODE=MySQL;DATABASE_TO_LOWER=TRUE;DB_CLOSE_DELAY=-1") .setName("dolphinscheduler;MODE=MySQL;DATABASE_TO_LOWER=TRUE;DB_CLOSE_DELAY=-1")
.addScript(PropertyUtils.getString("spring.datasource.sql.schema", "file:../sql/dolphinscheduler_h2.sql")) .addScript(PropertyUtils.getString("spring.datasource.sql.schema", "classpath:sql/dolphinscheduler_h2.sql"))
.build(); .build();
logger.info("Initialize H2 DataSource success"); logger.info("Initialize H2 DataSource success");
} }

1
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/UpgradeDao.java

@ -214,7 +214,6 @@ public abstract class UpgradeDao extends AbstractBaseDao {
if (StringUtils.isEmpty(rootDir)) { if (StringUtils.isEmpty(rootDir)) {
throw new RuntimeException("Environment variable user.dir not found"); throw new RuntimeException("Environment variable user.dir not found");
} }
//String mysqlSQLFilePath = rootDir + "/sql/create/release-1.0.0_schema/mysql/dolphinscheduler_ddl.sql";
String mysqlSQLFilePath = rootDir + initSqlPath + "dolphinscheduler_ddl.sql"; String mysqlSQLFilePath = rootDir + initSqlPath + "dolphinscheduler_ddl.sql";
try { try {
conn = dataSource.getConnection(); conn = dataSource.getConnection();

0
sql/create/release-1.0.0_schema/mysql/dolphinscheduler_ddl.sql → dolphinscheduler-dao/src/main/resources/sql/create/release-1.0.0_schema/mysql/dolphinscheduler_ddl.sql

0
sql/create/release-1.0.0_schema/mysql/dolphinscheduler_dml.sql → dolphinscheduler-dao/src/main/resources/sql/create/release-1.0.0_schema/mysql/dolphinscheduler_dml.sql

0
sql/create/release-1.2.0_schema/postgresql/dolphinscheduler_ddl.sql → dolphinscheduler-dao/src/main/resources/sql/create/release-1.2.0_schema/postgresql/dolphinscheduler_ddl.sql

0
sql/create/release-1.2.0_schema/postgresql/dolphinscheduler_dml.sql → dolphinscheduler-dao/src/main/resources/sql/create/release-1.2.0_schema/postgresql/dolphinscheduler_dml.sql

0
sql/dolphinscheduler_h2.sql → dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql

0
sql/dolphinscheduler_mysql.sql → dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql

0
sql/dolphinscheduler_postgre.sql → dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgre.sql

0
sql/soft_version → dolphinscheduler-dao/src/main/resources/sql/soft_version

0
sql/upgrade/1.0.1_schema/mysql/dolphinscheduler_ddl.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/1.0.1_schema/mysql/dolphinscheduler_ddl.sql

0
sql/upgrade/1.0.1_schema/mysql/dolphinscheduler_dml.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/1.0.1_schema/mysql/dolphinscheduler_dml.sql

0
sql/upgrade/1.0.2_schema/mysql/dolphinscheduler_ddl.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/1.0.2_schema/mysql/dolphinscheduler_ddl.sql

0
sql/upgrade/1.0.2_schema/mysql/dolphinscheduler_dml.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/1.0.2_schema/mysql/dolphinscheduler_dml.sql

0
sql/upgrade/1.1.0_schema/mysql/dolphinscheduler_ddl.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/1.1.0_schema/mysql/dolphinscheduler_ddl.sql

0
sql/upgrade/1.1.0_schema/mysql/dolphinscheduler_dml.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/1.1.0_schema/mysql/dolphinscheduler_dml.sql

0
sql/upgrade/1.2.0_schema/mysql/dolphinscheduler_ddl.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/1.2.0_schema/mysql/dolphinscheduler_ddl.sql

0
sql/upgrade/1.2.0_schema/mysql/dolphinscheduler_dml.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/1.2.0_schema/mysql/dolphinscheduler_dml.sql

0
sql/upgrade/1.2.0_schema/postgresql/dolphinscheduler_ddl.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/1.2.0_schema/postgresql/dolphinscheduler_ddl.sql

0
sql/upgrade/1.2.0_schema/postgresql/dolphinscheduler_dml.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/1.2.0_schema/postgresql/dolphinscheduler_dml.sql

0
sql/upgrade/1.3.0_schema/mysql/dolphinscheduler_ddl.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.0_schema/mysql/dolphinscheduler_ddl.sql

0
sql/upgrade/1.3.0_schema/mysql/dolphinscheduler_dml.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.0_schema/mysql/dolphinscheduler_dml.sql

0
sql/upgrade/1.3.0_schema/postgresql/dolphinscheduler_ddl.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.0_schema/postgresql/dolphinscheduler_ddl.sql

0
sql/upgrade/1.3.0_schema/postgresql/dolphinscheduler_dml.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.0_schema/postgresql/dolphinscheduler_dml.sql

0
sql/upgrade/1.3.2_schema/mysql/dolphinscheduler_ddl.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.2_schema/mysql/dolphinscheduler_ddl.sql

0
sql/upgrade/1.3.2_schema/mysql/dolphinscheduler_dml.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.2_schema/mysql/dolphinscheduler_dml.sql

0
sql/upgrade/1.3.2_schema/postgresql/dolphinscheduler_ddl.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.2_schema/postgresql/dolphinscheduler_ddl.sql

0
sql/upgrade/1.3.2_schema/postgresql/dolphinscheduler_dml.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.2_schema/postgresql/dolphinscheduler_dml.sql

0
sql/upgrade/1.3.3_schema/mysql/dolphinscheduler_ddl.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.3_schema/mysql/dolphinscheduler_ddl.sql

0
sql/upgrade/1.3.3_schema/mysql/dolphinscheduler_dml.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.3_schema/mysql/dolphinscheduler_dml.sql

0
sql/upgrade/1.3.3_schema/postgresql/dolphinscheduler_ddl.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.3_schema/postgresql/dolphinscheduler_ddl.sql

0
sql/upgrade/1.3.3_schema/postgresql/dolphinscheduler_dml.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.3_schema/postgresql/dolphinscheduler_dml.sql

0
sql/upgrade/1.3.5_schema/mysql/dolphinscheduler_ddl.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.5_schema/mysql/dolphinscheduler_ddl.sql

0
sql/upgrade/1.3.5_schema/mysql/dolphinscheduler_dml.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.5_schema/mysql/dolphinscheduler_dml.sql

0
sql/upgrade/1.3.5_schema/postgresql/dolphinscheduler_ddl.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.5_schema/postgresql/dolphinscheduler_ddl.sql

0
sql/upgrade/1.3.5_schema/postgresql/dolphinscheduler_dml.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.5_schema/postgresql/dolphinscheduler_dml.sql

0
sql/upgrade/1.3.6_schema/mysql/dolphinscheduler_ddl.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.6_schema/mysql/dolphinscheduler_ddl.sql

0
sql/upgrade/1.3.6_schema/mysql/dolphinscheduler_dml.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.6_schema/mysql/dolphinscheduler_dml.sql

0
sql/upgrade/1.3.6_schema/postgresql/dolphinscheduler_ddl.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.6_schema/postgresql/dolphinscheduler_ddl.sql

0
sql/upgrade/1.3.6_schema/postgresql/dolphinscheduler_dml.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.6_schema/postgresql/dolphinscheduler_dml.sql

0
sql/upgrade/1.3.7_schema/mysql/dolphinscheduler_ddl.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.7_schema/mysql/dolphinscheduler_ddl.sql

0
sql/upgrade/1.3.7_schema/mysql/dolphinscheduler_dml.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.7_schema/mysql/dolphinscheduler_dml.sql

0
sql/upgrade/1.3.7_schema/postgresql/dolphinscheduler_ddl.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.7_schema/postgresql/dolphinscheduler_ddl.sql

0
sql/upgrade/1.3.7_schema/postgresql/dolphinscheduler_dml.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/1.3.7_schema/postgresql/dolphinscheduler_dml.sql

0
sql/upgrade/2.0.0_schema/mysql/dolphinscheduler_ddl.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.0_schema/mysql/dolphinscheduler_ddl.sql

0
sql/upgrade/2.0.0_schema/mysql/dolphinscheduler_ddl_post.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.0_schema/mysql/dolphinscheduler_ddl_post.sql

0
sql/upgrade/2.0.0_schema/mysql/dolphinscheduler_dml.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.0_schema/mysql/dolphinscheduler_dml.sql

0
sql/upgrade/2.0.0_schema/postgresql/dolphinscheduler_ddl.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.0_schema/postgresql/dolphinscheduler_ddl.sql

0
sql/upgrade/2.0.0_schema/postgresql/dolphinscheduler_ddl_post.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.0_schema/postgresql/dolphinscheduler_ddl_post.sql

0
sql/upgrade/2.0.0_schema/postgresql/dolphinscheduler_dml.sql → dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.0_schema/postgresql/dolphinscheduler_dml.sql

6
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/AlertDaoTest.java

@ -23,15 +23,15 @@ import org.apache.dolphinscheduler.dao.entity.Alert;
import java.util.List; import java.util.List;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@Transactional @Transactional
public class AlertDaoTest { public class AlertDaoTest {
@Before @BeforeClass
public void setUp() { public static void setUp() {
System.setProperty("spring.profiles.active", "h2"); System.setProperty("spring.profiles.active", "h2");
} }

17
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ConnectionFactoryTest.java

@ -17,21 +17,22 @@
package org.apache.dolphinscheduler.dao.mapper; package org.apache.dolphinscheduler.dao.mapper;
import org.apache.dolphinscheduler.dao.datasource.ConnectionFactory; import org.apache.dolphinscheduler.dao.datasource.ConnectionFactory;
import org.junit.Assert;
import org.junit.Test;
import java.sql.Connection; import java.sql.Connection;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
public class ConnectionFactoryTest { public class ConnectionFactoryTest {
@BeforeClass
public static void setup() {
System.setProperty("spring.profiles.active", "h2");
}
/**
* test connection
* @throws Exception if error throws Exception
*/
@Test @Test
public void testConnection()throws Exception{ public void testConnection() throws Exception {
System.setProperty("spring.profiles.active", "h2");
Connection connection = ConnectionFactory.getInstance().getDataSource().getConnection(); Connection connection = ConnectionFactory.getInstance().getDataSource().getConnection();
Assert.assertTrue(connection != null); Assert.assertTrue(connection != null);
} }

8
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/upgrade/ProcessDefinitionDaoTest.java

@ -24,15 +24,15 @@ import java.util.Map;
import javax.sql.DataSource; import javax.sql.DataSource;
import org.junit.Before; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
public class ProcessDefinitionDaoTest { public class ProcessDefinitionDaoTest {
DataSource dataSource; static DataSource dataSource;
final ProcessDefinitionDao processDefinitionDao = new ProcessDefinitionDao(); final ProcessDefinitionDao processDefinitionDao = new ProcessDefinitionDao();
@Before @BeforeClass
public void seuUp() { public static void seuUp() {
System.setProperty("spring.profiles.active", "h2"); System.setProperty("spring.profiles.active", "h2");
dataSource = getDataSource(); dataSource = getDataSource();
} }

7
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/upgrade/UpgradeDaoTest.java

@ -16,14 +16,19 @@
*/ */
package org.apache.dolphinscheduler.dao.upgrade; package org.apache.dolphinscheduler.dao.upgrade;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
public class UpgradeDaoTest { public class UpgradeDaoTest {
private PostgresqlUpgradeDao postgresqlUpgradeDao; private PostgresqlUpgradeDao postgresqlUpgradeDao;
@BeforeClass
public static void setUpClass() {
System.setProperty("spring.profiles.active", "h2");
}
@Test @Test
public void setUp() { public void setUp() {
System.setProperty("spring.profiles.active", "h2");
postgresqlUpgradeDao = PostgresqlUpgradeDao.getInstance(); postgresqlUpgradeDao = PostgresqlUpgradeDao.getInstance();
} }

14
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/upgrade/WorkerGroupDaoTest.java

@ -25,10 +25,22 @@ import java.util.Map;
import javax.sql.DataSource; import javax.sql.DataSource;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
public class WorkerGroupDaoTest { public class WorkerGroupDaoTest {
protected final DataSource dataSource = getDataSource(); protected DataSource dataSource;
@BeforeClass
public static void setupClass() {
System.setProperty("spring.profiles.active", "h2");
}
@Before
public void setup() {
dataSource = getDataSource();
}
@Test @Test
public void testQueryQueryAllOldWorkerGroup() throws Exception { public void testQueryQueryAllOldWorkerGroup() throws Exception {

4
dolphinscheduler-dist/pom.xml vendored

@ -328,7 +328,7 @@
<sources> <sources>
<source> <source>
<location> <location>
${basedir}/../sql ${basedir}/../dolphinscheduler-dao/src/main/resources/sql
</location> </location>
<includes> <includes>
<include>**/*.*</include> <include>**/*.*</include>
@ -336,7 +336,7 @@
</source> </source>
<source> <source>
<location> <location>
${basedir}/../sql ${basedir}/../dolphinscheduler-dao/src/main/resources/sql
</location> </location>
<includes> <includes>
<include>soft_version</include> <include>soft_version</include>

2
dolphinscheduler-dist/src/main/assembly/dolphinscheduler-bin.xml vendored

@ -147,7 +147,7 @@
</fileSet> </fileSet>
<fileSet> <fileSet>
<directory>${basedir}/../sql</directory> <directory>${basedir}/../dolphinscheduler-dao/src/main/resources/sql</directory>
<includes> <includes>
<include>**/*</include> <include>**/*</include>
</includes> </includes>

54
dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/master/WorkflowExecuteThreadTest.java

@ -77,7 +77,7 @@ public class WorkflowExecuteThreadTest {
private ProcessService processService; private ProcessService processService;
private int processDefinitionId = 1; private final int processDefinitionId = 1;
private MasterConfig config; private MasterConfig config;
@ -112,44 +112,9 @@ public class WorkflowExecuteThreadTest {
Field dag = WorkflowExecuteThread.class.getDeclaredField("dag"); Field dag = WorkflowExecuteThread.class.getDeclaredField("dag");
dag.setAccessible(true); dag.setAccessible(true);
dag.set(workflowExecuteThread, new DAG()); dag.set(workflowExecuteThread, new DAG());
PowerMockito.doNothing().when(workflowExecuteThread, "prepareProcess");
PowerMockito.doNothing().when(workflowExecuteThread, "endProcess"); PowerMockito.doNothing().when(workflowExecuteThread, "endProcess");
} }
/**
* without schedule
*/
@Test
public void testParallelWithOutSchedule() throws ParseException {
try {
Mockito.when(processService.queryReleaseSchedulerListByProcessDefinitionCode(processDefinitionId)).thenReturn(zeroSchedulerList());
Method method = WorkflowExecuteThread.class.getDeclaredMethod("executeComplementProcess");
method.setAccessible(true);
method.invoke(workflowExecuteThread);
// one create save, and 1-30 for next save, and last day 20 no save
verify(processService, times(20)).saveProcessInstance(processInstance);
} catch (Exception e) {
e.printStackTrace();
Assert.fail();
}
}
/**
* with schedule
*/
@Test
public void testParallelWithSchedule() {
try {
Mockito.when(processService.queryReleaseSchedulerListByProcessDefinitionCode(processDefinitionId)).thenReturn(oneSchedulerList());
Method method = WorkflowExecuteThread.class.getDeclaredMethod("executeComplementProcess");
method.setAccessible(true);
method.invoke(workflowExecuteThread);
// one create save, and 9(1 to 20 step 2) for next save, and last day 31 no save
verify(processService, times(20)).saveProcessInstance(processInstance);
} catch (Exception e) {
Assert.fail();
}
}
@Test @Test
public void testParseStartNodeName() throws ParseException { public void testParseStartNodeName() throws ParseException {
@ -167,23 +132,6 @@ public class WorkflowExecuteThreadTest {
} }
} }
@Test
public void testRetryTaskIntervalOverTime() {
try {
TaskInstance taskInstance = new TaskInstance();
taskInstance.setId(0);
taskInstance.setMaxRetryTimes(0);
taskInstance.setRetryInterval(0);
taskInstance.setState(ExecutionStatus.FAILURE);
Class<WorkflowExecuteThread> masterExecThreadClass = WorkflowExecuteThread.class;
Method method = masterExecThreadClass.getDeclaredMethod("retryTaskIntervalOverTime", TaskInstance.class);
method.setAccessible(true);
Assert.assertTrue((Boolean) method.invoke(workflowExecuteThread, taskInstance));
} catch (Exception e) {
Assert.fail();
}
}
@Test @Test
public void testGetStartTaskInstanceList() { public void testGetStartTaskInstanceList() {
try { try {

2
dolphinscheduler-standalone-server/src/main/java/org/apache/dolphinscheduler/server/StandaloneServer.java

@ -38,7 +38,7 @@ public class StandaloneServer {
Thread.currentThread().setName("Standalone-Server"); Thread.currentThread().setName("Standalone-Server");
System.setProperty("spring.profiles.active", "api,h2"); System.setProperty("spring.profiles.active", "api,h2");
System.setProperty("spring.datasource.sql.schema", "file:./sql/dolphinscheduler_h2.sql"); System.setProperty("spring.datasource.sql.schema", "classpath:sql/dolphinscheduler_h2.sql");
startRegistry(); startRegistry();

264
pom.xml

@ -129,6 +129,7 @@
<java-websocket.version>1.5.1</java-websocket.version> <java-websocket.version>1.5.1</java-websocket.version>
<py4j.version>0.10.9</py4j.version> <py4j.version>0.10.9</py4j.version>
<auto-service.version>1.0.1</auto-service.version> <auto-service.version>1.0.1</auto-service.version>
<jacoco.skip>false</jacoco.skip>
</properties> </properties>
<dependencyManagement> <dependencyManagement>
@ -884,268 +885,6 @@
<systemPropertyVariables> <systemPropertyVariables>
<jacoco-agent.destfile>${project.build.directory}/jacoco.exec</jacoco-agent.destfile> <jacoco-agent.destfile>${project.build.directory}/jacoco.exec</jacoco-agent.destfile>
</systemPropertyVariables> </systemPropertyVariables>
<includes>
<!--registry plugin -->
<include>**/plugin/registry/zookeeper/ZookeeperRegistryTest.java</include>
<!-- API -->
<include>**/api/controller/ProjectControllerTest.java</include>
<include>**/api/controller/QueueControllerTest.java</include>
<include>**/api/configuration/TrafficConfigurationTest.java</include>
<include>**/api/controller/ProcessDefinitionControllerTest.java</include>
<include>**/api/controller/TenantControllerTest.java</include>
<include>**/api/controller/SchedulerControllerTest.java</include>
<include>**/api/dto/resources/filter/ResourceFilterTest.java</include>
<include>**/api/dto/resources/visitor/ResourceTreeVisitorTest.java</include>
<includeDataxTaskTest>**/api/enums/testGetEnum.java</includeDataxTaskTest>
<include>**/api/enums/StatusTest.java</include>
<include>**/api/exceptions/ApiExceptionHandlerTest.java</include>
<include>**/api/exceptions/ServiceExceptionTest.java</include>
<include>**/api/interceptor/LocaleChangeInterceptorTest.java</include>
<include>**/api/interceptor/LoginHandlerInterceptorTest.java</include>
<include>**/api/interceptor/RateLimitInterceptorTest.java</include>
<include>**/api/security/impl/pwd/PasswordAuthenticatorTest.java</include>
<include>**/api/security/impl/ldap/LdapAuthenticatorTest.java</include>
<include>**/api/security/SecurityConfigLDAPTest.java</include>
<include>**/api/security/SecurityConfigPasswordTest.java</include>
<include>**/api/service/AccessTokenServiceTest.java</include>
<include>**/api/service/AlertGroupServiceTest.java</include>
<include>**/api/service/BaseDAGServiceTest.java</include>
<include>**/api/service/BaseServiceTest.java</include>
<include>**/api/service/DataAnalysisServiceTest.java</include>
<include>**/api/service/AlertPluginInstanceServiceTest.java</include>
<include>**/api/service/DataSourceServiceTest.java</include>
<include>**/api/service/ExecutorService2Test.java</include>
<include>**/api/service/ExecutorServiceTest.java</include>
<include>**/api/service/LoggerServiceTest.java</include>
<include>**/api/service/MonitorServiceTest.java</include>
<include>**/api/service/ProcessDefinitionServiceTest.java</include>
<include>**/api/service/ProcessTaskRelationServiceImplTest.java</include>
<include>**/api/service/TaskDefinitionServiceImplTest.java</include>
<include>**/api/service/ProcessInstanceServiceTest.java</include>
<include>**/api/service/ProjectServiceTest.java</include>
<include>**/api/service/QueueServiceTest.java</include>
<include>**/api/service/ResourcesServiceTest.java</include>
<include>**/api/service/SchedulerServiceTest.java</include>
<include>**/api/service/SessionServiceTest.java</include>
<include>**/api/service/TaskInstanceServiceTest.java</include>
<include>**/api/service/TenantServiceTest.java</include>
<include>**/api/service/UdfFuncServiceTest.java</include>
<include>**/api/service/UiPluginServiceTest.java</include>
<include>**/api/service/UserAlertGroupServiceTest.java</include>
<include>**/api/service/UsersServiceTest.java</include>
<include>**/api/service/WorkerGroupServiceTest.java</include>
<include>**/api/service/WorkFlowLineageServiceTest.java</include>
<include>**/api/service/EnvironmentServiceTest.java</include>
<include>**/api/service/EnvironmentWorkerGroupRelationServiceTest.java</include>
<include>**/api/controller/ProcessDefinitionControllerTest.java</include>
<include>**/api/controller/TaskInstanceControllerTest.java</include>
<include>**/api/controller/WorkFlowLineageControllerTest.java</include>
<include>**/api/controller/EnvironmentControllerTest.java</include>
<include>**/api/utils/exportprocess/DataSourceParamTest.java</include>
<include>**/api/utils/exportprocess/DependentParamTest.java</include>
<include>**/api/utils/CheckUtilsTest.java</include>
<include>**/api/utils/FileUtilsTest.java</include>
<include>**/api/utils/CheckUtilsTest.java</include>
<include>**/api/utils/CheckUtilsTest.java</include>
<include>**/api/utils/ResultTest.java</include>
<include>**/common/graph/DAGTest.java</include>
<include>**/common/os/OshiTest.java</include>
<include>**/common/shell/ShellExecutorTest.java</include>
<include>**/common/task/DataxParametersTest.java</include>
<include>**/common/task/EntityTestUtils.java</include>
<include>**/common/task/FlinkParametersTest.java</include>
<include>**/common/task/HttpParametersTest.java</include>
<include>**/common/task/SparkParametersTest.java</include>
<include>**/common/task/SqlParametersTest.java</include>
<include>**/common/task/SqoopParameterEntityTest.java</include>
<include>**/common/threadutils/ThreadPoolExecutorsTest.java</include>
<include>**/common/threadutils/ThreadUtilsTest.java</include>
<include>**/common/utils/CollectionUtilsTest.java</include>
<include>**/common/utils/CommonUtilsTest.java</include>
<include>**/common/utils/DateUtilsTest.java</include>
<include>**/common/utils/DependentUtilsTest.java</include>
<include>**/common/utils/EncryptionUtilsTest.java</include>
<include>**/common/utils/FileUtilsTest.java</include>
<include>**/common/utils/JSONUtilsTest.java</include>
<include>**/common/utils/LoggerUtilsTest.java</include>
<include>**/common/utils/NetUtilsTest.java</include>
<include>**/common/utils/ParameterUtilsTest.java</include>
<include>**/common/utils/TimePlaceholderUtilsTest.java</include>
<include>**/common/utils/PreconditionsTest.java</include>
<include>**/common/utils/PropertyUtilsTest.java</include>
<include>**/common/utils/SchemaUtilsTest.java</include>
<include>**/common/utils/ScriptRunnerTest.java</include>
<include>**/common/utils/SensitiveLogUtilsTest.java</include>
<include>**/common/utils/StringTest.java</include>
<include>**/common/utils/StringUtilsTest.java</include>
<include>**/common/utils/TaskParametersUtilsTest.java</include>
<include>**/common/utils/VarPoolUtilsTest.java</include>
<include>**/common/utils/HadoopUtilsTest.java</include>
<include>**/common/utils/HttpUtilsTest.java</include>
<include>**/common/utils/KerberosHttpClientTest.java</include>
<include>**/common/utils/HiveConfUtilsTest.java</include>
<include>**/common/ConstantsTest.java</include>
<include>**/common/utils/HadoopUtils.java</include>
<include>**/common/utils/RetryerUtilsTest.java</include>
<include>**/common/datasource/clickhouse/ClickHouseDatasourceProcessorTest.java</include>
<include>**/common/datasource/db2/Db2DatasourceProcessorTest.java</include>
<include>**/common/datasource/hive/HiveDatasourceProcessorTest.java</include>
<include>**/common/datasource/mysql/MysqlDatasourceProcessorTest.java</include>
<include>**/common/datasource/oracle/OracleDatasourceProcessorTest.java</include>
<include>**/common/datasource/postgresql/PostgreSqlDatasourceProcessorTest.java</include>
<include>**/common/datasource/presto/PrestoDatasourceProcessorTest.java</include>
<include>**/common/datasource/spark/SparkDatasourceProcessorTest.java</include>
<include>**/common/datasource/sqlserver/SqlServerDatasourceProcessorTest.java</include>
<include>**/common/datasource/DatasourceUtilTest.java</include>
<include>**/common/enums/ExecutionStatusTest</include>
<include>**/dao/mapper/AccessTokenMapperTest.java</include>
<include>**/dao/mapper/AlertGroupMapperTest.java</include>
<include>**/dao/mapper/CommandMapperTest.java</include>
<include>**/dao/mapper/ConnectionFactoryTest.java</include>
<include>**/dao/mapper/DataSourceMapperTest.java</include>
<include>**/dao/datasource/MySQLDataSourceTest.java</include>
<include>**/dao/entity/TaskInstanceTest.java</include>
<include>**/dao/entity/UdfFuncTest.java</include>
<include>**/remote/command/alert/AlertSendRequestCommandTest.java</include>
<include>**/remote/command/alert/AlertSendResponseCommandTest.java</include>
<include>**/remote/command/future/ResponseFutureTest.java</include>
<include>**/remote/command/log/RemoveTaskLogRequestCommandTest.java</include>
<include>**/remote/command/log/RemoveTaskLogResponseCommandTest.java</include>
<include>**/remote/command/log/GetLogBytesRequestCommandTest.java</include>
<include>**/remote/command/log/GetLogBytesResponseCommandTest.java</include>
<include>**/remote/command/log/ViewLogRequestCommandTest.java</include>
<include>**/remote/utils/HostTest.java</include>
<include>**/remote/utils/NettyUtilTest.java</include>
<include>**/remote/NettyRemotingClientTest.java</include>
<include>**/rpc/RpcTest.java</include>
<include>**/server/log/LoggerServerTest.java</include>
<include>**/server/entity/SQLTaskExecutionContextTest.java</include>
<include>**/server/log/MasterLogFilterTest.java</include>
<include>**/server/log/SensitiveDataConverterTest.java</include>
<include>**/server/log/LoggerRequestProcessorTest.java</include>
<!--<include>**/server/log/TaskLogDiscriminatorTest.java</include>-->
<include>**/server/log/TaskLogFilterTest.java</include>
<include>**/server/log/WorkerLogFilterTest.java</include>
<include>**/server/master/cache/impl/TaskInstanceCacheManagerImplTest.java</include>
<include>**/server/master/config/MasterConfigTest.java</include>
<include>**/server/master/consumer/TaskPriorityQueueConsumerTest.java</include>
<include>**/server/master/runner/MasterTaskExecThreadTest.java</include>
<!--<include>**/server/master/dispatch/executor/NettyExecutorManagerTest.java</include>-->
<include>**/server/master/dispatch/host/assign/LowerWeightRoundRobinTest.java</include>
<include>**/server/master/dispatch/host/assign/RandomSelectorTest.java</include>
<include>**/server/master/dispatch/host/assign/RoundRobinSelectorTest.java</include>
<include>**/server/master/dispatch/host/assign/HostWorkerTest.java</include>
<include>**/server/master/registry/MasterRegistryClientTest.java</include>
<include>**/server/master/registry/ServerNodeManagerTest.java</include>
<include>**/server/master/dispatch/host/RefreshResourceTaskTest.java</include>
<include>**/server/master/dispatch/host/assign/RoundRobinHostManagerTest.java</include>
<include>**/server/master/MasterCommandTest.java</include>
<include>**/server/master/DependentTaskTest.java</include>
<include>**/server/master/ConditionsTaskTest.java</include>
<include>**/server/master/SwitchTaskTest.java</include>
<include>**/server/master/MasterExecThreadTest.java</include>
<include>**/server/master/ParamsTest.java</include>
<include>**/server/master/SubProcessTaskTest.java</include>
<include>**/server/master/processor/TaskAckProcessorTest.java</include>
<include>**/server/master/processor/TaskKillResponseProcessorTest.java</include>
<include>**/server/master/processor/queue/TaskResponseServiceTest.java</include>
<include>**/server/master/zk/ZKMasterClientTest.java</include>
<include>**/server/registry/ZookeeperRegistryCenterTest.java</include>
<include>**/server/utils/DataxUtilsTest.java</include>
<include>**/server/utils/ExecutionContextTestUtils.java</include>
<include>**/server/utils/FlinkArgsUtilsTest.java</include>
<include>**/server/utils/LogUtilsTest.java</include>
<include>**/server/utils/MapReduceArgsUtilsTest.java</include>
<include>**/server/utils/ParamUtilsTest.java</include>
<include>**/server/utils/ProcessUtilsTest.java</include>
<include>**/server/utils/SparkArgsUtilsTest.java</include>
<include>**/server/worker/processor/TaskCallbackServiceTest.java</include>
<include>**/server/worker/processor/TaskExecuteProcessorTest.java</include>
<include>**/server/worker/registry/WorkerRegistryTest.java</include>
<include>**/server/worker/shell/ShellCommandExecutorTest.java</include>
<include>**/server/worker/sql/SqlExecutorTest.java</include>
<include>**/server/worker/task/spark/SparkTaskTest.java</include>
<include>**/server/worker/task/spark/SparkTaskTest.java</include>
<include>**/server/worker/task/datax/DataxTaskTest.java</include>
<!--<include>**/server/worker/task/http/HttpTaskTest.java</include>-->
<include>**/server/worker/task/sqoop/SqoopTaskTest.java</include>
<include>**/server/worker/task/processdure/ProcedureTaskTest.java</include>
<include>**/server/worker/task/shell/ShellTaskTest.java</include>
<include>**/server/worker/task/TaskManagerTest.java</include>
<include>**/server/worker/task/PythonCommandExecutorTest.java</include>
<include>**/server/worker/task/TaskParamsTest.java</include>
<include>**/server/worker/task/ShellTaskReturnTest.java</include>
<include>**/server/worker/task/sql/SqlTaskTest.java</include>
<include>**/server/worker/runner/TaskExecuteThreadTest.java</include>
<include>**/server/worker/runner/WorkerManagerThreadTest.java</include>
<include>**/server/master/cache/impl/ProcessInstanceExecCacheManagerImplTest.java</include>
<include>**/service/quartz/cron/CronUtilsTest.java</include>
<include>**/service/process/ProcessServiceTest.java</include>
<include>**/service/registry/RegistryClientTest.java</include>
<include>**/service/registry/RegistryPluginTest.java</include>
<include>**/service/queue/TaskUpdateQueueTest.java</include>
<include>**/service/queue/PeerTaskInstancePriorityQueueTest.java</include>
<include>**/service/log/LogClientServiceTest.java</include>
<include>**/service/alert/AlertClientServiceTest.java</include>
<include>**/service/alert/ProcessAlertManagerTest.java</include>
<include>**/dao/mapper/DataSourceUserMapperTest.java</include>
<!--<iTaskUpdateQueueConsumerThreadnclude>**/dao/mapper/ErrorCommandMapperTest.java</iTaskUpdateQueueConsumerThreadnclude>-->
<include>**/dao/mapper/ProcessDefinitionMapperTest.java</include>
<include>**/dao/mapper/ProcessInstanceMapMapperTest.java</include>
<include>**/dao/mapper/ProcessInstanceMapperTest.java</include>
<include>**/dao/mapper/ProjectMapperTest.java</include>
<include>**/dao/mapper/ProjectUserMapperTest.java</include>
<include>**/dao/mapper/QueueMapperTest.java</include>
<include>**/dao/mapper/ResourceUserMapperTest.java</include>
<include>**/dao/mapper/ScheduleMapperTest.java</include>
<include>**/dao/mapper/SessionMapperTest.java</include>
<include>**/dao/mapper/TaskInstanceMapperTest.java</include>
<include>**/dao/mapper/TenantMapperTest.java</include>
<include>**/dao/mapper/UdfFuncMapperTest.java</include>
<include>**/dao/mapper/UDFUserMapperTest.java</include>
<include>**/dao/mapper/UserMapperTest.java</include>
<include>**/dao/mapper/AlertPluginInstanceMapperTest.java</include>
<include>**/dao/mapper/PluginDefineTest.java</include>
<include>**/dao/utils/DagHelperTest.java</include>
<include>**/dao/AlertDaoTest.java</include>
<include>**/dao/datasource/OracleDataSourceTest.java</include>
<include>**/dao/datasource/HiveDataSourceTest.java</include>
<include>**/dao/datasource/BaseDataSourceTest.java</include>
<include>**/dao/upgrade/ProcessDefinitionDaoTest.java</include>
<include>**/dao/upgrade/WokrerGrouopDaoTest.java</include>
<include>**/dao/upgrade/UpgradeDaoTest.java</include>
<include>**/plugin/alert/email/EmailAlertChannelFactoryTest.java</include>
<include>**/plugin/alert/email/EmailAlertChannelTest.java</include>
<include>**/plugin/alert/email/ExcelUtilsTest.java</include>
<include>**/plugin/alert/email/template/DefaultHTMLTemplateTest.java</include>
<include>**/plugin/alert/dingtalk/DingTalkSenderTest.java</include>
<include>**/plugin/alert/dingtalk/DingTalkAlertChannelFactoryTest.java</include>
<include>**/plugin/alert/wechat/WeChatSenderTest.java</include>
<include>**/plugin/alert/wechat/WeChatAlertChannelFactoryTest.java</include>
<include>**/plugin/alert/script/ProcessUtilsTest.java</include>
<include>**/plugin/alert/script/ScriptAlertChannelFactoryTest.java</include>
<include>**/plugin/alert/script/ScriptSenderTest.java</include>
<include>**/plugin/alert/http/HttpAlertChannelFactoryTest.java</include>
<include>**/plugin/alert/http/HttpAlertChannelTest.java</include>
<include>**/plugin/alert/feishu/FeiShuAlertChannelFactoryTest.java</include>
<include>**/plugin/alert/feishu/FeiShuSenderTest.java</include>
<include>**/plugin/alert/http/HttpAlertPluginTest.java</include>
<include>**/plugin/alert/http/HttpSenderTest.java</include>
<include>**/plugin/alert/slack/SlackAlertChannelFactoryTest.java</include>
<include>**/plugin/alert/slack/SlackAlertPluginTest.java</include>
<include>**/plugin/alert/slack/SlackSenderTest.java</include>
<include>**/spi/params/PluginParamsTransferTest.java</include>
<include>**/spi/plugin/DolphinSchedulerPluginLoaderTest.java</include>
<include>**/alert/plugin/EmailAlertPluginTest.java</include>
<include>**/alert/plugin/AlertPluginManagerTest.java</include>
<include>**/alert/plugin/DolphinPluginLoaderTest.java</include>
<include>**/alert/utils/FuncUtilsTest.java</include>
<include>**/alert/processor/AlertRequestProcessorTest.java</include>
<include>**/alert/runner/AlertSenderTest.java</include>
<include>**/alert/AlertServerTest.java</include>
<include>**/plugin/task/pigeon/PigeonTaskTest.java</include>
</includes>
<!-- <skip>true</skip> -->
</configuration> </configuration>
</plugin> </plugin>
@ -1155,6 +894,7 @@
<artifactId>jacoco-maven-plugin</artifactId> <artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version> <version>${jacoco.version}</version>
<configuration> <configuration>
<skip>${jacoco.skip}</skip>
<dataFile>${project.build.directory}/jacoco.exec</dataFile> <dataFile>${project.build.directory}/jacoco.exec</dataFile>
</configuration> </configuration>
<executions> <executions>

5
script/dolphinscheduler-daemon.sh

@ -45,6 +45,7 @@ export HOSTNAME=`hostname`
export DOLPHINSCHEDULER_PID_DIR=$DOLPHINSCHEDULER_HOME/pid export DOLPHINSCHEDULER_PID_DIR=$DOLPHINSCHEDULER_HOME/pid
export DOLPHINSCHEDULER_LOG_DIR=$DOLPHINSCHEDULER_HOME/logs export DOLPHINSCHEDULER_LOG_DIR=$DOLPHINSCHEDULER_HOME/logs
export DOLPHINSCHEDULER_CONF_DIR=$DOLPHINSCHEDULER_HOME/conf export DOLPHINSCHEDULER_CONF_DIR=$DOLPHINSCHEDULER_HOME/conf
export DOLPHINSCHEDULER_SQL_DIR=$DOLPHINSCHEDULER_HOME/sql
export DOLPHINSCHEDULER_LIB_JARS=$DOLPHINSCHEDULER_HOME/lib/* export DOLPHINSCHEDULER_LIB_JARS=$DOLPHINSCHEDULER_HOME/lib/*
export STOP_TIMEOUT=5 export STOP_TIMEOUT=5
@ -100,7 +101,7 @@ case $startStop in
if [ "$DOCKER" = "true" ]; then if [ "$DOCKER" = "true" ]; then
echo start $command in docker echo start $command in docker
export DOLPHINSCHEDULER_OPTS="$DOLPHINSCHEDULER_OPTS -XX:-UseContainerSupport" export DOLPHINSCHEDULER_OPTS="$DOLPHINSCHEDULER_OPTS -XX:-UseContainerSupport"
exec_command="$LOG_FILE $DOLPHINSCHEDULER_OPTS -classpath $DOLPHINSCHEDULER_CONF_DIR:$DOLPHINSCHEDULER_LIB_JARS $CLASS" exec_command="$LOG_FILE $DOLPHINSCHEDULER_OPTS -classpath $DOLPHINSCHEDULER_SQL_DIR:$DOLPHINSCHEDULER_CONF_DIR:$DOLPHINSCHEDULER_LIB_JARS $CLASS"
$JAVA_HOME/bin/java $exec_command $JAVA_HOME/bin/java $exec_command
else else
[ -w "$DOLPHINSCHEDULER_PID_DIR" ] || mkdir -p "$DOLPHINSCHEDULER_PID_DIR" [ -w "$DOLPHINSCHEDULER_PID_DIR" ] || mkdir -p "$DOLPHINSCHEDULER_PID_DIR"
@ -113,7 +114,7 @@ case $startStop in
fi fi
echo starting $command, logging to $log echo starting $command, logging to $log
exec_command="$LOG_FILE $DOLPHINSCHEDULER_OPTS -classpath $DOLPHINSCHEDULER_CONF_DIR:$DOLPHINSCHEDULER_LIB_JARS $CLASS" exec_command="$LOG_FILE $DOLPHINSCHEDULER_OPTS -classpath $DOLPHINSCHEDULER_SQL_DIR:$DOLPHINSCHEDULER_CONF_DIR:$DOLPHINSCHEDULER_LIB_JARS $CLASS"
echo "nohup $JAVA_HOME/bin/java $exec_command > $log 2>&1 &" echo "nohup $JAVA_HOME/bin/java $exec_command > $log 2>&1 &"
nohup $JAVA_HOME/bin/java $exec_command > $log 2>&1 & nohup $JAVA_HOME/bin/java $exec_command > $log 2>&1 &
echo $! > $pid echo $! > $pid

Loading…
Cancel
Save