Skip to content

Commit

Permalink
Merge branch 'dev' into issues/15649
Browse files Browse the repository at this point in the history
  • Loading branch information
SbloodyS authored Mar 4, 2024
2 parents 2eaa61c + 502b49a commit 51e9eb5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
12 changes: 6 additions & 6 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/dolphinscheduler-registry/ @caishunfeng @ruanwenjun
/dolphinscheduler-api/ @caishunfeng @SbloodyS
/dolphinscheduler-dao/ @caishunfeng @SbloodyS
/dolphinscheduler-dao/src/main/resources/sql/ @zhongjiajie
/dolphinscheduler-dao/src/main/resources/sql/ @EricGao888
/dolphinscheduler-common/ @caishunfeng
/dolphinscheduler-standalone-server/ @caishunfeng
/dolphinscheduler-datasource-plugin/ @caishunfeng
Expand All @@ -36,10 +36,10 @@
/dolphinscheduler-extract/ @caishunfeng @ruanwenjun
/dolphinscheduler-spi/ @caishunfeng
/dolphinscheduler-task-plugin/ @caishunfeng @SbloodyS @zhuangchong
/dolphinscheduler-tools/ @caishunfeng @SbloodyS @zhongjiajie @EricGao888
/script/ @caishunfeng @SbloodyS @zhongjiajie @EricGao888
/dolphinscheduler-tools/ @caishunfeng @SbloodyS @EricGao888
/script/ @caishunfeng @SbloodyS @EricGao888
/dolphinscheduler-ui/ @songjianet @Amy0104
/docs/ @zhongjiajie @EricGao888
/licenses/ @zhongjiajie
/images/ @zhongjiajie @EricGao888
/docs/ @EricGao888
/licenses/ @EricGao888
/images/ @EricGao888
/style/ @caishunfeng
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
import org.apache.dolphinscheduler.extract.common.transportor.TaskInstanceLogPageQueryRequest;
import org.apache.dolphinscheduler.extract.common.transportor.TaskInstanceLogPageQueryResponse;

import java.io.IOException;
import java.net.ServerSocket;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -89,9 +91,17 @@ public class LoggerServiceTest {

private NettyRemotingServer nettyRemotingServer;

private int nettyServerPort = 18080;

@BeforeEach
public void setUp() {
nettyRemotingServer = new NettyRemotingServer(NettyServerConfig.builder().listenPort(8080).build());
try (ServerSocket s = new ServerSocket(0)) {
nettyServerPort = s.getLocalPort();
} catch (IOException e) {
return;
}

nettyRemotingServer = new NettyRemotingServer(NettyServerConfig.builder().listenPort(nettyServerPort).build());
nettyRemotingServer.start();
SpringServerMethodInvokerDiscovery springServerMethodInvokerDiscovery =
new SpringServerMethodInvokerDiscovery(nettyRemotingServer);
Expand Down Expand Up @@ -148,7 +158,7 @@ public void testQueryLog() {
Assertions.assertEquals(Status.TASK_INSTANCE_HOST_IS_NULL.getCode(), result.getCode().intValue());

// PROJECT_NOT_EXIST
taskInstance.setHost("127.0.0.1:8080");
taskInstance.setHost("127.0.0.1:" + nettyServerPort);
taskInstance.setLogPath("/temp/log");
doThrow(new ServiceException(Status.PROJECT_NOT_EXIST)).when(projectService)
.checkProjectAndAuthThrowException(loginUser, taskInstance.getProjectCode(), VIEW_LOG);
Expand Down Expand Up @@ -198,7 +208,7 @@ public void testGetLogBytes() {
}

// PROJECT_NOT_EXIST
taskInstance.setHost("127.0.0.1:8080");
taskInstance.setHost("127.0.0.1:" + nettyServerPort);
taskInstance.setLogPath("/temp/log");
doThrow(new ServiceException(Status.PROJECT_NOT_EXIST)).when(projectService)
.checkProjectAndAuthThrowException(loginUser, taskInstance.getProjectCode(), VIEW_LOG);
Expand All @@ -215,7 +225,7 @@ public void testGetLogBytes() {
doNothing().when(projectService).checkProjectAndAuthThrowException(loginUser, taskInstance.getProjectCode(),
DOWNLOAD_LOG);
byte[] logBytes = loggerService.getLogBytes(loginUser, 1);
Assertions.assertEquals(47, logBytes.length);
Assertions.assertEquals(43, logBytes.length - String.valueOf(nettyServerPort).length());
}

@Test
Expand All @@ -233,7 +243,7 @@ public void testQueryLogInSpecifiedProject() {
// SUCCESS
taskInstance.setTaskCode(1L);
taskInstance.setId(1);
taskInstance.setHost("127.0.0.1:8080");
taskInstance.setHost("127.0.0.1:" + nettyServerPort);
taskInstance.setLogPath("/temp/log");
doNothing().when(projectService).checkProjectAndAuthThrowException(loginUser, projectCode, VIEW_LOG);
when(taskInstanceDao.queryById(1)).thenReturn(taskInstance);
Expand All @@ -259,7 +269,7 @@ public void testGetLogBytesInSpecifiedProject() {
// SUCCESS
taskInstance.setTaskCode(1L);
taskInstance.setId(1);
taskInstance.setHost("127.0.0.1:8080");
taskInstance.setHost("127.0.0.1:" + nettyServerPort);
taskInstance.setLogPath("/temp/log");
doNothing().when(projectService).checkProjectAndAuthThrowException(loginUser, projectCode, DOWNLOAD_LOG);
when(taskInstanceDao.queryById(1)).thenReturn(taskInstance);
Expand Down

0 comments on commit 51e9eb5

Please sign in to comment.