seata测试
This commit is contained in:
1 parent
991e555606
commit
deefac848b
3 files changed
+109
-5
No files matched your search
@@ -0,0 +1,17 @@
|
|||||||
|
import request from '/@/utils/request'
|
||||||
|
|
||||||
|
/** Seata 提交探测 */
|
||||||
|
export function seataProbeCommit() {
|
||||||
|
return request({
|
||||||
|
url: '/admin/seataProbe/commit',
|
||||||
|
method: 'post',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Seata 回滚探测 */
|
||||||
|
export function seataProbeRollback() {
|
||||||
|
return request({
|
||||||
|
url: '/admin/seataProbe/rollback',
|
||||||
|
method: 'post',
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
<template>
|
||||||
|
<div class="layout-padding">
|
||||||
|
<div class="layout-padding-auto layout-padding-view">
|
||||||
|
<el-alert
|
||||||
|
title="用于验证 Seata Server(如升级到 2.1)后全局事务是否正常。请先在业务库执行 db/seata_tx_probe.sql。"
|
||||||
|
type="info"
|
||||||
|
:closable="false"
|
||||||
|
show-icon
|
||||||
|
class="mb8"
|
||||||
|
/>
|
||||||
|
<div class="mb8">
|
||||||
|
<el-button type="primary" :loading="commitLoading" @click="runCommit" v-auth="'admin_seata_probe'">
|
||||||
|
测试提交(应落库)
|
||||||
|
</el-button>
|
||||||
|
<el-button type="warning" :loading="rollbackLoading" @click="runRollback" v-auth="'admin_seata_probe'">
|
||||||
|
测试回滚(应不落库)
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
<el-descriptions v-if="lastResult" title="最近一次结果" :column="1" border>
|
||||||
|
<el-descriptions-item label="是否通过">
|
||||||
|
<el-tag :type="lastResult.pass ? 'success' : 'danger'">{{ lastResult.pass ? '通过' : '未通过' }}</el-tag>
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="说明">{{ lastResult.message }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="类型">{{ lastResult.caseType }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="mark">{{ lastResult.mark }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="xid">{{ lastResult.xid || '-' }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="库中行数">{{ lastResult.rowCount }}</el-descriptions-item>
|
||||||
|
</el-descriptions>
|
||||||
|
<div v-else style="color: #909399">点击上方按钮开始测试</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts" name="adminSeataProbe">
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import { useMessage } from '/@/hooks/message'
|
||||||
|
import { seataProbeCommit, seataProbeRollback } from '/@/api/admin/seataProbe'
|
||||||
|
|
||||||
|
const commitLoading = ref(false)
|
||||||
|
const rollbackLoading = ref(false)
|
||||||
|
const lastResult = ref<any>(null)
|
||||||
|
|
||||||
|
const pickBody = (res: any) => {
|
||||||
|
if (res?.data && typeof res.data === 'object' && ('pass' in res.data || 'mark' in res.data)) {
|
||||||
|
return res.data
|
||||||
|
}
|
||||||
|
return res?.data ?? res
|
||||||
|
}
|
||||||
|
|
||||||
|
const runCommit = async () => {
|
||||||
|
commitLoading.value = true
|
||||||
|
try {
|
||||||
|
const res: any = await seataProbeCommit()
|
||||||
|
const body = pickBody(res)
|
||||||
|
lastResult.value = body
|
||||||
|
if (res?.code === 0 && body?.pass) {
|
||||||
|
useMessage().success(body.message || '提交探测通过')
|
||||||
|
} else {
|
||||||
|
useMessage().error(res?.msg || body?.message || '提交探测失败')
|
||||||
|
}
|
||||||
|
} catch (e: any) {
|
||||||
|
useMessage().error(e?.msg || e?.message || '请求失败')
|
||||||
|
} finally {
|
||||||
|
commitLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const runRollback = async () => {
|
||||||
|
rollbackLoading.value = true
|
||||||
|
try {
|
||||||
|
const res: any = await seataProbeRollback()
|
||||||
|
const body = pickBody(res)
|
||||||
|
lastResult.value = body
|
||||||
|
if (res?.code === 0 && body?.pass) {
|
||||||
|
useMessage().success(body.message || '回滚探测通过')
|
||||||
|
} else {
|
||||||
|
useMessage().error(res?.msg || body?.message || '回滚探测失败')
|
||||||
|
}
|
||||||
|
} catch (e: any) {
|
||||||
|
useMessage().error(e?.msg || e?.message || '请求失败')
|
||||||
|
} finally {
|
||||||
|
rollbackLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
+7
-5
@@ -22,11 +22,13 @@
|
|||||||
@sort-change="sortChangeHandle">
|
@sort-change="sortChangeHandle">
|
||||||
<el-table-column type="selection" width="40" align="center" />
|
<el-table-column type="selection" width="40" align="center" />
|
||||||
<el-table-column type="index" label="#" width="40" />
|
<el-table-column type="index" label="#" width="40" />
|
||||||
<el-table-column prop="apiName" label="接口名称" show-overflow-tooltip/>
|
<el-table-column prop="createTime" label="时间" width="170" show-overflow-tooltip/>
|
||||||
<el-table-column prop="requestParameter" label="请求参数" show-overflow-tooltip/>
|
<el-table-column prop="apiName" label="接口名称" min-width="180" show-overflow-tooltip/>
|
||||||
<el-table-column prop="requestUrl" label="请求路径" show-overflow-tooltip/>
|
<el-table-column prop="requestParameter" label="请求参数" min-width="160" show-overflow-tooltip/>
|
||||||
<el-table-column prop="httpStatus" label="状态码" show-overflow-tooltip/>
|
<el-table-column prop="requestUrl" label="请求路径" min-width="140" show-overflow-tooltip/>
|
||||||
<el-table-column prop="errorCode" label="错误码(如-1)" show-overflow-tooltip/>
|
<el-table-column prop="httpStatus" label="状态" width="80" show-overflow-tooltip/>
|
||||||
|
<el-table-column prop="errorCode" label="错误码" width="100" show-overflow-tooltip/>
|
||||||
|
<el-table-column prop="errorMsg" label="错误描述" min-width="120" show-overflow-tooltip/>
|
||||||
<el-table-column label="操作" width="150">
|
<el-table-column label="操作" width="150">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button icon="edit-pen" text type="primary" v-auth="'thirdparty_thirdPartyLog_edit'"
|
<el-button icon="edit-pen" text type="primary" v-auth="'thirdparty_thirdPartyLog_edit'"
|
||||||
|
|||||||
Reference in new issue
Block a user