提交 65893268 编写于 作者: C Captain.B

查询资源池

上级 fdb6d690
......@@ -9,6 +9,7 @@ public class EngineContext {
private String namespace;
private String fileType;
private String content;
private String resourcePoolId;
private Map<String, Object> properties = new HashMap<>();
private Map<String, String> testData = new HashMap<>();
......@@ -67,4 +68,12 @@ public class EngineContext {
public void setTestData(Map<String, String> testData) {
this.testData = testData;
}
public String getResourcePoolId() {
return resourcePoolId;
}
public void setResourcePoolId(String resourcePoolId) {
this.resourcePoolId = resourcePoolId;
}
}
......@@ -79,6 +79,9 @@ public class EngineFactory {
for (int i = 0; i < jsonArray.size(); i++) {
final JSONObject jsonObject = jsonArray.getJSONObject(i);
engineContext.addProperty(jsonObject.getString("key"), jsonObject.get("value"));
if (StringUtils.equals(jsonObject.getString("key"), "resourcePoolId")) {
engineContext.setResourcePoolId(jsonObject.getString("value"));
}
}
}
......
......@@ -4,6 +4,9 @@ import com.alibaba.fastjson.JSON;
import io.fabric8.kubernetes.api.model.ConfigMap;
import io.fabric8.kubernetes.api.model.ObjectMeta;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.metersphere.base.domain.TestResource;
import io.metersphere.base.domain.TestResourcePool;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.engine.Engine;
......@@ -13,19 +16,23 @@ import io.metersphere.engine.kubernetes.crds.jmeter.JmeterSpec;
import io.metersphere.engine.kubernetes.provider.ClientCredential;
import io.metersphere.engine.kubernetes.provider.KubernetesProvider;
import io.metersphere.service.TestResourcePoolService;
import io.metersphere.service.TestResourceService;
import org.apache.commons.collections.MapUtils;
import java.util.HashMap;
import java.util.List;
public class KubernetesTestEngine implements Engine {
private EngineContext context;
private TestResourcePoolService testResourcePoolService;
private TestResourceService testResourceService;
@Override
public boolean init(EngineContext context) {
// todo 初始化操作
this.context = context;
this.testResourcePoolService = CommonBeanFactory.getBean(TestResourcePoolService.class);
this.testResourceService = CommonBeanFactory.getBean(TestResourceService.class);
return true;
}
......@@ -36,6 +43,11 @@ public class KubernetesTestEngine implements Engine {
LogUtil.warn("Please initial the engine.");
return;
}
TestResourcePool resourcePool = testResourcePoolService.getResourcePool(context.getResourcePoolId());
if (resourcePool == null) {
MSException.throwException("Resource Pool is empty");
}
List<TestResource> resourceList = testResourceService.getResourcesByPoolId(resourcePool.getId());
// todo 运行测试
ClientCredential credential = new ClientCredential();
credential.setMasterUrl("https://172.16.10.93:6443");
......
......@@ -41,4 +41,10 @@ public class TestResourceService {
testResource.setUpdateTime(System.currentTimeMillis());
testResourceMapper.updateByPrimaryKeySelective(testResource);
}
public List<TestResource> getResourcesByPoolId(String resourcePoolId) {
TestResourceExample example = new TestResourceExample();
example.createCriteria().andTestResourcePoolIdEqualTo(resourcePoolId);
return testResourceMapper.selectByExampleWithBLOBs(example);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册