Skip to content

feat: enhance e2e API tests with DB verification and new endpoints#1899

Merged
akshaydeo merged 2 commits intomainfrom
03-03-feat_added_timeout_for_api_tests
Mar 12, 2026
Merged

feat: enhance e2e API tests with DB verification and new endpoints#1899
akshaydeo merged 2 commits intomainfrom
03-03-feat_added_timeout_for_api_tests

Conversation

@Radheshg04
Copy link
Copy Markdown
Contributor

@Radheshg04 Radheshg04 commented Mar 3, 2026

Changes

This pull request enhances the e2e API test infrastructure with comprehensive database verification capabilities and improved test reliability.

Database Verification Reporter

  • Added newman-reporter-dbverify custom Newman reporter that verifies CRUD operations against PostgreSQL and SQLite databases
  • Supports auto-detection of database connections from Bifrost config.json or explicit connection strings
  • Verifies that API responses correctly reflect database state for all major endpoints (customers, teams, virtual keys, routing rules, model configs, providers, plugins, MCP clients)
  • Handles both main config database and logs database verification with separate connection management

Test Infrastructure Improvements

  • Reduced --timeout-script from 300000ms to 120000ms and added --timeout of 900000ms across all Newman test scripts for better timeout handling
  • Added automatic MCP HTTP server setup on port 3001 for testing MCP client endpoints
  • Enhanced plugin build process with absolute path resolution for reliable plugin testing
  • Added comprehensive package.json with required dependencies (pg, better-sqlite3)

Postman Collection Updates

  • Refined error handling to focus on 4xx client errors rather than all 400+ status codes
  • Added new log histogram endpoints for tokens, cost, models, latency with provider-specific variants
  • Expanded routing rules and model configs test coverage with full CRUD operations
  • Updated provider test data to use custom provider configuration with OpenAI base type
  • Added enable_logging configuration option and Reconnect MCP Client endpoint
  • Removed complex MCP server error handling in favor of simpler client-not-found scenarios
  • Enhanced governance provider endpoints with update and delete operations

Configuration and Error Handling

  • Updated test assertion message from "Status is 2xx or expected error" to "Status is 2xx or expected 4xx"
  • Added support for routing rules and model configs in "Before Create" scenarios
  • Simplified plugin error handling to focus on 404 responses rather than mixed 404/500 scenarios
  • Removed governance/logging plugin 405 error handling as these endpoints are now consistently available

The changes significantly improve test reliability and provide comprehensive database verification to ensure API operations correctly persist to the database layer.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 3, 2026

📝 Walkthrough

Walkthrough

Multiple Newman test runner scripts update timeout configurations (shorter per-script, longer overall). A comprehensive database verification reporter module is introduced with supporting infrastructure. The main E2E API test runner adds DB verification, MCP server setup, and plugin path handling. The Postman API collection is expanded with new Logs and Governance endpoints, updated provider references, and refined error handling.

Changes

Cohort / File(s) Summary
Newman Test Timeout Configuration
tests/e2e/api/run-newman-anthropic-integration.sh, tests/e2e/api/run-newman-bedrock-integration.sh, tests/e2e/api/run-newman-composite-integration.sh, tests/e2e/api/run-newman-openai-integration.sh, tests/e2e/api/run-newman-tests.sh
Replaced single --timeout-script 300000 with dual timeouts: --timeout-script 120000 and --timeout 900000 across all integration test runners.
E2E API Tests Infrastructure
tests/e2e/api/run-newman-api-tests.sh
Added DB verification support (CLI flags, config detection), MCP HTTP server setup/teardown on port 3001, plugin path resolution and build, Newman command modifications with shortened script timeout and longer overall timeout, environment variable injection, and enhanced logging.
Database Verification Reporter
tests/e2e/api/newman-reporter-dbverify/index.js, tests/e2e/api/newman-reporter-dbverify/package.json
Introduced new Newman reporter module for SQL-based CRUD verification against PostgreSQL/SQLite databases, with DSN resolution, endpoint-to-table mapping, and structured ASCII verification output.
E2E API Package Setup
tests/e2e/api/package.json
Added E2E API tests package manifest with dependencies on pg, better-sqlite3, and the local newman-reporter-dbverify module.
Postman API Collection
tests/e2e/api/bifrost-api-management.postman_collection.json
Extended API definition with new Logs (histogram endpoints), Governance (Routing Rules, Model Configs, Providers CRUD), and MCP (Reconnect endpoint) sections; updated provider references from test_provider to custom-123; refined error handling for 4xx responses; added enable_logging configuration; adjusted plugin enabled state initialization.
Code Cleanup
transports/bifrost-http/handlers/plugins.go
Removed trailing whitespace in updatePlugin function.

Sequence Diagram(s)

sequenceDiagram
    participant Newman as Newman Test Runner
    participant API as API Server
    participant Reporter as DB Verify Reporter
    participant DB as Database<br/>(PostgreSQL/SQLite)
    
    Newman->>Newman: Execute API test request
    Newman->>API: Send API call (POST/GET/PUT/DELETE)
    API-->>Newman: Return 2xx response + body
    Newman->>Reporter: After hook: emit request complete
    Reporter->>Reporter: Map endpoint to DB table(s)
    Reporter->>Reporter: Extract entity ID from response
    
    alt DB Connection Ready
        Reporter->>DB: Execute verification query
        DB-->>Reporter: Return query result
        Reporter->>Reporter: Validate expected fields
        Reporter->>Reporter: Queue verification result
    else DB Connection Pending
        Reporter->>Reporter: Queue verification for later
    end
    
    Reporter->>Reporter: On DB ready: drain queued verifications
    Reporter->>DB: Execute queued SQL queries
    DB-->>Reporter: Return results
    Reporter->>Reporter: Generate ASCII summary
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

🐰 Hoppy hearts and databases aligned,
Timeouts stretched, DB verifications refined,
MCP servers spinning on port three-oh-oh-one,
Governance rules and logs now all in fun!
A warren of tests now runs so deep,
Dreams of verified data, we Newman-ly keep!

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (1 warning, 2 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 56.25% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Linked Issues check ❓ Inconclusive Related issues field shows 'N/A' with no linked GitHub issues or discussions, making it unclear if this addresses specific test reliability concerns or failures. Link related GitHub issues or include issue numbers if this PR addresses specific test hanging or timeout problems.
Out of Scope Changes check ❓ Inconclusive PR includes significant out-of-scope changes beyond timeout adjustments: new DB verification reporter module with 837 lines, package.json additions, and Postman collection expansions with 347 new lines. Clarify whether DB verification reporter and Postman collection changes are intentional or should be separated into distinct PRs for focused review.
✅ Passed checks (2 passed)
Check name Status Explanation
Description check ✅ Passed The PR description is detailed and comprehensive, covering the database verification reporter, test infrastructure improvements, Postman collection updates, and configuration changes. It aligns well with the template structure.
Title check ✅ Passed The PR title accurately reflects the main changes: enhancing e2e API tests with DB verification (via new newman-reporter-dbverify module and related test infrastructure) and new endpoints (Logs, Governance, routing rules, model configs in the Postman collection).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 03-03-feat_added_timeout_for_api_tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Radheshg04 Radheshg04 marked this pull request as ready for review March 3, 2026 15:32
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 3, 2026

🧪 Test Suite Available

This PR can be tested by a repository admin.

Run tests for PR #1899

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/e2e/api/run-newman-composite-integration.sh (1)

175-206: ⚠️ Potential issue | 🟠 Major

Avoid eval in run_newman; this is injection-prone.

Lines [175-206] build a shell command string from interpolated values (including --folder) and execute it with eval, which can lead to command injection and quoting bugs.

🔒 Safer array-based rewrite
 run_newman() {
-    local cmd="newman run $COLLECTION"
+    local -a cmd=(newman run "$COLLECTION")
     if [ -n "${2:-}" ] && [ -f "${2}" ]; then
-        cmd="$cmd -e ${2}"
+        cmd+=(-e "${2}")
     else
         local base_url="${BIFROST_BASE_URL:-http://localhost:8080}"
         local provider="${BIFROST_PROVIDER:-openai}"
         local model="${BIFROST_MODEL:-gpt-4o}"
         local embedding_model="${BIFROST_EMBEDDING_MODEL:-text-embedding-3-small}"
         local speech_model="${BIFROST_SPEECH_MODEL:-tts-1}"
         local transcription_model="${BIFROST_TRANSCRIPTION_MODEL:-whisper-1}"
         local image_model="${BIFROST_IMAGE_MODEL:-dall-e-3}"
         if [ -n "$ENV_FLAG" ]; then
-            cmd="$cmd $ENV_FLAG"
+            cmd+=(-e "$ENVIRONMENT")
         fi
-        cmd="$cmd --env-var \"base_url=$base_url\" --env-var \"provider=$provider\" --env-var \"model=$model\" --env-var \"embedding_model=$embedding_model\" --env-var \"speech_model=$speech_model\" --env-var \"transcription_model=$transcription_model\" --env-var \"image_model=$image_model\""
+        cmd+=(--env-var "base_url=$base_url" --env-var "provider=$provider" --env-var "model=$model" --env-var "embedding_model=$embedding_model" --env-var "speech_model=$speech_model" --env-var "transcription_model=$transcription_model" --env-var "image_model=$image_model")
     fi
-    [ -n "$FOLDER" ] && cmd="$cmd $FOLDER"
-    cmd="$cmd --timeout-script 120000 --timeout 900000 -r $REPORTERS"
+    [ -n "$FOLDER" ] && cmd+=(--folder "$FOLDER")
+    cmd+=(--timeout-script 120000 --timeout 900000 -r "$REPORTERS")
     if [[ "$REPORTERS" == *"html"* ]]; then
-        cmd="$cmd --reporter-html-export $REPORT_DIR/report_${1:-run}.html"
+        cmd+=(--reporter-html-export "$REPORT_DIR/report_${1:-run}.html")
     fi
     if [[ "$REPORTERS" == *"json"* ]]; then
-        cmd="$cmd --reporter-json-export $REPORT_DIR/report_${1:-run}.json"
+        cmd+=(--reporter-json-export "$REPORT_DIR/report_${1:-run}.json")
     fi
-    [ -n "$VERBOSE" ] && cmd="$cmd $VERBOSE"
-    [ -n "$BAIL" ] && cmd="$cmd $BAIL"
+    [ -n "$VERBOSE" ] && cmd+=("$VERBOSE")
+    [ -n "$BAIL" ] && cmd+=("$BAIL")
     if [ "$ci_normalized" = "1" ] || [ "$ci_normalized" = "true" ]; then
-        cmd="$cmd --env-var \"CI=1\""
+        cmd+=(--env-var "CI=1")
     fi
-
-    eval $cmd
+    "${cmd[@]}"
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/e2e/api/run-newman-composite-integration.sh` around lines 175 - 206,
The current run_newman code builds a single string in cmd and executes it with
eval, which is injection-prone; replace this with a safely quoted array-based
invocation: create an array (e.g., cmd_args) instead of the string cmd, append
program name "newman" then push each argument as separate elements (use
cmd_args+=( "-e" "$2" ) when a file is provided, otherwise append each --env-var
as separate elements with their values quoted, and handle ENV_FLAG, FOLDER,
REPORTERS, REPORT_DIR, VERBOSE, BAIL, and ci_normalized by appending appropriate
elements like "--timeout-script" "120000" and reporter export flags), and
finally run newman with: "${cmd_args[@]}" (no eval). Ensure you stop using eval
$cmd and keep all variable expansions quoted to prevent injection.
🧹 Nitpick comments (1)
tests/e2e/api/run-newman-anthropic-integration.sh (1)

188-188: Make timeout values configurable once to reduce stack-wide drift.

Line [188] hardcodes values that are duplicated across multiple runner scripts. Consider env-backed defaults so future stack changes are single-point updates.

♻️ Proposed refactor
+# Timeout configuration (override in CI if needed)
+NEWMAN_TIMEOUT_SCRIPT_MS="${NEWMAN_TIMEOUT_SCRIPT_MS:-120000}"
+NEWMAN_TIMEOUT_MS="${NEWMAN_TIMEOUT_MS:-900000}"
+
 run_newman() {
@@
-    cmd+=(--timeout-script 120000 --timeout 900000)
+    cmd+=(--timeout-script "$NEWMAN_TIMEOUT_SCRIPT_MS" --timeout "$NEWMAN_TIMEOUT_MS")

As per coding guidelines, "always check the stack if there is one for the current PR. do not give localized reviews for the PR, always see all changes in the light of the whole stack of PRs (if there is a stack, if there is no stack you can continue to make localized suggestions/reviews)".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/e2e/api/run-newman-anthropic-integration.sh` at line 188, The hardcoded
timeouts in the cmd array (the tokens '--timeout-script' and '--timeout') inside
run-newman-anthropic-integration.sh should be replaced with env-backed defaults
so all runner scripts share a single configuration point; update the script to
read NEWMAN_TIMEOUT_SCRIPT and NEWMAN_TIMEOUT (or a single NEWMAN_TIMEOUTS
JSON/CSV) with sensible defaults and use those variables when appending to cmd,
and extract the same env defaults into a common sourced file (or CI variable) so
other runner scripts reference the same values.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@tests/e2e/api/run-newman-composite-integration.sh`:
- Around line 175-206: The current run_newman code builds a single string in cmd
and executes it with eval, which is injection-prone; replace this with a safely
quoted array-based invocation: create an array (e.g., cmd_args) instead of the
string cmd, append program name "newman" then push each argument as separate
elements (use cmd_args+=( "-e" "$2" ) when a file is provided, otherwise append
each --env-var as separate elements with their values quoted, and handle
ENV_FLAG, FOLDER, REPORTERS, REPORT_DIR, VERBOSE, BAIL, and ci_normalized by
appending appropriate elements like "--timeout-script" "120000" and reporter
export flags), and finally run newman with: "${cmd_args[@]}" (no eval). Ensure
you stop using eval $cmd and keep all variable expansions quoted to prevent
injection.

---

Nitpick comments:
In `@tests/e2e/api/run-newman-anthropic-integration.sh`:
- Line 188: The hardcoded timeouts in the cmd array (the tokens
'--timeout-script' and '--timeout') inside run-newman-anthropic-integration.sh
should be replaced with env-backed defaults so all runner scripts share a single
configuration point; update the script to read NEWMAN_TIMEOUT_SCRIPT and
NEWMAN_TIMEOUT (or a single NEWMAN_TIMEOUTS JSON/CSV) with sensible defaults and
use those variables when appending to cmd, and extract the same env defaults
into a common sourced file (or CI variable) so other runner scripts reference
the same values.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 11b46fb and 571ae65.

📒 Files selected for processing (6)
  • tests/e2e/api/run-newman-anthropic-integration.sh
  • tests/e2e/api/run-newman-api-tests.sh
  • tests/e2e/api/run-newman-bedrock-integration.sh
  • tests/e2e/api/run-newman-composite-integration.sh
  • tests/e2e/api/run-newman-openai-integration.sh
  • tests/e2e/api/run-newman-tests.sh

@Radheshg04 Radheshg04 force-pushed the 03-03-feat_added_timeout_for_api_tests branch from 571ae65 to d09527d Compare March 6, 2026 04:33
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/e2e/api/bifrost-api-management.postman_collection.json (1)

284-330: ⚠️ Potential issue | 🟠 Major

Don't mutate shared openai governance state from this suite.

The collection now creates a disposable custom-123 provider, but the provider-governance CRUD still writes to and deletes /api/governance/providers/openai. That overwrites real operator-managed config instead of test-owned state. Reuse the disposable provider here and move its delete until after this folder, or snapshot/restore the existing openai document.

🔧 Safer target for the provider-governance requests
-              "raw": "{{base_url}}/api/governance/providers/openai",
+              "raw": "{{base_url}}/api/governance/providers/custom-123",
               "host": ["{{base_url}}"],
-              "path": ["api", "governance", "providers", "openai"]
+              "path": ["api", "governance", "providers", "custom-123"]

Apply that to both the update and delete requests, and defer the earlier Delete Provider step until this governance cleanup is finished.

Also applies to: 1155-1178

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/e2e/api/bifrost-api-management.postman_collection.json` around lines
284 - 330, The tests are mutating the shared governance provider "openai";
change the governance CRUD requests to target the disposable provider created
earlier ("custom-123") instead of "/api/governance/providers/openai" (look for
requests referencing "/api/governance/providers/openai") and apply the same
change to both the governance Update and Delete steps; additionally, defer the
earlier "Delete Provider" request that removes "/api/providers/custom-123" until
after the governance cleanup folder completes (or implement snapshot/restore of
the original "openai" doc) so the suite only touches test-owned state (see "Get
Provider (After Create)", "Update Provider", "Delete Provider" and their
"/api/providers/custom-123" endpoints to find where to adjust ordering and
URLs).
🧹 Nitpick comments (5)
tests/e2e/api/newman-reporter-dbverify/index.js (2)

769-774: Same forEach implicit return issue.

Apply the same fix as above to avoid the Biome warning.

Proposed fix
         .catch((e) => {
           logsDbReady = false;
           console.warn(`[dbverify] Logs DB not reachable, skipping logs DB checks: ${e.message}`);
-          earlyLogsDbQueue.forEach((item) => results.push({ name: item.name, result: 'SKIP', detail: 'Logs DB not connected' }));
+          earlyLogsDbQueue.forEach((item) => {
+            results.push({ name: item.name, result: 'SKIP', detail: 'Logs DB not connected' });
+          });
           earlyLogsDbQueue.length = 0;
         });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/e2e/api/newman-reporter-dbverify/index.js` around lines 769 - 774, The
forEach callback uses an implicit arrow return which triggers the Biome warning;
replace the earlyLogsDbQueue.forEach((item) => results.push({ ... })) inside the
catch block with an explicit loop (e.g., for (const item of earlyLogsDbQueue) {
results.push({ name: item.name, result: 'SKIP', detail: 'Logs DB not connected'
}); }) so there is no implicit return, then clear earlyLogsDbQueue.length = 0 as
before; locate the callback in the catch block that sets logsDbReady = false and
console.warn to apply this change.

752-757: Remove implicit return from forEach callbacks.

The results.push() call returns a value (the new array length), which is implicitly returned from the forEach callback. While not a bug (forEach ignores return values), this triggers static analysis warnings and is a minor code smell.

Proposed fix
         .catch((e) => {
           dbReady = false;
           console.warn(`[dbverify] Main DB not reachable, skipping DB checks: ${e.message}`);
-          earlyMainDbQueue.forEach((item) => results.push({ name: item.name, result: 'SKIP', detail: 'Main DB not connected' }));
+          earlyMainDbQueue.forEach((item) => {
+            results.push({ name: item.name, result: 'SKIP', detail: 'Main DB not connected' });
+          });
           earlyMainDbQueue.length = 0;
         });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/e2e/api/newman-reporter-dbverify/index.js` around lines 752 - 757, The
forEach callback in earlyMainDbQueue.forEach currently uses an expression that
implicitly returns the result of results.push, triggering static-analysis
warnings; change the callback to a statement body that does not return a value
(e.g., use a block with results.push(...) followed by a semicolon or replace
with a for/of loop) so the push is executed but nothing is returned; update the
code around earlyMainDbQueue.forEach((item) => results.push({ name: item.name,
result: 'SKIP', detail: 'Main DB not connected' })); to a non-returning callback
or explicit loop, keeping the same objects and clearing earlyMainDbQueue
afterward.
tests/e2e/api/run-newman-api-tests.sh (1)

193-203: Unused loop variable i flagged by shellcheck.

The loop variable i is unused. This is a minor warning but easy to fix for cleaner code.

Proposed fix
     # Wait up to 10 s for it to accept connections
-    for i in $(seq 1 10); do
+    for _ in $(seq 1 10); do
         sleep 1
         if lsof -ti tcp:3001 &>/dev/null 2>&1; then
             echo "  http-no-ping-server ready (PID $HTTP_SERVER_PID)"
             return 0
         fi
     done
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/e2e/api/run-newman-api-tests.sh` around lines 193 - 203, The loop uses
an unused variable `i`; change the loop to use a throwaway variable (e.g. `_`)
so shellcheck warning is resolved: update the loop declaration (currently `for i
in $(seq 1 10); do`) to use `_` (or an equivalent unused name) and leave the
body (the lsof readiness check, echo and return) unchanged; refer to the loop
around the lsof readiness check in run-newman-api-tests.sh.
merged-prs.md (1)

1-32: Consider this file's purpose and placement.

This appears to be a personal tracking file for merged PRs by a specific author. A few observations:

  1. The static analysis warnings (MD018) are false positives - the # symbols are PR references, not markdown headings.
  2. Consider whether this file belongs in the repository root, or if it should be in a .github/ directory, a personal notes location, or excluded from version control entirely.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@merged-prs.md` around lines 1 - 32, merged-prs.md looks like a personal
PR-tracking note that triggers markdownlint MD018; either relocate or exclude it
and suppress the linter: move the file out of the repo root into a non-repo
personal/notes location or into a .github/ or docs/ folder if it must be stored
in-repo, or add it to .gitignore to keep it out of version control; if you must
keep it in the repo, suppress the false positive by adding a per-file
markdownlint directive (e.g., add <!-- markdownlint-disable MD018 --> at the top
of merged-prs.md) or add an exclusion rule for this filename in the repository’s
markdownlint configuration so the MD018 warnings stop.
tests/e2e/api/bifrost-api-management.postman_collection.json (1)

63-75: Narrow the collection-wide 4xx bypass.

This now runs for every request in the collection, so a mandatory management endpoint can go green if it happens to return unsupported_operation, feature_not_enabled, or a generic not configured message. Keeping that bypass behind an explicit request/folder allowlist would preserve the portability win without weakening the new coverage.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/e2e/api/bifrost-api-management.postman_collection.json` around lines 63
- 75, The current collection-level 4xx bypass unconditionally sets pass=true for
responses with certain error codes/messages (code block using
pm.response.json(), errCode and regex checks) which is too broad; restrict this
by adding an explicit allowlist check (e.g., an array of allowed request names
or folder names) and only run the existing errCode/regex logic when the current
request is on that allowlist (use pm.request.name or pm.info.folderName to look
up the current request and gate the existing if (!pass && code >= 400 && code <
500) { ... } block accordingly), so non-allowed requests cannot silently pass
due to those error codes/messages.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/e2e/api/package.json`:
- Around line 6-10: The test runner skips installing runtime deps required by
the custom reporter, so update the run-newman-api-tests.sh script to install
dependencies before invoking Newman: ensure the script (run-newman-api-tests.sh)
runs a reproducible install (e.g., cd tests/e2e/api && npm ci || npm install)
prior to exporting NODE_PATH and running newman with the
newman-reporter-dbverify reporter; this guarantees the required modules pg and
better-sqlite3 are present and avoids the "[dbverify] ... not found" warnings
(alternatively, add a short README note in tests/e2e/api documenting the npm
install prerequisite).

---

Outside diff comments:
In `@tests/e2e/api/bifrost-api-management.postman_collection.json`:
- Around line 284-330: The tests are mutating the shared governance provider
"openai"; change the governance CRUD requests to target the disposable provider
created earlier ("custom-123") instead of "/api/governance/providers/openai"
(look for requests referencing "/api/governance/providers/openai") and apply the
same change to both the governance Update and Delete steps; additionally, defer
the earlier "Delete Provider" request that removes "/api/providers/custom-123"
until after the governance cleanup folder completes (or implement
snapshot/restore of the original "openai" doc) so the suite only touches
test-owned state (see "Get Provider (After Create)", "Update Provider", "Delete
Provider" and their "/api/providers/custom-123" endpoints to find where to
adjust ordering and URLs).

---

Nitpick comments:
In `@merged-prs.md`:
- Around line 1-32: merged-prs.md looks like a personal PR-tracking note that
triggers markdownlint MD018; either relocate or exclude it and suppress the
linter: move the file out of the repo root into a non-repo personal/notes
location or into a .github/ or docs/ folder if it must be stored in-repo, or add
it to .gitignore to keep it out of version control; if you must keep it in the
repo, suppress the false positive by adding a per-file markdownlint directive
(e.g., add <!-- markdownlint-disable MD018 --> at the top of merged-prs.md) or
add an exclusion rule for this filename in the repository’s markdownlint
configuration so the MD018 warnings stop.

In `@tests/e2e/api/bifrost-api-management.postman_collection.json`:
- Around line 63-75: The current collection-level 4xx bypass unconditionally
sets pass=true for responses with certain error codes/messages (code block using
pm.response.json(), errCode and regex checks) which is too broad; restrict this
by adding an explicit allowlist check (e.g., an array of allowed request names
or folder names) and only run the existing errCode/regex logic when the current
request is on that allowlist (use pm.request.name or pm.info.folderName to look
up the current request and gate the existing if (!pass && code >= 400 && code <
500) { ... } block accordingly), so non-allowed requests cannot silently pass
due to those error codes/messages.

In `@tests/e2e/api/newman-reporter-dbverify/index.js`:
- Around line 769-774: The forEach callback uses an implicit arrow return which
triggers the Biome warning; replace the earlyLogsDbQueue.forEach((item) =>
results.push({ ... })) inside the catch block with an explicit loop (e.g., for
(const item of earlyLogsDbQueue) { results.push({ name: item.name, result:
'SKIP', detail: 'Logs DB not connected' }); }) so there is no implicit return,
then clear earlyLogsDbQueue.length = 0 as before; locate the callback in the
catch block that sets logsDbReady = false and console.warn to apply this change.
- Around line 752-757: The forEach callback in earlyMainDbQueue.forEach
currently uses an expression that implicitly returns the result of results.push,
triggering static-analysis warnings; change the callback to a statement body
that does not return a value (e.g., use a block with results.push(...) followed
by a semicolon or replace with a for/of loop) so the push is executed but
nothing is returned; update the code around earlyMainDbQueue.forEach((item) =>
results.push({ name: item.name, result: 'SKIP', detail: 'Main DB not connected'
})); to a non-returning callback or explicit loop, keeping the same objects and
clearing earlyMainDbQueue afterward.

In `@tests/e2e/api/run-newman-api-tests.sh`:
- Around line 193-203: The loop uses an unused variable `i`; change the loop to
use a throwaway variable (e.g. `_`) so shellcheck warning is resolved: update
the loop declaration (currently `for i in $(seq 1 10); do`) to use `_` (or an
equivalent unused name) and leave the body (the lsof readiness check, echo and
return) unchanged; refer to the loop around the lsof readiness check in
run-newman-api-tests.sh.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4b5d7d56-6f09-412a-9844-75b54d4a0ee1

📥 Commits

Reviewing files that changed from the base of the PR and between 571ae65 and d09527d.

📒 Files selected for processing (12)
  • merged-prs.md
  • tests/e2e/api/bifrost-api-management.postman_collection.json
  • tests/e2e/api/newman-reporter-dbverify/index.js
  • tests/e2e/api/newman-reporter-dbverify/package.json
  • tests/e2e/api/package.json
  • tests/e2e/api/run-newman-anthropic-integration.sh
  • tests/e2e/api/run-newman-api-tests.sh
  • tests/e2e/api/run-newman-bedrock-integration.sh
  • tests/e2e/api/run-newman-composite-integration.sh
  • tests/e2e/api/run-newman-openai-integration.sh
  • tests/e2e/api/run-newman-tests.sh
  • transports/bifrost-http/handlers/plugins.go
🚧 Files skipped from review as they are similar to previous changes (4)
  • tests/e2e/api/run-newman-openai-integration.sh
  • tests/e2e/api/run-newman-anthropic-integration.sh
  • tests/e2e/api/run-newman-tests.sh
  • tests/e2e/api/run-newman-composite-integration.sh

Comment thread tests/e2e/api/package.json
@Radheshg04 Radheshg04 force-pushed the 03-03-feat_added_timeout_for_api_tests branch from e572635 to a5c596f Compare March 6, 2026 07:04
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/e2e/api/bifrost-api-management.postman_collection.json (1)

4-4: ⚠️ Potential issue | 🟡 Minor

Documentation inconsistency: description references stale provider name.

The collection description still mentions test_provider as a fixed resource name, but the collection now uses custom-123 for the provider tests (see lines 284, 299, etc.).

📝 Suggested fix
-    "description": "E2E tests for Bifrost management API endpoints (/api/*) and health endpoint. Uses fixed resource names (e.g. test_provider, hello-world); do not run this collection in parallel against the same server.",
+    "description": "E2E tests for Bifrost management API endpoints (/api/*) and health endpoint. Uses fixed resource names (e.g. custom-123, hello-world); do not run this collection in parallel against the same server.",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/e2e/api/bifrost-api-management.postman_collection.json` at line 4,
Update the collection description string so it accurately reflects the current
fixed resource name used in the requests: replace the stale "test_provider"
mention with the actual provider identifier "custom-123" (the description field
at the top of the JSON and any other metadata description entries), and scan
request bodies/variables that the description references to ensure consistency
with the provider name used in requests (e.g., occurrences tied to provider
tests such as the requests referencing "custom-123").
🧹 Nitpick comments (5)
tests/e2e/api/run-newman-api-tests.sh (2)

195-201: Unused loop variable (minor).

The variable i in for i in $(seq 1 10) is unused within the loop body. This is a false positive from ShellCheck since you're just iterating, but you can use _ to indicate an intentionally unused variable.

♻️ Proposed fix
-    for i in $(seq 1 10); do
+    for _ in $(seq 1 10); do
         sleep 1
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/e2e/api/run-newman-api-tests.sh` around lines 195 - 201, Replace the
unused loop variable `i` in the for-loop in run-newman-api-tests.sh with `_` to
indicate it's intentionally unused: locate the loop `for i in $(seq 1 10); do`
(the block that sleeps, checks `lsof -ti tcp:3001`, echoes readiness including
`HTTP_SERVER_PID` and returns) and change the loop variable to `_` so it reads
`for _ in $(seq 1 10); do`.

169-204: Consider portability of lsof for port checking.

lsof may not be available on all systems (e.g., minimal Docker images). Consider adding a fallback using nc or curl for the readiness check.

♻️ Alternative readiness check using curl
     # Wait up to 10 s for it to accept connections
-    for i in $(seq 1 10); do
+    for _ in $(seq 1 10); do
         sleep 1
-        if lsof -ti tcp:3001 &>/dev/null 2>&1; then
+        if curl -s --max-time 1 http://localhost:3001/ >/dev/null 2>&1 || lsof -ti tcp:3001 &>/dev/null 2>&1; then
             echo "  http-no-ping-server ready (PID $HTTP_SERVER_PID)"
             return 0
         fi
     done
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/e2e/api/run-newman-api-tests.sh` around lines 169 - 204, The
start_http_mcp_server function currently relies solely on lsof to check port
3001; make the checks portable by adding a fallback path when lsof is not
present: detect if lsof exists and use it as now for the initial "port in use"
check and the readiness loop, otherwise use a lightweight alternative such as nc
-z localhost 3001 (or curl -sSf http://127.0.0.1:3001) to test connectivity;
update all places referencing lsof in start_http_mcp_server (the initial
skip-if-in-use block and the for-loop readiness check) to try lsof first, then
fall back to nc/curl, and keep setting HTTP_SERVER_PID and using
HTTP_SERVER_BIN/HTTP_SERVER_DIR as before.
tests/e2e/api/newman-reporter-dbverify/index.js (3)

140-159: Consider adding connection timeout for PostgreSQL client.

The pg.Client connection doesn't specify a connection timeout. If the database is unreachable, this could hang indefinitely.

♻️ Proposed fix to add connection timeout
   if (type === 'postgres') {
     let pg;
     try { pg = require('pg'); }
     catch (_) {
       console.warn('[dbverify] pg module not found. Run: npm install in tests/e2e/api/');
       return null;
     }
-    const pgClient = new pg.Client({ connectionString: url });
+    const pgClient = new pg.Client({
+      connectionString: url,
+      connectionTimeoutMillis: 10000, // 10 second timeout
+    });
     await pgClient.connect();
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/e2e/api/newman-reporter-dbverify/index.js` around lines 140 - 159, The
createDbClient function currently constructs a new pg.Client without any
timeout, so connect() can hang if the DB is unreachable; update the pg.Client
instantiation in createDbClient to include a connection timeout (e.g.,
connectionTimeoutMillis) in the client config and optionally a query timeout
(e.g., statement_timeout or query_timeout) to prevent indefinite hangs, and
ensure any thrown timeout error is propagated/handled the same way as other
connection errors; refer to the createDbClient function and the pg.Client
constructor when making the change.

755-756: Avoid returning values from forEach callbacks.

The results.push() call returns the new array length, which is inadvertently returned from the forEach callback. While harmless, this is flagged by static analysis and can be cleaner.

♻️ Proposed fix
-          earlyMainDbQueue.forEach((item) => results.push({ name: item.name, result: 'SKIP', detail: 'Main DB not connected' }));
+          for (const item of earlyMainDbQueue) {
+            results.push({ name: item.name, result: 'SKIP', detail: 'Main DB not connected' });
+          }
           earlyMainDbQueue.length = 0;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/e2e/api/newman-reporter-dbverify/index.js` around lines 755 - 756, The
forEach callback is implicitly returning the value from results.push which
static analysis flags; update the block around earlyMainDbQueue and results.push
to avoid returning from the callback — for example, replace
earlyMainDbQueue.forEach((item) => results.push({ name: item.name, result:
'SKIP', detail: 'Main DB not connected' })); with an explicit loop (e.g., for
(const item of earlyMainDbQueue) { results.push({ name: item.name, result:
'SKIP', detail: 'Main DB not connected' }); }) and keep the existing
earlyMainDbQueue.length = 0; so no value is returned from a callback.

772-773: Same forEach callback return issue as above.

♻️ Proposed fix
-          earlyLogsDbQueue.forEach((item) => results.push({ name: item.name, result: 'SKIP', detail: 'Logs DB not connected' }));
+          for (const item of earlyLogsDbQueue) {
+            results.push({ name: item.name, result: 'SKIP', detail: 'Logs DB not connected' });
+          }
           earlyLogsDbQueue.length = 0;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/e2e/api/newman-reporter-dbverify/index.js` around lines 772 - 773, The
forEach callback on earlyLogsDbQueue is causing the same callback/return pattern
problem as earlier; replace the forEach with an explicit for...of loop over
earlyLogsDbQueue and push each item into results using results.push({ name:
item.name, result: 'SKIP', detail: 'Logs DB not connected' }), then set
earlyLogsDbQueue.length = 0 after the loop to clear it; reference
earlyLogsDbQueue and results.push to locate the code to change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@tests/e2e/api/bifrost-api-management.postman_collection.json`:
- Line 4: Update the collection description string so it accurately reflects the
current fixed resource name used in the requests: replace the stale
"test_provider" mention with the actual provider identifier "custom-123" (the
description field at the top of the JSON and any other metadata description
entries), and scan request bodies/variables that the description references to
ensure consistency with the provider name used in requests (e.g., occurrences
tied to provider tests such as the requests referencing "custom-123").

---

Nitpick comments:
In `@tests/e2e/api/newman-reporter-dbverify/index.js`:
- Around line 140-159: The createDbClient function currently constructs a new
pg.Client without any timeout, so connect() can hang if the DB is unreachable;
update the pg.Client instantiation in createDbClient to include a connection
timeout (e.g., connectionTimeoutMillis) in the client config and optionally a
query timeout (e.g., statement_timeout or query_timeout) to prevent indefinite
hangs, and ensure any thrown timeout error is propagated/handled the same way as
other connection errors; refer to the createDbClient function and the pg.Client
constructor when making the change.
- Around line 755-756: The forEach callback is implicitly returning the value
from results.push which static analysis flags; update the block around
earlyMainDbQueue and results.push to avoid returning from the callback — for
example, replace earlyMainDbQueue.forEach((item) => results.push({ name:
item.name, result: 'SKIP', detail: 'Main DB not connected' })); with an explicit
loop (e.g., for (const item of earlyMainDbQueue) { results.push({ name:
item.name, result: 'SKIP', detail: 'Main DB not connected' }); }) and keep the
existing earlyMainDbQueue.length = 0; so no value is returned from a callback.
- Around line 772-773: The forEach callback on earlyLogsDbQueue is causing the
same callback/return pattern problem as earlier; replace the forEach with an
explicit for...of loop over earlyLogsDbQueue and push each item into results
using results.push({ name: item.name, result: 'SKIP', detail: 'Logs DB not
connected' }), then set earlyLogsDbQueue.length = 0 after the loop to clear it;
reference earlyLogsDbQueue and results.push to locate the code to change.

In `@tests/e2e/api/run-newman-api-tests.sh`:
- Around line 195-201: Replace the unused loop variable `i` in the for-loop in
run-newman-api-tests.sh with `_` to indicate it's intentionally unused: locate
the loop `for i in $(seq 1 10); do` (the block that sleeps, checks `lsof -ti
tcp:3001`, echoes readiness including `HTTP_SERVER_PID` and returns) and change
the loop variable to `_` so it reads `for _ in $(seq 1 10); do`.
- Around line 169-204: The start_http_mcp_server function currently relies
solely on lsof to check port 3001; make the checks portable by adding a fallback
path when lsof is not present: detect if lsof exists and use it as now for the
initial "port in use" check and the readiness loop, otherwise use a lightweight
alternative such as nc -z localhost 3001 (or curl -sSf http://127.0.0.1:3001) to
test connectivity; update all places referencing lsof in start_http_mcp_server
(the initial skip-if-in-use block and the for-loop readiness check) to try lsof
first, then fall back to nc/curl, and keep setting HTTP_SERVER_PID and using
HTTP_SERVER_BIN/HTTP_SERVER_DIR as before.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2f30a8c3-179c-4e36-8b03-8e77156c8896

📥 Commits

Reviewing files that changed from the base of the PR and between d09527d and a5c596f.

📒 Files selected for processing (11)
  • tests/e2e/api/bifrost-api-management.postman_collection.json
  • tests/e2e/api/newman-reporter-dbverify/index.js
  • tests/e2e/api/newman-reporter-dbverify/package.json
  • tests/e2e/api/package.json
  • tests/e2e/api/run-newman-anthropic-integration.sh
  • tests/e2e/api/run-newman-api-tests.sh
  • tests/e2e/api/run-newman-bedrock-integration.sh
  • tests/e2e/api/run-newman-composite-integration.sh
  • tests/e2e/api/run-newman-openai-integration.sh
  • tests/e2e/api/run-newman-tests.sh
  • transports/bifrost-http/handlers/plugins.go
✅ Files skipped from review due to trivial changes (2)
  • tests/e2e/api/package.json
  • transports/bifrost-http/handlers/plugins.go
🚧 Files skipped from review as they are similar to previous changes (5)
  • tests/e2e/api/run-newman-bedrock-integration.sh
  • tests/e2e/api/run-newman-composite-integration.sh
  • tests/e2e/api/run-newman-openai-integration.sh
  • tests/e2e/api/run-newman-anthropic-integration.sh
  • tests/e2e/api/newman-reporter-dbverify/package.json

@Radheshg04 Radheshg04 changed the title feat: added timeout for api tests feat: enhance e2e API tests with DB verification and new endpoints Mar 6, 2026
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Copy Markdown
Contributor

akshaydeo commented Mar 12, 2026

Merge activity

  • Mar 12, 5:16 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Mar 12, 5:17 AM UTC: @akshaydeo merged this pull request with Graphite.

@akshaydeo akshaydeo merged commit 2b524da into main Mar 12, 2026
9 of 10 checks passed
@akshaydeo akshaydeo deleted the 03-03-feat_added_timeout_for_api_tests branch March 12, 2026 05:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants