测试:消除监控样本的时区依赖并准确记录零值验收

This commit is contained in:
cieanyau committed 2026-11-07 04:20:45 +08:00
1 parent 1b35d50352
commit 016d223673
1 file changed
+14 -4
+14 -4
View File
@@ -13,7 +13,7 @@ import {
async function instanceBoundary(
page,
{ module = "mf_cloud", value = 50, time = 1793836800 } = {},
{ module = "mf_cloud", value = 50, time } = {},
) {
const state = { value, quotes: [], chartReads: 0 };
const times = [
@@ -21,7 +21,11 @@ async function instanceBoundary(
"2026-11-06 08:00:00",
"2026-11-07 08:00:00",
];
const epoch = time;
// 秒级接口按浏览器本地08:00造样本,与字符串时间接口一致,不依赖执行机时区。
const epoch =
time === undefined
? await page.evaluate(() => new Date(2026, 10, 5, 8).getTime() / 1000)
: time;
await page.context().route(`${backendOrigin}/console/v1/**`, (route) => {
const request = route.request();
const url = new URL(request.url());
@@ -266,7 +270,7 @@ test(
for (const module of ["mf_cloud", "remf_finance", "kky_ecs"]) {
test(
`real zero ${module} measurements remain visible in overview and monitor`,
`real zero ${module} CPU remains visible alongside other metric charts`,
{ timeout: 30000 },
(t) =>
scenario(t, {}, async (page) => {
@@ -290,7 +294,13 @@ for (const module of ["mf_cloud", "remf_finance", "kky_ecs"]) {
page.locator(".mon .chart-viewport").first(),
"0%",
);
return { module, observedZeroRings: 2, observedZeroCharts: 4, tooltip };
return {
module,
observedZeroRings: 2,
renderedMetricCharts: 4,
observedCpuZero: true,
tooltip,
};
}),
);
}