jmeter image properties

This commit is contained in:
Captain.B 2020-04-02 14:06:40 +08:00
parent 933be35362
commit 1f67ebd2e0
5 changed files with 31 additions and 9 deletions

View File

@ -1,5 +1,6 @@
package io.metersphere;
import io.metersphere.config.JmeterProperties;
import io.metersphere.config.KafkaProperties;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@ -9,11 +10,12 @@ import org.springframework.boot.web.servlet.ServletComponentScan;
@SpringBootApplication(exclude = {QuartzAutoConfiguration.class})
@ServletComponentScan
@EnableConfigurationProperties(KafkaProperties.class)
@EnableConfigurationProperties({
KafkaProperties.class,
JmeterProperties.class
})
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}

View File

@ -0,0 +1,20 @@
package io.metersphere.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties(prefix = JmeterProperties.JMETER_PREFIX)
public class JmeterProperties {
public static final String JMETER_PREFIX = "jmeter";
private String image = "registry.fit2cloud.com/metersphere/jmeter-master:0.0.3";
public String getImage() {
return image;
}
public void setImage(String image) {
this.image = image;
}
}

View File

@ -10,6 +10,7 @@ import io.metersphere.commons.constants.ResourcePoolTypeEnum;
import io.metersphere.commons.constants.TestStatus;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.config.JmeterProperties;
import io.metersphere.service.LoadTestService;
import io.metersphere.service.TestResourcePoolService;
import io.metersphere.service.TestResourceService;
@ -20,9 +21,7 @@ import java.util.List;
import java.util.UUID;
public abstract class AbstractEngine implements Engine {
public static final String REGISTRY = "registry.fit2cloud.com/metersphere/";
public static final String JMETER_IMAGE = "jmeter-master:0.0.3";
protected String JMETER_IMAGE;
private Long startTime;
private String reportId;
protected LoadTestWithBLOBs loadTest;
@ -36,6 +35,7 @@ public abstract class AbstractEngine implements Engine {
public AbstractEngine() {
testResourcePoolService = CommonBeanFactory.getBean(TestResourcePoolService.class);
testResourceService = CommonBeanFactory.getBean(TestResourceService.class);
JMETER_IMAGE = CommonBeanFactory.getBean(JmeterProperties.class).getImage();
this.startTime = System.currentTimeMillis();
this.reportId = UUID.randomUUID().toString();
}

View File

@ -80,7 +80,7 @@ public class DockerTestEngine extends AbstractEngine {
testRequest.setSize(1);
testRequest.setTestId(testId);
testRequest.setFileString(content);
testRequest.setImage(REGISTRY + JMETER_IMAGE);
testRequest.setImage(JMETER_IMAGE);
testRequest.setTestData(context.getTestData());
// todo 判断测试状态

View File

@ -87,7 +87,7 @@ public class KubernetesTestEngine extends AbstractEngine {
}});
jmeter.setSpec(new JmeterSpec() {{
setReplicas(1);
setImage(REGISTRY + JMETER_IMAGE);
setImage(JMETER_IMAGE);
}});
LogUtil.info("Load test started. " + context.getTestId());
kubernetesProvider.applyCustomResource(jmeter);
@ -111,7 +111,7 @@ public class KubernetesTestEngine extends AbstractEngine {
}});
jmeter.setSpec(new JmeterSpec() {{
setReplicas(1);
setImage(REGISTRY + JMETER_IMAGE);
setImage(JMETER_IMAGE);
}});
provider.deleteCustomResource(jmeter);
} catch (Exception e) {