启动测试 0.3

This commit is contained in:
Captain.B 2020-03-16 19:19:52 +08:00
parent fbdd747cb7
commit 940631faa3
6 changed files with 12 additions and 4 deletions

View File

@ -7,6 +7,7 @@ import io.metersphere.base.domain.FileMetadata;
import io.metersphere.base.domain.LoadTestWithBLOBs; import io.metersphere.base.domain.LoadTestWithBLOBs;
import io.metersphere.commons.constants.EngineType; import io.metersphere.commons.constants.EngineType;
import io.metersphere.commons.exception.MSException; import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.engine.docker.DockerTestEngine; import io.metersphere.engine.docker.DockerTestEngine;
import io.metersphere.engine.kubernetes.KubernetesTestEngine; import io.metersphere.engine.kubernetes.KubernetesTestEngine;
import io.metersphere.parse.EngineSourceParser; import io.metersphere.parse.EngineSourceParser;
@ -21,9 +22,9 @@ public class EngineFactory {
switch (type) { switch (type) {
case DOCKER: case DOCKER:
return new DockerTestEngine(); return CommonBeanFactory.getBean(DockerTestEngine.class);
case KUBERNETES: case KUBERNETES:
return new KubernetesTestEngine(); return CommonBeanFactory.getBean(KubernetesTestEngine.class);
} }
return null; return null;
} }

View File

@ -2,7 +2,9 @@ package io.metersphere.engine.docker;
import io.metersphere.engine.Engine; import io.metersphere.engine.Engine;
import io.metersphere.engine.EngineContext; import io.metersphere.engine.EngineContext;
import org.springframework.stereotype.Service;
@Service
public class DockerTestEngine implements Engine { public class DockerTestEngine implements Engine {
private EngineContext context; private EngineContext context;

View File

@ -11,9 +11,11 @@ import io.metersphere.engine.kubernetes.crds.jmeter.Jmeter;
import io.metersphere.engine.kubernetes.crds.jmeter.JmeterSpec; import io.metersphere.engine.kubernetes.crds.jmeter.JmeterSpec;
import io.metersphere.engine.kubernetes.provider.ClientCredential; import io.metersphere.engine.kubernetes.provider.ClientCredential;
import io.metersphere.engine.kubernetes.provider.KubernetesProvider; import io.metersphere.engine.kubernetes.provider.KubernetesProvider;
import org.springframework.stereotype.Service;
import java.util.HashMap; import java.util.HashMap;
@Service
public class KubernetesTestEngine implements Engine { public class KubernetesTestEngine implements Engine {
private EngineContext context; private EngineContext context;

View File

@ -1,6 +1,7 @@
package io.metersphere.parse; package io.metersphere.parse;
import io.metersphere.commons.constants.FileType; import io.metersphere.commons.constants.FileType;
import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.parse.xml.XmlEngineSourceParse; import io.metersphere.parse.xml.XmlEngineSourceParse;
public class EngineSourceParserFactory { public class EngineSourceParserFactory {
@ -8,7 +9,7 @@ public class EngineSourceParserFactory {
final FileType engineType = FileType.valueOf(type); final FileType engineType = FileType.valueOf(type);
if (FileType.JMX.equals(engineType)) { if (FileType.JMX.equals(engineType)) {
return new XmlEngineSourceParse(); return CommonBeanFactory.getBean(XmlEngineSourceParse.class);
} }
return null; return null;

View File

@ -4,6 +4,7 @@ import io.metersphere.engine.EngineContext;
import io.metersphere.parse.EngineSourceParser; import io.metersphere.parse.EngineSourceParser;
import io.metersphere.parse.xml.reader.DocumentParser; import io.metersphere.parse.xml.reader.DocumentParser;
import io.metersphere.parse.xml.reader.DocumentParserFactory; import io.metersphere.parse.xml.reader.DocumentParserFactory;
import org.springframework.stereotype.Service;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
@ -11,6 +12,7 @@ import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import java.io.InputStream; import java.io.InputStream;
@Service
public class XmlEngineSourceParse implements EngineSourceParser { public class XmlEngineSourceParse implements EngineSourceParser {
@Override @Override
public String parse(EngineContext context, InputStream source) throws Exception { public String parse(EngineContext context, InputStream source) throws Exception {

View File

@ -161,7 +161,7 @@ public class LoadTestService {
LogUtil.info("Load test started " + loadTest.getName()); LogUtil.info("Load test started " + loadTest.getName());
// engine type (DOCKER|KUBERNETES) // engine type (DOCKER|KUBERNETES)
// todo set type // todo set type
final Engine engine = EngineFactory.createEngine(fileMetadata.getEngine()); Engine engine = EngineFactory.createEngine(fileMetadata.getEngine());
if (engine == null) { if (engine == null) {
MSException.throwException(String.format("Test cannot be runtest ID%sfile type%s", MSException.throwException(String.format("Test cannot be runtest ID%sfile type%s",
request.getId(), request.getId(),