forked from mtusi2026/mtusi2026lab6
Перенесено дерево lab5 целиком: NestJS-приложение (API + worker,
RabbitMQ, outbox, S3), Dockerfile, compose.yaml, infra/{haproxy,minio,
rabbitmq}, стендовые скрипты, scripts/lab4, scripts/lab5,
evidence/lab4, evidence/lab5 и contracts/extensions.openapi.json.
Задание lab6 оставлено своим: README, REPORT, COURSE, lab.json,
contracts/{openapi,infrastructure,jobs.schema,attachment-states,
examples,observability}, tests, compose.example.yaml, infra/otel,
.github/pull_request_template.md.
Адаптации при переносе:
- docker-проект mtusi-lab5 -> mtusi-lab6 и тег образа
mtusi-messenger:lab6 (compose.yaml, scripts/stop-one.sh, .env.example,
infra/README.md), чтобы тома и контейнеры не пересекались с lab5;
- Makefile: цели lab5 сохранены целиком (skeleton lab6 не отличается
от skeleton lab5);
- .env.example: переменные приложения и стенда lab5 + блок lab6
(OTEL_*) из skeleton.
20 lines
741 B
TypeScript
20 lines
741 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { retryDelayMs } from './backoff.js';
|
|
|
|
describe('retryDelayMs', () => {
|
|
it('uses equal jitter', () => {
|
|
expect(retryDelayMs(1, 1000, 30000, () => 0)).toBe(500);
|
|
expect(retryDelayMs(1, 1000, 30000, () => 1)).toBe(1000);
|
|
expect(retryDelayMs(10, 1000, 30000, () => 1)).toBe(30000);
|
|
});
|
|
|
|
it('never exceeds the cap and grows monotonically at random 0.5', () => {
|
|
const values = Array.from({ length: 6 }, (_, index) =>
|
|
retryDelayMs(index + 1, 1000, 30000, () => 0.5),
|
|
);
|
|
for (const value of values) expect(value).toBeLessThanOrEqual(30000);
|
|
for (let index = 1; index < values.length; index += 1)
|
|
expect(values[index]).toBeGreaterThanOrEqual(values[index - 1]);
|
|
});
|
|
});
|