refactor: K8s 枚举值统一调整

This commit is contained in:
fit2-zhao 2024-10-15 15:16:05 +08:00 committed by Craftsman
parent 7832a10c02
commit 063fe7ab1a
5 changed files with 16 additions and 13 deletions

View File

@ -1,5 +1,8 @@
package io.metersphere.sdk.constants; package io.metersphere.sdk.constants;
import lombok.Getter;
@Getter
public enum ResourcePoolTypeEnum { public enum ResourcePoolTypeEnum {
/** /**
* node controller 资源池 * node controller 资源池
@ -7,7 +10,7 @@ public enum ResourcePoolTypeEnum {
NODE("Node"), NODE("Node"),
K8S("Kubernetes"); K8S("Kubernetes");
private String name; private final String name;
ResourcePoolTypeEnum(String name) { ResourcePoolTypeEnum(String name) {
this.name = name; this.name = name;

View File

@ -227,7 +227,7 @@ public class ApiExecuteService {
} }
// 判断是否为 K8S 资源池 // 判断是否为 K8S 资源池
boolean isK8SResourcePool = StringUtils.equals(testResourcePoolDTO.getType(), ResourcePoolTypeEnum.K8S.name()); boolean isK8SResourcePool = StringUtils.equals(testResourcePoolDTO.getType(), ResourcePoolTypeEnum.K8S.getName());
boolean isDebugMode = ApiExecuteRunMode.isDebug(taskInfo.getRunMode()); boolean isDebugMode = ApiExecuteRunMode.isDebug(taskInfo.getRunMode());
if (isK8SResourcePool) { if (isK8SResourcePool) {
@ -310,7 +310,7 @@ public class ApiExecuteService {
taskInfo.setMsUrl(testResourcePool.getServerUrl()); taskInfo.setMsUrl(testResourcePool.getServerUrl());
} }
// 判断是否为 K8S 资源池 // 判断是否为 K8S 资源池
boolean isK8SResourcePool = StringUtils.equals(testResourcePool.getType(), ResourcePoolTypeEnum.K8S.name()); boolean isK8SResourcePool = StringUtils.equals(testResourcePool.getType(), ResourcePoolTypeEnum.K8S.getName());
if (isK8SResourcePool) { if (isK8SResourcePool) {
TestResourceDTO testResourceDTO = new TestResourceDTO(); TestResourceDTO testResourceDTO = new TestResourceDTO();
BeanUtils.copyBean(testResourceDTO, testResourcePool.getTestResourceReturnDTO()); BeanUtils.copyBean(testResourceDTO, testResourcePool.getTestResourceReturnDTO());

View File

@ -285,7 +285,7 @@ public class ApiTaskCenterService {
reportList.removeAll(request.getExcludeIds()); reportList.removeAll(request.getExcludeIds());
} }
boolean isK8SResourcePool = StringUtils.equals(testResourcePoolDTO.getType(), ResourcePoolTypeEnum.K8S.name()); boolean isK8SResourcePool = StringUtils.equals(testResourcePoolDTO.getType(), ResourcePoolTypeEnum.K8S.getName());
if (isK8SResourcePool) { if (isK8SResourcePool) {
handleK8STask(request, reports, reportList, testResourcePoolDTO); handleK8STask(request, reports, reportList, testResourcePoolDTO);

View File

@ -246,7 +246,7 @@ class TestResourcePoolControllerTests extends BaseTest {
void addTestResourcePoolSeven() throws Exception { void addTestResourcePoolSeven() throws Exception {
//资源池的应用与类型无关 这里资源池正确的顺序就到此为止换个类型只测一遍就行 //资源池的应用与类型无关 这里资源池正确的顺序就到此为止换个类型只测一遍就行
// 不选全部资源池部分有值 资源池节点为NODE use api // 不选全部资源池部分有值 资源池节点为NODE use api
this.addTestResourcePoolSuccess("test_pool_7", false, true, true, false, false, false, ResourcePoolTypeEnum.K8S.name()); this.addTestResourcePoolSuccess("test_pool_7", false, true, true, false, false, false, ResourcePoolTypeEnum.K8S.getName());
} }
@ -299,7 +299,7 @@ class TestResourcePoolControllerTests extends BaseTest {
@Test @Test
@Order(11) @Order(11)
void getResourcePoolsDetailWidthBlobK8s() throws Exception { void getResourcePoolsDetailWidthBlobK8s() throws Exception {
TestResourcePool testResourcePoolRequest1 = this.addTestResourcePoolSuccess("test_pool_blob_k8s", false, true, true, true, true, false, ResourcePoolTypeEnum.K8S.name()); TestResourcePool testResourcePoolRequest1 = this.addTestResourcePoolSuccess("test_pool_blob_k8s", false, true, true, true, true, false, ResourcePoolTypeEnum.K8S.getName());
String id = testResourcePoolRequest1.getId(); String id = testResourcePoolRequest1.getId();
MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.get("/test/resource/pool/detail/" + id) MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.get("/test/resource/pool/detail/" + id)
.header(SessionConstants.HEADER_TOKEN, sessionId) .header(SessionConstants.HEADER_TOKEN, sessionId)
@ -349,7 +349,7 @@ class TestResourcePoolControllerTests extends BaseTest {
@Test @Test
@Order(13) @Order(13)
void getResourcePoolsDetailWidthBlobNoOrgIds() throws Exception { void getResourcePoolsDetailWidthBlobNoOrgIds() throws Exception {
TestResourcePool testResourcePoolRequest1 = this.addTestResourcePoolSuccess("test_pool_blob_no_org_id", true, false, true, false, false, false, ResourcePoolTypeEnum.K8S.name()); TestResourcePool testResourcePoolRequest1 = this.addTestResourcePoolSuccess("test_pool_blob_no_org_id", true, false, true, false, false, false, ResourcePoolTypeEnum.K8S.getName());
String id = testResourcePoolRequest1.getId(); String id = testResourcePoolRequest1.getId();
QueryResourcePoolRequest request = new QueryResourcePoolRequest(); QueryResourcePoolRequest request = new QueryResourcePoolRequest();
request.setCurrent(1); request.setCurrent(1);
@ -375,7 +375,7 @@ class TestResourcePoolControllerTests extends BaseTest {
String id = "1034"; String id = "1034";
getDetail("/test/resource/pool/detail/" + id, ERROR_REQUEST_MATCHER); getDetail("/test/resource/pool/detail/" + id, ERROR_REQUEST_MATCHER);
TestResourcePool testResourcePoolRequest1 = this.addTestResourcePoolSuccess("test_pool_blob_no_node", true, false, true, false, false, true, ResourcePoolTypeEnum.K8S.name()); TestResourcePool testResourcePoolRequest1 = this.addTestResourcePoolSuccess("test_pool_blob_no_node", true, false, true, false, false, true, ResourcePoolTypeEnum.K8S.getName());
getDetail("/test/resource/pool/detail/" + testResourcePoolRequest1.getId(), status().isOk()); getDetail("/test/resource/pool/detail/" + testResourcePoolRequest1.getId(), status().isOk());
} }
@ -397,7 +397,7 @@ class TestResourcePoolControllerTests extends BaseTest {
@Order(15) @Order(15)
void updateTestResourcePool() throws Exception { void updateTestResourcePool() throws Exception {
createMockUrl(); createMockUrl();
TestResourcePool testResourcePoolRequest1 = this.addTestResourcePoolSuccess("test_pool_blob2", false, true, true, false, false, false, ResourcePoolTypeEnum.K8S.name()); TestResourcePool testResourcePoolRequest1 = this.addTestResourcePoolSuccess("test_pool_blob2", false, true, true, false, false, false, ResourcePoolTypeEnum.K8S.getName());
String id = testResourcePoolRequest1.getId(); String id = testResourcePoolRequest1.getId();
TestResourcePoolRequest testResourcePoolRequest = new TestResourcePoolRequest(); TestResourcePoolRequest testResourcePoolRequest = new TestResourcePoolRequest();
testResourcePoolRequest.setId(id); testResourcePoolRequest.setId(id);
@ -422,7 +422,7 @@ class TestResourcePoolControllerTests extends BaseTest {
@Order(16) @Order(16)
void updateTestResourcePoolWithOrgIds() throws Exception { void updateTestResourcePoolWithOrgIds() throws Exception {
createMockUrl(); createMockUrl();
TestResourcePool testResourcePoolRequest1 = this.addTestResourcePoolSuccess("test_pool_blob3", false, true, true, false, false, false, ResourcePoolTypeEnum.K8S.name()); TestResourcePool testResourcePoolRequest1 = this.addTestResourcePoolSuccess("test_pool_blob3", false, true, true, false, false, false, ResourcePoolTypeEnum.K8S.getName());
String id = testResourcePoolRequest1.getId(); String id = testResourcePoolRequest1.getId();
TestResourcePoolRequest testResourcePoolRequest = new TestResourcePoolRequest(); TestResourcePoolRequest testResourcePoolRequest = new TestResourcePoolRequest();
testResourcePoolRequest.setId(id); testResourcePoolRequest.setId(id);
@ -494,7 +494,7 @@ class TestResourcePoolControllerTests extends BaseTest {
testResourcePoolRequest.setId(""); testResourcePoolRequest.setId("");
this.requestPost(urlType, url, id, testResourcePoolRequest, status().isBadRequest()); this.requestPost(urlType, url, id, testResourcePoolRequest, status().isBadRequest());
TestResourcePool testResourcePoolRequest1 = this.addTestResourcePoolSuccess("test_pool_blob2", false, true, true, false, false, false, ResourcePoolTypeEnum.K8S.name()); TestResourcePool testResourcePoolRequest1 = this.addTestResourcePoolSuccess("test_pool_blob2", false, true, true, false, false, false, ResourcePoolTypeEnum.K8S.getName());
id = testResourcePoolRequest1.getId(); id = testResourcePoolRequest1.getId();
} }

View File

@ -337,7 +337,7 @@ public class TestPlanTaskCenterService {
poolIdMap.forEach((poolId, reportList) -> { poolIdMap.forEach((poolId, reportList) -> {
TestResourcePoolReturnDTO testResourcePoolDTO = testResourcePoolService.getTestResourcePoolDetail(poolId); TestResourcePoolReturnDTO testResourcePoolDTO = testResourcePoolService.getTestResourcePoolDetail(poolId);
// 判断是否为 K8S 资源池 // 判断是否为 K8S 资源池
boolean isK8SResourcePool = StringUtils.equals(testResourcePoolDTO.getType(), ResourcePoolTypeEnum.K8S.name()); boolean isK8SResourcePool = StringUtils.equals(testResourcePoolDTO.getType(), ResourcePoolTypeEnum.K8S.getName());
if (isK8SResourcePool) { if (isK8SResourcePool) {
SubListUtils.dealForSubList(reportList, 100, (subList) -> { SubListUtils.dealForSubList(reportList, 100, (subList) -> {
try { try {