kezhenxu94 commented on a change in pull request #6015:
URL: https://github.com/apache/dolphinscheduler/pull/6015#discussion_r694445228



##########
File path: dolphinscheduler-task-plugin/dolphinscheduler-task-tis/pom.xml
##########
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>

Review comment:
       Still missing license header

##########
File path: dolphinscheduler-task-plugin/dolphinscheduler-task-tis/pom.xml
##########
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0";
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+    <parent>
+        <artifactId>dolphinscheduler-task-plugin</artifactId>
+        <groupId>org.apache.dolphinscheduler</groupId>
+        <version>1.3.6-SNAPSHOT</version>
+    </parent>
+
+
+    <modelVersion>4.0.0</modelVersion>
+
+<!--    <packaging>dolphinscheduler-plugin</packaging>-->

Review comment:
       remove this

##########
File path: dolphinscheduler-dist/release-docs/LICENSE
##########
@@ -492,6 +492,8 @@ The text of each license is also included at 
licenses/LICENSE-[project].txt.
     slf4j-api 1.7.5: 
https://mvnrepository.com/artifact/org.slf4j/slf4j-api/1.7.5, MIT
     animal-sniffer-annotations 1.14 
https://mvnrepository.com/artifact/org.codehaus.mojo/animal-sniffer-annotations/1.14,
 MIT
     checker-compat-qual 2.0.0 
https://mvnrepository.com/artifact/org.checkerframework/checker-compat-qual/2.0.0,
 MIT + GPLv2
+    moco-core 1.2.0: 
https://mvnrepository.com/artifact/com.github.dreamhead/moco-core/1.2.0, MIT
+    moco-runner 1.2.0: 
https://mvnrepository.com/artifact/com.github.dreamhead/moco-runner/1.2.0, MIT

Review comment:
       Why should we add these, they are `test` scope dependencies

##########
File path: 
dolphinscheduler-task-plugin/dolphinscheduler-task-tis/src/test/java/org/apache/dolphinscheduler/plugin/task/tis/TISTaskTest.java
##########
@@ -0,0 +1,151 @@
+package org.apache.dolphinscheduler.plugin.task.tis;/*
+ * 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.
+ */
+
+import com.github.dreamhead.moco.HttpServer;
+import org.apache.commons.io.IOUtils;
+import org.apache.dolphinscheduler.server.worker.task.TaskProps;
+import org.apache.dolphinscheduler.spi.task.ExecutionStatus;
+import org.apache.dolphinscheduler.spi.task.TaskRequest;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.powermock.api.mockito.PowerMockito;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.*;
+
+import static com.github.dreamhead.moco.Moco.pathResource;
+import static com.github.dreamhead.moco.MocoJsonRunner.jsonHttpServer;
+import static com.github.dreamhead.moco.Runner.running;
+
+
+public class TISTaskTest {
+    private static final Logger logger = 
LoggerFactory.getLogger(TISTaskTest.class);
+    private TISTask tisTask;
+
+    private TaskRequest taskExecutionContext;
+
+    @Before
+    public void before() throws Exception {
+
+        TaskProps props = new TaskProps();
+        props.setExecutePath("/tmp");
+        props.setTaskAppId(String.valueOf(System.currentTimeMillis()));
+        props.setTaskInstanceId(1);
+        props.setTenantCode("1");
+        props.setEnvFile(".dolphinscheduler_env.sh");
+        props.setTaskStartTime(new Date());
+        props.setTaskTimeout(0);
+        props.setTaskParams("{\"targetJobName\":\"mysql_elastic\"}");
+
+
+        taskExecutionContext = Mockito.mock(TaskRequest.class);
+        
Mockito.when(taskExecutionContext.getTaskParams()).thenReturn(props.getTaskParams());
+        Mockito.when(taskExecutionContext.getExecutePath()).thenReturn("/tmp");
+        
Mockito.when(taskExecutionContext.getTaskAppId()).thenReturn(UUID.randomUUID().toString());
+        Mockito.when(taskExecutionContext.getTenantCode()).thenReturn("root");
+        Mockito.when(taskExecutionContext.getStartTime()).thenReturn(new 
Date());
+        Mockito.when(taskExecutionContext.getTaskTimeout()).thenReturn(10000);
+        Mockito.when(taskExecutionContext.getLogPath()).thenReturn("/tmp/dx");
+//        Mockito.when(taskExecutionContext.getVarPool())
+//                .thenReturn("[{\"direct\":\"IN\",\"prop\":\"" + 
TISTask.KEY_POOL_VAR_TIS_HOST + 
"\",\"type\":\"VARCHAR\",\"value\":\"127.0.0.1:8080\"}]");
+        Map<String, String> gloabParams = 
Collections.singletonMap(TISTask.KEY_POOL_VAR_TIS_HOST, "127.0.0.1:8080");
+        
Mockito.when(taskExecutionContext.getDefinedParams()).thenReturn(gloabParams);
+
+        tisTask = PowerMockito.spy(new TISTask(taskExecutionContext, logger));
+        tisTask.init();
+
+    }
+
+    /**
+     * Method: DataxTask()
+     */
+    @Test
+    public void testDataxTask()
+            throws Exception {
+        TaskProps props = new TaskProps();
+        props.setExecutePath("/tmp");
+        props.setTaskAppId(String.valueOf(System.currentTimeMillis()));
+        props.setTaskInstanceId(1);
+        props.setTenantCode("1");
+        Assert.assertNotNull(new TISTask(null, logger));
+    }
+
+    /**
+     * Method: init
+     */
+    @Test
+    public void testInit()
+            throws Exception {
+        try {
+            tisTask.init();
+        } catch (Exception e) {
+            Assert.fail(e.getMessage());
+        }
+    }
+
+    /**
+     * Method: handle()
+     */
+    @Test
+    public void testHandle()
+            throws Exception {
+        String taskName = "mysql_elastic";
+        int taskid = 1087;
+
+        // 
https://github.com/dreamhead/moco/blob/master/moco-doc/websocket-apis.md
+        // 
https://github.com/dreamhead/moco/blob/master/moco-doc/socket-apis.md#json-text
+        // https://blog.csdn.net/qq_36450484/article/details/99655976

Review comment:
       Remove this kind of links

##########
File path: 
dolphinscheduler-task-plugin/dolphinscheduler-task-tis/src/main/java/org/apache/dolphinscheduler/plugin/task/tis/TISTaskChannel.java
##########
@@ -0,0 +1,37 @@
+/*
+ * 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.plugin.task.tis;
+
+import org.apache.dolphinscheduler.spi.task.AbstractTask;
+import org.apache.dolphinscheduler.spi.task.TaskChannel;
+import org.apache.dolphinscheduler.spi.task.TaskRequest;
+
+/**
+ *
+ **/

Review comment:
       remove 

##########
File path: 
dolphinscheduler-task-plugin/dolphinscheduler-task-tis/src/test/java/org/apache/dolphinscheduler/plugin/task/tis/TISTaskTest.java
##########
@@ -0,0 +1,151 @@
+package org.apache.dolphinscheduler.plugin.task.tis;/*
+ * 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.
+ */
+
+import com.github.dreamhead.moco.HttpServer;
+import org.apache.commons.io.IOUtils;
+import org.apache.dolphinscheduler.server.worker.task.TaskProps;
+import org.apache.dolphinscheduler.spi.task.ExecutionStatus;
+import org.apache.dolphinscheduler.spi.task.TaskRequest;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.powermock.api.mockito.PowerMockito;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.*;
+
+import static com.github.dreamhead.moco.Moco.pathResource;
+import static com.github.dreamhead.moco.MocoJsonRunner.jsonHttpServer;
+import static com.github.dreamhead.moco.Runner.running;
+
+
+public class TISTaskTest {
+    private static final Logger logger = 
LoggerFactory.getLogger(TISTaskTest.class);
+    private TISTask tisTask;
+
+    private TaskRequest taskExecutionContext;
+
+    @Before
+    public void before() throws Exception {
+
+        TaskProps props = new TaskProps();
+        props.setExecutePath("/tmp");
+        props.setTaskAppId(String.valueOf(System.currentTimeMillis()));
+        props.setTaskInstanceId(1);
+        props.setTenantCode("1");
+        props.setEnvFile(".dolphinscheduler_env.sh");
+        props.setTaskStartTime(new Date());
+        props.setTaskTimeout(0);
+        props.setTaskParams("{\"targetJobName\":\"mysql_elastic\"}");
+
+
+        taskExecutionContext = Mockito.mock(TaskRequest.class);
+        
Mockito.when(taskExecutionContext.getTaskParams()).thenReturn(props.getTaskParams());
+        Mockito.when(taskExecutionContext.getExecutePath()).thenReturn("/tmp");
+        
Mockito.when(taskExecutionContext.getTaskAppId()).thenReturn(UUID.randomUUID().toString());
+        Mockito.when(taskExecutionContext.getTenantCode()).thenReturn("root");
+        Mockito.when(taskExecutionContext.getStartTime()).thenReturn(new 
Date());
+        Mockito.when(taskExecutionContext.getTaskTimeout()).thenReturn(10000);
+        Mockito.when(taskExecutionContext.getLogPath()).thenReturn("/tmp/dx");
+//        Mockito.when(taskExecutionContext.getVarPool())
+//                .thenReturn("[{\"direct\":\"IN\",\"prop\":\"" + 
TISTask.KEY_POOL_VAR_TIS_HOST + 
"\",\"type\":\"VARCHAR\",\"value\":\"127.0.0.1:8080\"}]");
+        Map<String, String> gloabParams = 
Collections.singletonMap(TISTask.KEY_POOL_VAR_TIS_HOST, "127.0.0.1:8080");
+        
Mockito.when(taskExecutionContext.getDefinedParams()).thenReturn(gloabParams);
+
+        tisTask = PowerMockito.spy(new TISTask(taskExecutionContext, logger));
+        tisTask.init();
+
+    }
+
+    /**
+     * Method: DataxTask()
+     */
+    @Test
+    public void testDataxTask()
+            throws Exception {
+        TaskProps props = new TaskProps();
+        props.setExecutePath("/tmp");
+        props.setTaskAppId(String.valueOf(System.currentTimeMillis()));
+        props.setTaskInstanceId(1);
+        props.setTenantCode("1");
+        Assert.assertNotNull(new TISTask(null, logger));
+    }
+
+    /**
+     * Method: init
+     */
+    @Test
+    public void testInit()
+            throws Exception {
+        try {
+            tisTask.init();
+        } catch (Exception e) {
+            Assert.fail(e.getMessage());
+        }
+    }
+
+    /**
+     * Method: handle()
+     */

Review comment:
       Remove meaningless comments




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to