代码有bug 执行10000次 最后只赛进去1个Process
因为 CloudService cloudService = (CloudService) vertexModel; 这里的cloudService变量会被共享,重复不断被覆盖
vertexModelList.add(cloudService);
public void testAddVertex(int count, VertexModel vertexModel) {
List<VertexModel> vertexModels = new ArrayList<>();
for (int i = 0; i < count; i++) {
mockVertexes(vertexModels, 1710119400000L + i * 1000, vertexModel, SOURCE_ENGINEERING);
}
createGesClient();
this.addVertexes(vertexModels);
}
private List<VertexModel> getVertexModels(int size) {
List<VertexModel> vertexModels = new ArrayList<>();
for (int i = 0; i < size; i++) {
mockVertexes(vertexModels, 1710119400000L + i * 1000, new Process(), SOURCE_ENGINEERING);
}
return vertexModels;
}
private void mockVertexes(List<VertexModel> vertexModelList, long time, VertexModel vertexModel,
String environmentId) {
String uuid = UUID.randomUUID().toString();
String start = uuid.substring(0, uuid.indexOf("-"));
String appName = "ManageOne" + start;
vertexModel.setId(uuid);
vertexModel.setName("MOCommonCompt.MOUniAuthService" + start);
vertexModel.setCreateTime(new Date(time));
vertexModel.setUpdateTime(new Date(time));
vertexModel.setEnvironmentId(environmentId);
switch (vertexModel.getClass().getSimpleName()) {
case "Process":
Process process = new Process();
BeanUtils.copyProperties(vertexModel, process);
process.setDescription("matchedProcess");
process.setAppName(appName);
process.setServiceName("DBS-DRS-Service.DBS-drs-kafka" + start);
process.setCouldServiceRelated(new HashSet<>(Collections.singletonList(appName)));
vertexModelList.add(process);
break;
case "CloudService":
CloudService cloudService = (CloudService) vertexModel;
cloudService.setAppName(appName);
cloudService.setIndexName(appName);
cloudService.setName(appName);
cloudService.setCouldServiceRelated(new HashSet<>(Collections.singletonList(appName)));
cloudService.setVersion(start);
vertexModelList.add(cloudService);
break;
case "CommonService":
int fourDigitNumber = random.nextInt(9000) + 1000;
CommonService commonService = (CommonService) vertexModel;
commonService.setAppName(appName);
commonService.setAppId(uuid);
commonService.setType(appName);
commonService.setServerPorts(new HashSet<>(Collections.singletonList(String.valueOf(fourDigitNumber))));
commonService.setVersion(start);
vertexModelList.add(commonService);
break;
case "CaculateVirtual":
CaculateVirtual virtual = (CaculateVirtual) vertexModel;
virtual.setAzoneId(uuid);
virtual.setRegionId(uuid);
virtual.setIpAddress(start);
virtual.setType(CaculateVirtual.Type.VM);
vertexModelList.add(virtual);
break;
case "VolumeVirtual":
VolumeVirtual volume = (VolumeVirtual) vertexModel;
volume.setType(VolumeVirtual.VolumeType.EVS);
volume.setStatus("in-use");
vertexModelList.add(volume);
break;
default:
System.out.println("传进来不对");
}
}
标签:vertexModel,uuid,appName,process,代码,cloudService,复盘,new,bug
From: https://www.cnblogs.com/yuanbaobao/p/18086798