Merge branch 'master' of https://github.com/metersphere/metersphere
This commit is contained in:
commit
fee6481452
|
@ -13,6 +13,7 @@ public class EngineContext {
|
||||||
private Long threadNum;
|
private Long threadNum;
|
||||||
private Long startTime;
|
private Long startTime;
|
||||||
private String reportId;
|
private String reportId;
|
||||||
|
private Integer resourceIndex;
|
||||||
private Map<String, Object> properties = new HashMap<>();
|
private Map<String, Object> properties = new HashMap<>();
|
||||||
private Map<String, String> testData = new HashMap<>();
|
private Map<String, String> testData = new HashMap<>();
|
||||||
private Map<String, String> env = new HashMap<>();
|
private Map<String, String> env = new HashMap<>();
|
||||||
|
@ -116,4 +117,13 @@ public class EngineContext {
|
||||||
public void setReportId(String reportId) {
|
public void setReportId(String reportId) {
|
||||||
this.reportId = reportId;
|
this.reportId = reportId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Integer getResourceIndex() {
|
||||||
|
return resourceIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResourceIndex(Integer resourceIndex) {
|
||||||
|
this.resourceIndex = resourceIndex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class EngineFactory {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EngineContext createContext(LoadTestWithBLOBs loadTest, String resourceId, long threadNum, long startTime, String reportId) throws Exception {
|
public static EngineContext createContext(LoadTestWithBLOBs loadTest, String resourceId, long threadNum, long startTime, String reportId, int resourceIndex) {
|
||||||
final List<FileMetadata> fileMetadataList = fileService.getFileMetadataByTestId(loadTest.getId());
|
final List<FileMetadata> fileMetadataList = fileService.getFileMetadataByTestId(loadTest.getId());
|
||||||
if (org.springframework.util.CollectionUtils.isEmpty(fileMetadataList)) {
|
if (org.springframework.util.CollectionUtils.isEmpty(fileMetadataList)) {
|
||||||
MSException.throwException(Translator.get("run_load_test_file_not_found") + loadTest.getId());
|
MSException.throwException(Translator.get("run_load_test_file_not_found") + loadTest.getId());
|
||||||
|
@ -76,6 +76,7 @@ public class EngineFactory {
|
||||||
engineContext.setResourcePoolId(loadTest.getTestResourcePoolId());
|
engineContext.setResourcePoolId(loadTest.getTestResourcePoolId());
|
||||||
engineContext.setStartTime(startTime);
|
engineContext.setStartTime(startTime);
|
||||||
engineContext.setReportId(reportId);
|
engineContext.setReportId(reportId);
|
||||||
|
engineContext.setResourceIndex(resourceIndex);
|
||||||
HashMap<String, String> env = new HashMap<String, String>() {{
|
HashMap<String, String> env = new HashMap<String, String>() {{
|
||||||
put("BOOTSTRAP_SERVERS", kafkaProperties.getBootstrapServers());
|
put("BOOTSTRAP_SERVERS", kafkaProperties.getBootstrapServers());
|
||||||
put("LOG_TOPIC", kafkaProperties.getLog().getTopic());
|
put("LOG_TOPIC", kafkaProperties.getLog().getTopic());
|
||||||
|
|
|
@ -14,6 +14,7 @@ import io.metersphere.performance.engine.EngineContext;
|
||||||
import io.metersphere.performance.engine.EngineFactory;
|
import io.metersphere.performance.engine.EngineFactory;
|
||||||
import io.metersphere.performance.engine.docker.request.TestRequest;
|
import io.metersphere.performance.engine.docker.request.TestRequest;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -55,16 +56,16 @@ public class DockerTestEngine extends AbstractEngine {
|
||||||
for (int i = 0, size = resourceList.size(); i < size; i++) {
|
for (int i = 0, size = resourceList.size(); i < size; i++) {
|
||||||
int ratio = resourceRatio.get(i);
|
int ratio = resourceRatio.get(i);
|
||||||
double realThreadNum = ((double) ratio / totalThreadNum) * threadNum;
|
double realThreadNum = ((double) ratio / totalThreadNum) * threadNum;
|
||||||
runTest(resourceList.get(i), Math.round(realThreadNum));
|
runTest(resourceList.get(i), Math.round(realThreadNum), i);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void runTest(TestResource resource, long realThreadNum) {
|
private void runTest(TestResource resource, long realThreadNum, int resourceIndex) {
|
||||||
// todo 运行测试
|
// todo 运行测试
|
||||||
EngineContext context = null;
|
EngineContext context = null;
|
||||||
try {
|
try {
|
||||||
context = EngineFactory.createContext(loadTest, resource.getId(), realThreadNum, this.getStartTime(), this.getReportId());
|
context = EngineFactory.createContext(loadTest, resource.getId(), realThreadNum, this.getStartTime(), this.getReportId(), resourceIndex);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
MSException.throwException(e);
|
MSException.throwException(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -800,6 +800,8 @@ public class JmeterDocumentParser implements DocumentParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processConcurrencyThreadGroup(Element concurrencyThreadGroup) {
|
private void processConcurrencyThreadGroup(Element concurrencyThreadGroup) {
|
||||||
|
String testname = concurrencyThreadGroup.getAttribute("testname");
|
||||||
|
concurrencyThreadGroup.setAttribute("testname", testname + "-" + context.getResourceIndex());
|
||||||
if (concurrencyThreadGroup.getChildNodes().getLength() > 0) {
|
if (concurrencyThreadGroup.getChildNodes().getLength() > 0) {
|
||||||
final NodeList childNodes = concurrencyThreadGroup.getChildNodes();
|
final NodeList childNodes = concurrencyThreadGroup.getChildNodes();
|
||||||
for (int i = 0; i < childNodes.getLength(); i++) {
|
for (int i = 0; i < childNodes.getLength(); i++) {
|
||||||
|
|
Loading…
Reference in New Issue