perf(cmpp): instrument inbound flow and unbatch submit worker
This commit is contained in:
@@ -11,7 +11,17 @@ describe('GatewayEventsController protocol logging', () => {
|
||||
const protocolLogs = {
|
||||
record: jest.fn(),
|
||||
};
|
||||
const controller = new GatewayEventsController(sendChain as never, {} as never, protocolLogs as never, { recordEvent: jest.fn() } as never);
|
||||
const metrics = {
|
||||
beginCmppInboundStage: jest.fn().mockReturnValue(1n),
|
||||
finishCmppInboundStage: jest.fn(),
|
||||
};
|
||||
const controller = new GatewayEventsController(
|
||||
sendChain as never,
|
||||
{} as never,
|
||||
protocolLogs as never,
|
||||
{ recordEvent: jest.fn() } as never,
|
||||
metrics as never,
|
||||
);
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
@@ -77,6 +87,20 @@ describe('GatewayEventsController protocol logging', () => {
|
||||
}));
|
||||
});
|
||||
|
||||
it('records a failed inbound total without swallowing the service error', async () => {
|
||||
const failure = new Error('inbound failed');
|
||||
(sendChain as Record<string, jest.Mock>).submitInboundMessage = jest.fn().mockRejectedValue(failure);
|
||||
|
||||
await expect(controller.submitInbound({
|
||||
account: '607532',
|
||||
phoneNumber: '13127620092',
|
||||
content: 'failed',
|
||||
sequenceId: 142,
|
||||
})).rejects.toBe(failure);
|
||||
|
||||
expect(metrics.finishCmppInboundStage).toHaveBeenCalledWith(1n, 'total', 'error');
|
||||
});
|
||||
|
||||
it('accepts only safe outbound Gateway packet events', () => {
|
||||
expect(controller.protocolLog({
|
||||
protocol: 'cmpp',
|
||||
@@ -155,6 +179,7 @@ describe('GatewayEventsController protocol logging', () => {
|
||||
messageId: 'MSG-1',
|
||||
status: 'success',
|
||||
}));
|
||||
expect(metrics.finishCmppInboundStage).toHaveBeenCalledWith(1n, 'total', 'success');
|
||||
});
|
||||
|
||||
it('replaces a fallback receipt identifier with the resolved main message identifier', async () => {
|
||||
|
||||
Reference in New Issue
Block a user