[ Cmii ] [ Octopus ] - add Image Function Scheduler - 2
This commit is contained in:
@@ -22,6 +22,9 @@ public class ImageSyncContext {
|
|||||||
// function args
|
// function args
|
||||||
ArrayList<String> imageSyncFuncArgs;
|
ArrayList<String> imageSyncFuncArgs;
|
||||||
|
|
||||||
|
// download only
|
||||||
|
Boolean downloadAndCompressOnly;
|
||||||
|
|
||||||
// target
|
// target
|
||||||
ProjectInfoPO projectInfoPO;
|
ProjectInfoPO projectInfoPO;
|
||||||
ServerInfoPO projectMasterNode;
|
ServerInfoPO projectMasterNode;
|
||||||
|
|||||||
@@ -121,12 +121,15 @@ public class FuncServiceImpl implements FuncService {
|
|||||||
// add in
|
// add in
|
||||||
funcArgs.add(0, imageFunctionEnum.getFuncName());
|
funcArgs.add(0, imageFunctionEnum.getFuncName());
|
||||||
|
|
||||||
return syncCallFunction(
|
List<String> resultLog = syncCallFunction(
|
||||||
agentTopicName,
|
agentTopicName,
|
||||||
ExecutionMessageType.IMAGE,
|
ExecutionMessageType.IMAGE,
|
||||||
funcArgs,
|
funcArgs,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
|
funcArgs.remove(0);
|
||||||
|
return resultLog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -81,10 +81,12 @@ public class ImageFuncScheduler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (CollectionUtils.isNotEmpty(cmiiAppNameTagList)) {
|
if (CollectionUtils.isNotEmpty(imageFullNameList)) {
|
||||||
if (CollectionUtils.isEmpty(realFullNameList)) {
|
if (CollectionUtils.isEmpty(realFullNameList)) {
|
||||||
|
//
|
||||||
realFullNameList = imageFullNameList;
|
realFullNameList = imageFullNameList;
|
||||||
} else {
|
} else {
|
||||||
|
// cmii app tag name not null && imageFullNameList not nuill
|
||||||
realFullNameList.addAll(imageFullNameList);
|
realFullNameList.addAll(imageFullNameList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -122,6 +124,12 @@ public class ImageFuncScheduler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.info("Image Sync Half Complete ! Gzip file name => {}", gzipFileName);
|
||||||
|
if (imageSyncContext.getDownloadAndCompressOnly()) {
|
||||||
|
log.info("Image Sync download only !");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// outside agent
|
// outside agent
|
||||||
resultLog = funcService.callImageFuncService(outsideAgentTopicName, DOWNLOAD_GZIP_IMAGE_FILE, imageSyncFuncArgs);
|
resultLog = funcService.callImageFuncService(outsideAgentTopicName, DOWNLOAD_GZIP_IMAGE_FILE, imageSyncFuncArgs);
|
||||||
if (!JudgeSyncBaseCommandResult(resultLog)) {
|
if (!JudgeSyncBaseCommandResult(resultLog)) {
|
||||||
|
|||||||
@@ -31,8 +31,12 @@ public class CoreProjectServiceImpl implements CoreProjectService {
|
|||||||
@Override
|
@Override
|
||||||
public Page<ProjectInfoPO> projectQueryByEntity(ProjectQueryEntity projectQueryEntity) {
|
public Page<ProjectInfoPO> projectQueryByEntity(ProjectQueryEntity projectQueryEntity) {
|
||||||
|
|
||||||
if (projectQueryEntity == null || projectQueryEntity.getProjectName() == null || projectQueryEntity.getProjectNamespace() == null) {
|
if (projectQueryEntity == null) {
|
||||||
return null;
|
return null;
|
||||||
|
} else {
|
||||||
|
if (projectQueryEntity.getProjectName() == null && projectQueryEntity.getProjectNamespace() == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (projectQueryEntity.getPageNumber() == null || projectQueryEntity.getPageSize() == null) {
|
if (projectQueryEntity.getPageNumber() == null || projectQueryEntity.getPageSize() == null) {
|
||||||
@@ -45,6 +49,7 @@ public class CoreProjectServiceImpl implements CoreProjectService {
|
|||||||
projectQueryEntity.getPageSize()
|
projectQueryEntity.getPageSize()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// like wdd?
|
||||||
new LambdaQueryChainWrapper<ProjectInfoPO>(projectInfoService.getBaseMapper())
|
new LambdaQueryChainWrapper<ProjectInfoPO>(projectInfoService.getBaseMapper())
|
||||||
.likeRight(
|
.likeRight(
|
||||||
StringUtils.isNotBlank(projectQueryEntity.getProjectName()),
|
StringUtils.isNotBlank(projectQueryEntity.getProjectName()),
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ spring:
|
|||||||
allow-circular-references: true
|
allow-circular-references: true
|
||||||
allow-bean-definition-overriding: true
|
allow-bean-definition-overriding: true
|
||||||
rabbitmq:
|
rabbitmq:
|
||||||
host: 192.168.35.71
|
host: 10.250.0.100
|
||||||
port: 20672
|
port: 20672
|
||||||
username: boge
|
username: boge
|
||||||
password: boge8tingH
|
password: boge8tingH
|
||||||
@@ -21,7 +21,7 @@ spring:
|
|||||||
max-interval: 65000
|
max-interval: 65000
|
||||||
initial-interval: 65000
|
initial-interval: 65000
|
||||||
redis:
|
redis:
|
||||||
host: 192.168.35.71
|
host: 10.250.0.100
|
||||||
port: 21370
|
port: 21370
|
||||||
database: 0
|
database: 0
|
||||||
password: boge8tingH
|
password: boge8tingH
|
||||||
@@ -50,7 +50,7 @@ spring:
|
|||||||
time-between-eviction-runs: 50000
|
time-between-eviction-runs: 50000
|
||||||
datasource:
|
datasource:
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
url: jdbc:mysql://192.168.35.71:21306/octopus_server?autoReconnect=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
|
url: jdbc:mysql://10.250.0.100:21306/octopus_server?autoReconnect=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
|
||||||
username: boge
|
username: boge
|
||||||
password: boge8tingH
|
password: boge8tingH
|
||||||
type: com.zaxxer.hikari.HikariDataSource
|
type: com.zaxxer.hikari.HikariDataSource
|
||||||
|
|||||||
@@ -2,14 +2,14 @@ server:
|
|||||||
port: 9999
|
port: 9999
|
||||||
|
|
||||||
# shanghai 42.192.52.227
|
# shanghai 42.192.52.227
|
||||||
# local 42.192.52.227
|
# local 10.250.0.100
|
||||||
# cqga 42.192.52.227
|
# cqga 42.192.52.227
|
||||||
spring:
|
spring:
|
||||||
main:
|
main:
|
||||||
allow-circular-references: true
|
allow-circular-references: true
|
||||||
allow-bean-definition-overriding: true
|
allow-bean-definition-overriding: true
|
||||||
rabbitmq:
|
rabbitmq:
|
||||||
host: 42.192.52.227
|
host: 10.250.0.100
|
||||||
port: 20672
|
port: 20672
|
||||||
username: boge
|
username: boge
|
||||||
password: boge8tingH
|
password: boge8tingH
|
||||||
@@ -24,7 +24,7 @@ spring:
|
|||||||
max-interval: 65000
|
max-interval: 65000
|
||||||
initial-interval: 65000
|
initial-interval: 65000
|
||||||
redis:
|
redis:
|
||||||
host: 42.192.52.227
|
host: 10.250.0.100
|
||||||
port: 21370
|
port: 21370
|
||||||
database: 0
|
database: 0
|
||||||
password: boge8tingH
|
password: boge8tingH
|
||||||
@@ -47,7 +47,7 @@ spring:
|
|||||||
|
|
||||||
datasource:
|
datasource:
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
url: jdbc:mysql://42.192.52.227:21306/octopus_server?autoReconnect=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
|
url: jdbc:mysql://10.250.0.100:21306/octopus_server?autoReconnect=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
|
||||||
username: boge
|
username: boge
|
||||||
password: boge8tingH
|
password: boge8tingH
|
||||||
type: com.zaxxer.hikari.HikariDataSource
|
type: com.zaxxer.hikari.HikariDataSource
|
||||||
|
|||||||
@@ -0,0 +1,75 @@
|
|||||||
|
package io.wdd.server.coreService;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import io.wdd.server.beans.po.ProjectInfoPO;
|
||||||
|
import io.wdd.server.beans.request.ProjectQueryEntity;
|
||||||
|
import io.wdd.server.service.ProjectInfoService;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
@SpringBootTest
|
||||||
|
public class TestCoreProjectService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ObjectMapper objectMapper;
|
||||||
|
@Autowired
|
||||||
|
private ProjectInfoService projectInfoService;
|
||||||
|
@Autowired
|
||||||
|
private CoreProjectService projectService;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testProjectQueryByEntityWithNullEntity() {
|
||||||
|
Page<ProjectInfoPO> result = projectService.projectQueryByEntity(null);
|
||||||
|
assertNull(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testProjectQueryByEntityWithNullProjectNameAndProjectNamespace() {
|
||||||
|
ProjectQueryEntity entity = new ProjectQueryEntity();
|
||||||
|
Page<ProjectInfoPO> result = projectService.projectQueryByEntity(entity);
|
||||||
|
assertNull(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
@Test
|
||||||
|
public void testProjectQueryByEntityWithNullPageNumberAndPageSize() {
|
||||||
|
ProjectQueryEntity entity = new ProjectQueryEntity();
|
||||||
|
// entity.setProjectName("");
|
||||||
|
entity.setProjectNamespace("wdd");
|
||||||
|
Page<ProjectInfoPO> result = projectService.projectQueryByEntity(entity);
|
||||||
|
|
||||||
|
String s = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(result);
|
||||||
|
System.out.println(s);
|
||||||
|
assertNotNull(result);
|
||||||
|
Assertions.assertEquals(1, result.getCurrent());
|
||||||
|
Assertions.assertEquals(10, result.getSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testProjectQueryByEntityWithValidEntity() {
|
||||||
|
ProjectQueryEntity entity = new ProjectQueryEntity();
|
||||||
|
// entity.setProjectName("Test Project");
|
||||||
|
entity.setProjectNamespace("wdd");
|
||||||
|
entity.setPageNumber(2);
|
||||||
|
entity.setPageSize(20);
|
||||||
|
|
||||||
|
Page<ProjectInfoPO> expectedPage = new Page<>(2, 20);
|
||||||
|
when(projectInfoService.getBaseMapper().selectList(any())).thenReturn(new ArrayList<>());
|
||||||
|
|
||||||
|
Page<ProjectInfoPO> result = projectService.projectQueryByEntity(entity);
|
||||||
|
assertNotNull(result);
|
||||||
|
Assertions.assertEquals(expectedPage.getCurrent(), result.getCurrent());
|
||||||
|
Assertions.assertEquals(expectedPage.getSize(), result.getSize());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,7 +11,8 @@ import io.wdd.server.coreService.CoreProjectServerService;
|
|||||||
import io.wdd.server.coreService.CoreProjectService;
|
import io.wdd.server.coreService.CoreProjectService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@@ -27,31 +28,40 @@ public class TestImageSyncScheduler {
|
|||||||
ImageFuncScheduler imageFuncScheduler;
|
ImageFuncScheduler imageFuncScheduler;
|
||||||
|
|
||||||
|
|
||||||
@Resource
|
@Autowired
|
||||||
CoreProjectService coreProjectService;
|
CoreProjectService coreProjectService;
|
||||||
|
|
||||||
@Resource
|
@Autowired
|
||||||
CoreProjectServerService coreProjectServerService;
|
CoreProjectServerService coreProjectServerService;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void runImageSync() {
|
public void runImageSync() {
|
||||||
|
|
||||||
ArrayList<String> CmiiAppNameList = new ArrayList<>(List.of(
|
ArrayList<String> CmiiAppNameList = new ArrayList<>(List.of(
|
||||||
|
// "harbor.cdcyy.com.cn/cmii/cmii-uav-mission:5.3.0-cqly-032802"
|
||||||
));
|
));
|
||||||
|
|
||||||
ArrayList<String> ImageFullNameList = new ArrayList<>(List.of(
|
ArrayList<String> ImageFullNameList = new ArrayList<>(List.of(
|
||||||
|
"harbor.cdcyy.com.cn/cmii/cmii-uav-mission:5.3.0-cqly-032802"
|
||||||
));
|
));
|
||||||
|
|
||||||
String projectNamespace = "xmyd";
|
Boolean downloadAndCompressOnly = true;
|
||||||
|
|
||||||
|
String projectNamespace = "wdd";
|
||||||
|
|
||||||
|
String innerWorkerAgentName = "Chengdu-amd64-65-lapwdd"; //wdd
|
||||||
|
// String innerWorkerAgentName = "Chengdu-amd64-71-3571gd"; //prod
|
||||||
|
|
||||||
|
|
||||||
|
// 之下不要修改 除非你知道自己在干什么!
|
||||||
|
|
||||||
// start
|
// start
|
||||||
ImageSyncContext imageSyncContext = new ImageSyncContext();
|
ImageSyncContext imageSyncContext = new ImageSyncContext();
|
||||||
|
|
||||||
|
imageSyncContext.setDownloadAndCompressOnly(downloadAndCompressOnly);
|
||||||
|
|
||||||
// inner
|
// inner
|
||||||
imageSyncContext.setInnerWorkerAgentName("Chengdu-amd64-71-3571gd");
|
imageSyncContext.setInnerWorkerAgentName(innerWorkerAgentName); // dev
|
||||||
|
|
||||||
ProjectQueryEntity projectQueryEntity = ProjectQueryEntity.builder().projectNamespace(projectNamespace).build();
|
ProjectQueryEntity projectQueryEntity = ProjectQueryEntity.builder().projectNamespace(projectNamespace).build();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user