fix: fix tencentCloudAlarmMetricSchema incorrect problem
This commit is contained in:
parent
f1aaa7040e
commit
914046aefa
59
src/server/model/_schema/__tests__/feed.spec.ts
Normal file
59
src/server/model/_schema/__tests__/feed.spec.ts
Normal file
@ -0,0 +1,59 @@
|
||||
import { describe, expect, test } from 'vitest';
|
||||
import {
|
||||
tencentCloudAlarmMetricSchema,
|
||||
tencentCloudAlarmSchema,
|
||||
} from '../feed.js';
|
||||
|
||||
describe('tencentCloudAlarmSchema', () => {
|
||||
test('should be pass in ', () => {
|
||||
const data = {
|
||||
sessionId: '395d4bb4-08bf-45fd-a820-ef27047a00009',
|
||||
alarmStatus: '1',
|
||||
alarmType: 'metric',
|
||||
alarmObjInfo: {
|
||||
region: 'sh',
|
||||
namespace: 'qce/lb',
|
||||
appId: '1257200005',
|
||||
uin: '10000670009',
|
||||
dimensions: {
|
||||
deviceName: 'Tailchat',
|
||||
objId: '953a6ec8-f9ff-4c6f-96f6-37c2005dddfb',
|
||||
objName: '172.17.32.0#41119',
|
||||
unInstanceId: 'ins-n0y0008z',
|
||||
},
|
||||
},
|
||||
alarmPolicyInfo: {
|
||||
policyId: 'policy-b900061',
|
||||
policyType: 'cvm_device',
|
||||
policyName: 'xxxxx',
|
||||
policyTypeCName: 'xxxxx-xxxxxx',
|
||||
policyTypeEname: '',
|
||||
conditions: {
|
||||
metricName: 'outratio',
|
||||
metricShowName: 'xxxxxxxxxxxxx',
|
||||
calcType: '>',
|
||||
calcValue: '95',
|
||||
currentValue: '95.255',
|
||||
historyValue: '',
|
||||
unit: '%',
|
||||
calcUnit: '%',
|
||||
period: '300',
|
||||
periodNum: '5',
|
||||
alarmNotifyType: 'continuousAlarm',
|
||||
alarmNotifyPeriod: 86400,
|
||||
},
|
||||
tag: [],
|
||||
policyTags: [],
|
||||
},
|
||||
firstOccurTime: '2024-08-07 07:55:00',
|
||||
durationTime: 0,
|
||||
recoverTime: '0',
|
||||
policyDetailURL: 'https://tcop.qq.com/r/xxxxxx',
|
||||
};
|
||||
|
||||
const res = tencentCloudAlarmSchema.safeParse(data);
|
||||
|
||||
expect(res.success).toBe(true);
|
||||
expect((res as any).data).toEqual(data);
|
||||
});
|
||||
});
|
@ -27,11 +27,11 @@ const tencentCloudAlarmEventSchema = z.object({
|
||||
});
|
||||
|
||||
// 定义 metric 类型
|
||||
const tencentCloudAlarmMetricSchema = z.object({
|
||||
export const tencentCloudAlarmMetricSchema = z.object({
|
||||
sessionId: z.string(),
|
||||
alarmStatus: z.union([z.literal('0'), z.literal('1')]),
|
||||
alarmType: z.literal('metric'),
|
||||
alarmLevel: z.string(),
|
||||
alarmLevel: z.string().optional(),
|
||||
alarmObjInfo: z.object({
|
||||
region: z.string().optional(),
|
||||
namespace: z.string(),
|
||||
|
Loading…
Reference in New Issue
Block a user