[3.1.1][API]Fix updating workflow definition causing task definition data to be duplicated. (#12712)
This commit is contained in:
parent
215c571c8d
commit
7f3193643a
|
|
@ -25,6 +25,7 @@ import java.util.Map;
|
|||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
|
||||
/**
|
||||
* ScriptSenderTest
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
|||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.Constants;
|
||||
import org.apache.dolphinscheduler.common.enums.NodeType;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.dao.entity.WorkerGroup;
|
||||
|
|
@ -50,6 +49,7 @@ import org.springframework.util.MultiValueMap;
|
|||
* worker group controller test
|
||||
*/
|
||||
public class WorkerGroupControllerTest extends AbstractControllerTest {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(WorkerGroupControllerTest.class);
|
||||
|
||||
@MockBean(name = "workerGroupMapper")
|
||||
|
|
@ -69,10 +69,10 @@ public class WorkerGroupControllerTest extends AbstractControllerTest {
|
|||
Mockito.when(registryClient.getServerMaps(NodeType.WORKER)).thenReturn(serverMaps);
|
||||
|
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||
paramsMap.add("name","cxc_work_group");
|
||||
paramsMap.add("addrList","192.168.0.1,192.168.0.2");
|
||||
paramsMap.add("description","");
|
||||
paramsMap.add("otherParamsJson","");
|
||||
paramsMap.add("name", "cxc_work_group");
|
||||
paramsMap.add("addrList", "192.168.0.1,192.168.0.2");
|
||||
paramsMap.add("description", "");
|
||||
paramsMap.add("otherParamsJson", "");
|
||||
MvcResult mvcResult = mockMvc.perform(post("/worker-groups")
|
||||
.header("sessionId", sessionId)
|
||||
.params(paramsMap))
|
||||
|
|
@ -87,9 +87,9 @@ public class WorkerGroupControllerTest extends AbstractControllerTest {
|
|||
@Test
|
||||
public void testQueryAllWorkerGroupsPaging() throws Exception {
|
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||
paramsMap.add("pageNo","2");
|
||||
paramsMap.add("searchVal","cxc");
|
||||
paramsMap.add("pageSize","2");
|
||||
paramsMap.add("pageNo", "2");
|
||||
paramsMap.add("searchVal", "cxc");
|
||||
paramsMap.add("pageSize", "2");
|
||||
MvcResult mvcResult = mockMvc.perform(get("/worker-groups")
|
||||
.header("sessionId", sessionId)
|
||||
.params(paramsMap))
|
||||
|
|
@ -118,7 +118,7 @@ public class WorkerGroupControllerTest extends AbstractControllerTest {
|
|||
@Test
|
||||
public void queryWorkerAddressList() throws Exception {
|
||||
MvcResult mvcResult = mockMvc.perform(get("/worker-groups/worker-address-list")
|
||||
.header("sessionId", sessionId))
|
||||
.header("sessionId", sessionId))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
|
||||
.andReturn();
|
||||
|
|
@ -133,7 +133,8 @@ public class WorkerGroupControllerTest extends AbstractControllerTest {
|
|||
workerGroup.setId(12);
|
||||
workerGroup.setName("测试");
|
||||
Mockito.when(workerGroupMapper.selectById(12)).thenReturn(workerGroup);
|
||||
Mockito.when(processInstanceMapper.queryByWorkerGroupNameAndStatus("测试", org.apache.dolphinscheduler.service.utils.Constants.NOT_TERMINATED_STATES))
|
||||
Mockito.when(processInstanceMapper.queryByWorkerGroupNameAndStatus("测试",
|
||||
org.apache.dolphinscheduler.service.utils.Constants.NOT_TERMINATED_STATES))
|
||||
.thenReturn(null);
|
||||
Mockito.when(workerGroupMapper.deleteById(12)).thenReturn(1);
|
||||
Mockito.when(processInstanceMapper.updateProcessInstanceByWorkerGroupName("测试", "")).thenReturn(1);
|
||||
|
|
|
|||
|
|
@ -16,17 +16,14 @@
|
|||
*/
|
||||
package org.apache.dolphinscheduler.api.utils;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.common.Constants;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ResultTest {
|
||||
|
||||
|
|
|
|||
|
|
@ -24,10 +24,9 @@ import static org.junit.Assert.assertTrue;
|
|||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import org.apache.dolphinscheduler.common.Constants;
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
||||
import org.apache.dolphinscheduler.common.constants.Constants;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.powermock.reflect.Whitebox;
|
||||
|
|
|
|||
|
|
@ -17,13 +17,10 @@
|
|||
|
||||
package org.apache.dolphinscheduler.plugin.datasource.presto.param;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import org.apache.dolphinscheduler.common.constants.DataSourceConstants;
|
||||
import org.apache.dolphinscheduler.plugin.datasource.api.plugin.DataSourceClientProvider;
|
||||
import org.apache.dolphinscheduler.plugin.datasource.api.utils.CommonUtils;
|
||||
import org.apache.dolphinscheduler.plugin.datasource.api.utils.DataSourceUtils;
|
||||
=======
|
||||
import org.apache.dolphinscheduler.common.constants.DataSourceConstants;
|
||||
>>>>>>> dedff70f9 ([Improvement] Merge spi.utils into common.utils (#12502))
|
||||
import org.apache.dolphinscheduler.plugin.datasource.api.utils.PasswordUtils;
|
||||
import org.apache.dolphinscheduler.spi.enums.DbType;
|
||||
|
||||
|
|
@ -33,6 +30,7 @@ import java.util.Map;
|
|||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
|
|
@ -40,7 +38,8 @@ import org.powermock.core.classloader.annotations.PrepareForTest;
|
|||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({Class.class, DriverManager.class, DataSourceUtils.class, CommonUtils.class, DataSourceClientProvider.class, PasswordUtils.class})
|
||||
@PrepareForTest({Class.class, DriverManager.class, DataSourceUtils.class, CommonUtils.class,
|
||||
DataSourceClientProvider.class, PasswordUtils.class})
|
||||
public class PrestoDataSourceProcessorTest {
|
||||
|
||||
private PrestoDataSourceProcessor prestoDatasourceProcessor = new PrestoDataSourceProcessor();
|
||||
|
|
@ -66,8 +65,9 @@ public class PrestoDataSourceProcessorTest {
|
|||
|
||||
@Test
|
||||
public void testCreateConnectionParams2() {
|
||||
String connectionJson = "{\"user\":\"root\",\"password\":\"123456\",\"address\":\"jdbc:presto://localhost:1234\""
|
||||
+ ",\"database\":\"default\",\"jdbcUrl\":\"jdbc:presto://localhost:1234/default\"}";
|
||||
String connectionJson =
|
||||
"{\"user\":\"root\",\"password\":\"123456\",\"address\":\"jdbc:presto://localhost:1234\""
|
||||
+ ",\"database\":\"default\",\"jdbcUrl\":\"jdbc:presto://localhost:1234/default\"}";
|
||||
PrestoConnectionParam connectionParams = (PrestoConnectionParam) prestoDatasourceProcessor
|
||||
.createConnectionParams(connectionJson);
|
||||
Assert.assertNotNull(connectionParams);
|
||||
|
|
@ -76,12 +76,8 @@ public class PrestoDataSourceProcessorTest {
|
|||
|
||||
@Test
|
||||
public void testGetDatasourceDriver() {
|
||||
<<<<<<< HEAD
|
||||
Assert.assertEquals(Constants.COM_PRESTO_JDBC_DRIVER, prestoDatasourceProcessor.getDatasourceDriver());
|
||||
=======
|
||||
Assertions.assertEquals(DataSourceConstants.COM_PRESTO_JDBC_DRIVER,
|
||||
prestoDatasourceProcessor.getDatasourceDriver());
|
||||
>>>>>>> dedff70f9 ([Improvement] Merge spi.utils into common.utils (#12502))
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -101,11 +97,7 @@ public class PrestoDataSourceProcessorTest {
|
|||
|
||||
@Test
|
||||
public void testGetValidationQuery() {
|
||||
<<<<<<< HEAD
|
||||
Assert.assertEquals(Constants.PRESTO_VALIDATION_QUERY, prestoDatasourceProcessor.getValidationQuery());
|
||||
=======
|
||||
Assertions.assertEquals(DataSourceConstants.PRESTO_VALIDATION_QUERY,
|
||||
prestoDatasourceProcessor.getValidationQuery());
|
||||
>>>>>>> dedff70f9 ([Improvement] Merge spi.utils into common.utils (#12502))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2535,6 +2535,8 @@ public class ProcessServiceImpl implements ProcessService {
|
|||
TaskDefinition task = taskDefinitionMap.get(taskDefinitionToUpdate.getCode());
|
||||
if (task == null) {
|
||||
newTaskDefinitionLogs.add(taskDefinitionToUpdate);
|
||||
} else {
|
||||
taskDefinitionToUpdate.setId(task.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,9 +17,7 @@
|
|||
|
||||
package org.apache.dolphinscheduler.service.process;
|
||||
|
||||
import static org.apache.dolphinscheduler.common.constants.CommandKeyConstants.CMD_PARAM_RECOVER_PROCESS_ID_STRING;
|
||||
import static org.apache.dolphinscheduler.common.constants.CommandKeyConstants.CMD_PARAM_START_PARAMS;
|
||||
import static org.apache.dolphinscheduler.common.constants.CommandKeyConstants.CMD_PARAM_SUB_PROCESS_DEFINE_CODE;
|
||||
import static org.apache.dolphinscheduler.common.constants.CommandKeyConstants.*;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
|
||||
import org.apache.dolphinscheduler.common.constants.Constants;
|
||||
|
|
@ -221,15 +219,15 @@ public class ProcessServiceTest {
|
|||
parentInstance.setCommandType(CommandType.START_FAILURE_TASK_PROCESS);
|
||||
parentInstance.setHistoryCmd("COMPLEMENT_DATA,START_FAILURE_TASK_PROCESS");
|
||||
Map<String, String> complementMap = new HashMap<>();
|
||||
complementMap.put(Constants.CMDPARAM_COMPLEMENT_DATA_START_DATE, startString);
|
||||
complementMap.put(Constants.CMDPARAM_COMPLEMENT_DATA_END_DATE, endString);
|
||||
complementMap.put(CMD_PARAM_COMPLEMENT_DATA_START_DATE, startString);
|
||||
complementMap.put(CMD_PARAM_COMPLEMENT_DATA_END_DATE, endString);
|
||||
parentInstance.setCommandParam(JSONUtils.toJsonString(complementMap));
|
||||
command = processService.createSubProcessCommand(parentInstance, childInstance, instanceMap, task);
|
||||
Assert.assertEquals(CommandType.COMPLEMENT_DATA, command.getCommandType());
|
||||
|
||||
JsonNode complementDate = JSONUtils.parseObject(command.getCommandParam());
|
||||
Date start = DateUtils.stringToDate(complementDate.get(Constants.CMDPARAM_COMPLEMENT_DATA_START_DATE).asText());
|
||||
Date end = DateUtils.stringToDate(complementDate.get(Constants.CMDPARAM_COMPLEMENT_DATA_END_DATE).asText());
|
||||
Date start = DateUtils.stringToDate(complementDate.get(CMD_PARAM_COMPLEMENT_DATA_START_DATE).asText());
|
||||
Date end = DateUtils.stringToDate(complementDate.get(CMD_PARAM_COMPLEMENT_DATA_END_DATE).asText());
|
||||
Assert.assertEquals(startString, DateUtils.dateToString(start));
|
||||
Assert.assertEquals(endString, DateUtils.dateToString(end));
|
||||
|
||||
|
|
|
|||
|
|
@ -18,10 +18,9 @@
|
|||
package org.apache.dolphinscheduler.service.utils;
|
||||
|
||||
import org.apache.dolphinscheduler.common.utils.FileUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.PropertyUtils;
|
||||
import org.apache.dolphinscheduler.service.storage.impl.HadoopUtils;
|
||||
|
||||
import org.apache.dolphinscheduler.spi.utils.PropertyUtils;
|
||||
|
||||
import org.apache.hadoop.security.UserGroupInformation;
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
|
|
|||
Loading…
Reference in New Issue