refactor: 资源池执行接口测试修改
This commit is contained in:
parent
d1b4107b32
commit
d20957dbb1
|
@ -6,7 +6,6 @@ import io.metersphere.base.domain.UserHeader;
|
||||||
import io.metersphere.commons.constants.OperLogConstants;
|
import io.metersphere.commons.constants.OperLogConstants;
|
||||||
import io.metersphere.commons.constants.OperLogModule;
|
import io.metersphere.commons.constants.OperLogModule;
|
||||||
import io.metersphere.commons.constants.ParamConstants;
|
import io.metersphere.commons.constants.ParamConstants;
|
||||||
import io.metersphere.config.KafkaProperties;
|
|
||||||
import io.metersphere.controller.request.HeaderRequest;
|
import io.metersphere.controller.request.HeaderRequest;
|
||||||
import io.metersphere.dto.BaseSystemConfigDTO;
|
import io.metersphere.dto.BaseSystemConfigDTO;
|
||||||
import io.metersphere.dto.SystemStatisticData;
|
import io.metersphere.dto.SystemStatisticData;
|
||||||
|
@ -37,8 +36,6 @@ public class SystemParameterController {
|
||||||
private WorkspaceService workspaceService;
|
private WorkspaceService workspaceService;
|
||||||
@Resource
|
@Resource
|
||||||
private ProjectService projectService;
|
private ProjectService projectService;
|
||||||
@Resource
|
|
||||||
private KafkaProperties kafkaProperties;
|
|
||||||
|
|
||||||
@PostMapping("/edit/email")
|
@PostMapping("/edit/email")
|
||||||
@MsAuditLog(module = OperLogModule.SYSTEM_PARAMETER_SETTING, type = OperLogConstants.UPDATE, title = "邮件设置", beforeEvent = "#msClass.getMailLogDetails()", content = "#msClass.getMailLogDetails()", msClass = SystemParameterService.class)
|
@MsAuditLog(module = OperLogModule.SYSTEM_PARAMETER_SETTING, type = OperLogConstants.UPDATE, title = "邮件设置", beforeEvent = "#msClass.getMailLogDetails()", content = "#msClass.getMailLogDetails()", msClass = SystemParameterService.class)
|
||||||
|
@ -56,11 +53,6 @@ public class SystemParameterController {
|
||||||
return systemParameterService.getVersion();
|
return systemParameterService.getVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/kafka-servers")
|
|
||||||
public String getKafkaBootstrapServers() {
|
|
||||||
return kafkaProperties.getBootstrapServers();
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/theme")
|
@GetMapping("/theme")
|
||||||
public String getTheme() {
|
public String getTheme() {
|
||||||
return systemParameterService.getValue("ui.theme");
|
return systemParameterService.getValue("ui.theme");
|
||||||
|
|
|
@ -87,21 +87,7 @@
|
||||||
<el-input v-model="form.gcAlgo"
|
<el-input v-model="form.gcAlgo"
|
||||||
placeholder="-XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20"/>
|
placeholder="-XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item prop="type">
|
<el-form-item prop="type" :label="$t('test_resource_pool.type')">
|
||||||
<template v-slot:label>
|
|
||||||
{{ $t('test_resource_pool.type') }}
|
|
||||||
<el-popover
|
|
||||||
v-if="form.type === 'K8S'"
|
|
||||||
placement="bottom"
|
|
||||||
width="450"
|
|
||||||
:title="$t('test_resource_pool.k8s_sa_tips')"
|
|
||||||
trigger="hover">
|
|
||||||
<el-link type="primary" @click="downloadYaml({deployType:'sa', deployName:'sa'})">
|
|
||||||
{{ $t('test_resource_pool.k8s_sa_download_tips') }}
|
|
||||||
</el-link>
|
|
||||||
<i class="el-icon-info" slot="reference"></i>
|
|
||||||
</el-popover>
|
|
||||||
</template>
|
|
||||||
<el-select v-model="form.type" :placeholder="$t('test_resource_pool.select_pool_type')"
|
<el-select v-model="form.type" :placeholder="$t('test_resource_pool.select_pool_type')"
|
||||||
@change="changeResourceType(form.type)">
|
@change="changeResourceType(form.type)">
|
||||||
<el-option key="NODE" value="NODE" label="Node">Node</el-option>
|
<el-option key="NODE" value="NODE" label="Node">Node</el-option>
|
||||||
|
@ -127,28 +113,29 @@
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="12">
|
<el-col>
|
||||||
<el-form-item label="Namespace" :rules="requiredRules">
|
<el-form-item label="Namespace" :rules="requiredRules">
|
||||||
<el-input v-model="item.namespace" type="text"/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="12">
|
|
||||||
<el-form-item>
|
|
||||||
<template v-slot:label>
|
<template v-slot:label>
|
||||||
Deploy Type
|
Namespace
|
||||||
<el-popover
|
<el-popover
|
||||||
placement="bottom"
|
placement="bottom"
|
||||||
width="450"
|
width="450"
|
||||||
:title="$t('test_resource_pool.k8s_deploy_type_tips')"
|
|
||||||
trigger="hover">
|
trigger="hover">
|
||||||
<el-link type="primary" @click="downloadYaml(item)">{{ $t('test_resource_pool.k8s_deploy_download_tips') }}</el-link>
|
<div>
|
||||||
|
<strong>{{ $t('test_resource_pool.k8s_sa_tips') }}</strong><br>
|
||||||
|
<el-link type="primary" @click="downloadYaml(item, 'sa')">sa.yaml</el-link>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="padding-top: 20px">
|
||||||
|
<strong>{{ $t('test_resource_pool.k8s_deploy_type_tips') }}</strong><br>
|
||||||
|
<el-link type="primary" @click="downloadYaml(item, 'DaemonSet')">daemonset.yaml</el-link>
|
||||||
|
|
||||||
|
<el-link type="primary" @click="downloadYaml(item, 'Deployment')">deployment.yaml</el-link>
|
||||||
|
</div>
|
||||||
<i class="el-icon-info" slot="reference"></i>
|
<i class="el-icon-info" slot="reference"></i>
|
||||||
</el-popover>
|
</el-popover>
|
||||||
</template>
|
</template>
|
||||||
<el-select v-model="item.deployType" style="width: 100%">
|
<el-input v-model="item.namespace" type="text"/>
|
||||||
<el-option key="DaemonSet" value="DaemonSet" label="DaemonSet"/>
|
|
||||||
<el-option key="Deployment" value="Deployment" label="Deployment"/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
@ -323,14 +310,12 @@ export default {
|
||||||
haveTestUsePool: false
|
haveTestUsePool: false
|
||||||
},
|
},
|
||||||
apiImage: '',
|
apiImage: '',
|
||||||
kafkaBootstrapServers: '',
|
|
||||||
apiImageTag: '',
|
apiImageTag: '',
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
activated() {
|
activated() {
|
||||||
this.initTableData();
|
this.initTableData();
|
||||||
this.getApiImageTag();
|
this.getApiImageTag();
|
||||||
this.getKafkaBootstrapServers();
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
initTableData() {
|
initTableData() {
|
||||||
|
@ -583,7 +568,7 @@ export default {
|
||||||
this.result.loading = false;
|
this.result.loading = false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
downloadYaml(item) {
|
downloadYaml(item, deployType) {
|
||||||
if (!item.namespace) {
|
if (!item.namespace) {
|
||||||
this.$error(this.$t('test_resource_pool.fill_the_data'));
|
this.$error(this.$t('test_resource_pool.fill_the_data'));
|
||||||
return;
|
return;
|
||||||
|
@ -596,20 +581,15 @@ export default {
|
||||||
if (item.apiImage) {
|
if (item.apiImage) {
|
||||||
apiImage = item.apiImage;
|
apiImage = item.apiImage;
|
||||||
}
|
}
|
||||||
let yaml = getYaml(item.deployType, item.deployName, item.namespace, apiImage, this.kafkaBootstrapServers);
|
let yaml = getYaml(deployType, item.deployName, item.namespace, apiImage);
|
||||||
let blob = new Blob([yaml], {type: 'application/yaml'});
|
let blob = new Blob([yaml], {type: 'application/yaml'});
|
||||||
let url = URL.createObjectURL(blob);
|
let url = URL.createObjectURL(blob);
|
||||||
let downloadAnchorNode = document.createElement('a')
|
let downloadAnchorNode = document.createElement('a')
|
||||||
downloadAnchorNode.setAttribute("href", url);
|
downloadAnchorNode.setAttribute("href", url);
|
||||||
downloadAnchorNode.setAttribute("download", item.deployType.toLowerCase() + ".yaml")
|
downloadAnchorNode.setAttribute("download", deployType.toLowerCase() + ".yaml")
|
||||||
downloadAnchorNode.click();
|
downloadAnchorNode.click();
|
||||||
downloadAnchorNode.remove();
|
downloadAnchorNode.remove();
|
||||||
},
|
},
|
||||||
getKafkaBootstrapServers() {
|
|
||||||
this.$get('/system/kafka-servers', response => {
|
|
||||||
this.kafkaBootstrapServers = response.data;
|
|
||||||
})
|
|
||||||
},
|
|
||||||
getApiImageTag() {
|
getApiImageTag() {
|
||||||
this.$get('/system/version', response => {
|
this.$get('/system/version', response => {
|
||||||
if (!response.data) {
|
if (!response.data) {
|
||||||
|
|
|
@ -28,8 +28,6 @@ spec:
|
||||||
weight: 100
|
weight: 100
|
||||||
containers:
|
containers:
|
||||||
- env:
|
- env:
|
||||||
- name: KAFKA_BOOTSTRAP-SERVERS
|
|
||||||
value: {kafkaBootstrapServers}
|
|
||||||
image: {image}
|
image: {image}
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
name: ms-node-controller
|
name: ms-node-controller
|
||||||
|
@ -77,8 +75,6 @@ spec:
|
||||||
weight: 100
|
weight: 100
|
||||||
containers:
|
containers:
|
||||||
- env:
|
- env:
|
||||||
- name: KAFKA_BOOTSTRAP-SERVERS
|
|
||||||
value: {kafkaBootstrapServers}
|
|
||||||
image: {image}
|
image: {image}
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
name: ms-node-controller
|
name: ms-node-controller
|
||||||
|
@ -155,20 +151,18 @@ rules:
|
||||||
- delete
|
- delete
|
||||||
`
|
`
|
||||||
|
|
||||||
export function getYaml(type, name, namespace, image, kafkaBootstrapServers) {
|
export function getYaml(type, name, namespace, image) {
|
||||||
if (type === 'Deployment') {
|
if (type === 'Deployment') {
|
||||||
return deployment
|
return deployment
|
||||||
.replace('{name}', name)
|
.replace('{name}', name)
|
||||||
.replace('{namespace}', namespace)
|
.replace('{namespace}', namespace)
|
||||||
.replace('{image}', image)
|
.replace('{image}', image);
|
||||||
.replace('{kafkaBootstrapServers}', kafkaBootstrapServers);
|
|
||||||
}
|
}
|
||||||
if (type === 'DaemonSet') {
|
if (type === 'DaemonSet') {
|
||||||
return daemonSet
|
return daemonSet
|
||||||
.replace('{name}', name)
|
.replace('{name}', name)
|
||||||
.replace('{namespace}', namespace)
|
.replace('{namespace}', namespace)
|
||||||
.replace('{image}', image)
|
.replace('{image}', image);
|
||||||
.replace('{kafkaBootstrapServers}', kafkaBootstrapServers);
|
|
||||||
}
|
}
|
||||||
if (type === 'sa') {
|
if (type === 'sa') {
|
||||||
return sa.replace('{namespace}', namespace);
|
return sa.replace('{namespace}', namespace);
|
||||||
|
|
Loading…
Reference in New Issue