Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docker-compose.ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ services:
environment:
DOCDB_USER: hyperdx
DOCDB_PASSWORD: hyperdx
DOCDB_DISABLE_TTL: 'true'
ports:
- '127.0.0.1:${HDX_CI_MONGO_PORT:-39999}:10260'
networks:
Expand Down
7 changes: 7 additions & 0 deletions docker/documentdb/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ else
start_postgres
fi

# Integration tests write documents with timestamps far in the past, so the
# once-a-minute TTL purge can delete them mid-test.
if [ "${DOCDB_DISABLE_TTL:-false}" = true ]; then
psql -h /tmp -U postgres -d postgres -qtAX -v ON_ERROR_STOP=1 \
-c "SELECT cron.unschedule(jobid) FROM cron.job WHERE jobname = 'documentdb_ttl_task';" >/dev/null
fi

echo "postgresql://postgres@localhost:5432/postgres" > /tmp/pg-url
mkdir -p /tmp/tls
export DOCUMENTDB_PG_URL_FILE=/tmp/pg-url DOCUMENTDB_TLS_STATE_DIR=/tmp/tls
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2022,8 +2022,11 @@ describe('checkAlerts', () => {
getMetadata: jest.fn().mockReturnValue(mockMetadata),
}));

// clearAllMocks keeps implementations, so reset to stop one test's
// mockRejectedValue leaking into the next.
jest
.spyOn(slack, 'postMessageToWebhook')
.mockReset()
.mockResolvedValueOnce(fromAny(null));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 P2 — After mockReset(), calls past the first one go to the real Slack webhook

Use .mockReset().mockResolvedValue(fromAny(null)) so every call in a test gets a default stub, not just the first. Why: the repo uses Jest 30 (packages/api/package.json), where mockReset() on a spyOn puts back the original function. The beforeEach then stubs only one call with mockResolvedValueOnce, so any later call runs the real postMessageToWebhook (packages/api/src/utils/slack.ts:13). That sends a real IncomingWebhook.send to https://hooks.slack.com/services/123. Before this PR, those calls were usually caught by a stub some earlier test had left behind with mockResolvedValue (e.g. lines 3081 and 8096). Now they reliably make real network calls. Example: the group-by skip test at ~7257/7278 expects 4 Slack calls and stubs none itself. Its calls 2–4 now reach the network, which makes the suite slower and dependent on the network — the kind of flakiness this PR is meant to remove.

Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond


jest.spyOn(checkAlert, 'handleSendGenericWebhook');
Expand Down
Loading