Skip to content

Add public API smoke tests#44

Merged
Kzoeps merged 16 commits into
mainfrom
smoke-test
May 4, 2026
Merged

Add public API smoke tests#44
Kzoeps merged 16 commits into
mainfrom
smoke-test

Conversation

@Kzoeps
Copy link
Copy Markdown
Collaborator

@Kzoeps Kzoeps commented Apr 30, 2026

Summary

  • Add a read-only post-deploy API/GraphQL smoke suite under tests/api-smoke.
  • Add make smoke-api with friendly streamed operator output, debug request logs, and fail-fast URL validation.
  • Document smoke requirements, loaded lexicon/startup behavior, public-only limitations, data assumptions, and expectations overrides.

Validation

  • go build -v ./...
  • make lint
  • DATABASE_URL=sqlite::memory: go test -v -race ./...
  • make test
  • go test ./tests/api-smoke
  • HYPERINDEX_SMOKE_URL=http://127.0.0.1:1 go test -tags=api_smoke ./tests/api-smoke -run TestNonExistent -count=1
  • HYPERINDEX_SMOKE_URL=https://dev.api.hi.gainforest.app make smoke-api
  • HYPERINDEX_SMOKE_DEBUG=1 HYPERINDEX_SMOKE_URL=https://dev.api.hi.gainforest.app make smoke-api

Summary by CodeRabbit

  • New Features

    • Added a post-deployment API smoke test suite exercising public GraphQL and REST endpoints (health, schema, records, pagination, search).
  • Documentation

    • Added comprehensive README explaining how to run the smoke tests, environment variables, expectations override, and debug options.
  • Chores

    • Added a make target to run the smoke test suite.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hyperindex-atproto-client Ready Ready Preview, Comment May 4, 2026 6:16am
hyperindex-client Ready Ready Preview, Comment May 4, 2026 6:16am

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 30, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: db5db7cc-c184-463c-941c-785549076326

📥 Commits

Reviewing files that changed from the base of the PR and between 441c266 and bfaed8f.

📒 Files selected for processing (2)
  • tests/api-smoke/config_test.go
  • tests/api-smoke/pagination_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/api-smoke/config_test.go

📝 Walkthrough

Walkthrough

Adds a new post-deploy, read-only API smoke test suite (GraphQL + REST), its configuration/expectations, test helpers, tests for schema/records/pagination/search/health/stats, docs, a Makefile target, and an unreleased changelog entry.

Changes

API Smoke Tests

Layer / File(s) Summary
Data Shape / Expectations
tests/api-smoke/expectations.json
New JSON fixture listing required NSIDs, typed query field mappings, non-record NSIDs, data-bearing collection minimums, pagination page sizes, and search payload.
Config & Validation
tests/api-smoke/config_test.go
Added smokeConfig loader parsing HYPERINDEX_SMOKE_URL, loading expectations.json (or HYPERINDEX_SMOKE_EXPECTATIONS), HTTP client timeout, debug flag, and expectations.validate() with cross-field consistency checks (requiredNSIDs, typedQueryFields, nonRecordNSIDs, dataBearingCollections, pagination constraints, search).
GraphQL/HTTP Client Utilities
tests/api-smoke/graphql_client_test.go
Added GraphQL POST helpers (postGraphQL/postGraphQLWithOptions), typed response/error models, debug logging, and response truncation utilities.
REST Helpers & Tests
tests/api-smoke/rest_test.go
Added REST helpers and tests for /health (status "ok") and /stats (integer-like non-negative records/actors/lexicons and minimums).
Schema Introspection Tests
tests/api-smoke/schema_test.go
Added GraphQL introspection tests verifying presence/shape of typed query fields, connection subfields, ByUri variants, exclusion of non-record lexicons, and required public queries.
Record & Typed Round-Trip Tests
tests/api-smoke/records_test.go
Added tests asserting record shape invariants (URI/DID prefixes, collection matching, CID/rkey presence) and typed ByUri round-trip equality with generic record.
Pagination Tests
tests/api-smoke/pagination_test.go
Added tests exercising cursor pagination across two pages per configured collection: edge counts, cursors non-empty, hasNextPage true on first page, endCursor present, and no duplicate URIs across pages.
Public Queries / Search Tests
tests/api-smoke/public_queries_test.go
Added tests for collectionStats coverage and search results validation (at least one edge, URI/DID prefixes, collection presence).
Build Integration & Docs
Makefile, tests/api-smoke/README.md
Added make smoke-api phony target to run go test -tags=api_smoke ./tests/api-smoke, documented invocation, required env vars (HYPERINDEX_SMOKE_URL, optional HYPERINDEX_SMOKE_EXPECTATIONS, debug flag), and listed concrete checks and limitations.
Changelog
.changes/unreleased/add-api-smoke-tests.yaml
Added unreleased changelog entry (kind: added) documenting the new read-only API smoke test suite and marking it as operator-facing.

Sequence Diagram

sequenceDiagram
    participant Runner as Test Runner (make / go test)
    participant Smoke as Smoke Tests
    participant API as Hyperindex API (GraphQL/REST)
    participant Expectations as expectations.json
    Runner->>Smoke: invoke (HYPERINDEX_SMOKE_URL, optional expectations)
    Smoke->>Expectations: load & validate expectations.json
    Smoke->>API: GET /health
    API-->>Smoke: 200 + {"status":"ok"}
    Smoke->>API: GET /stats
    API-->>Smoke: 200 + stats JSON
    Smoke->>API: POST /graphql (introspection / records / search)
    API-->>Smoke: 200 + GraphQL response
    Smoke->>Runner: pass/fail results (exit code, logs)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Poem

🐰 Soft whiskers twitch at CI's hum,
I hop through queries, one by one.
Health checks pass and cursors flow,
Records found where tall grasses grow.
A little rabbit nods—tests done!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add public API smoke tests' accurately and concisely summarizes the main change: introducing a comprehensive smoke test suite for the public API.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch smoke-test

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
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

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

@railway-app
Copy link
Copy Markdown

railway-app Bot commented Apr 30, 2026

🚅 Deployed to the hyperindex-pr-44 environment in hyperindex-v2-setup

Service Status Web Updated (UTC)
hyperindex ✅ Success (View Logs) Web May 4, 2026 at 6:17 am
hyperindex-client ⏭️ Skipped (View Logs) Web May 4, 2026 at 6:16 am
1 service not affected by this PR
  • hyperindex-client

Copy link
Copy Markdown

@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: 2

🤖 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/api-smoke/config_test.go`:
- Around line 145-175: validate() currently only builds dataBearingNSIDs
(map[string]bool) so the pagination check can't access MinimumRecords; add a
map[string]int (e.g., dataBearingMinRecords) when iterating
e.DataBearingCollections to record each collection.MinimumRecords keyed by
collection.NSID, then in the loop over e.PaginationCollections (using
collection.NSID and collection.PageSize) validate that
dataBearingMinRecords[collection.NSID] >= 2*collection.PageSize and return a
clear fmt.Errorf like "pagination collection %q must have minimumRecords >= 2 *
pageSize" if it doesn't; keep existing checks (NSID non-empty, PageSize > 0,
presence in dataBearingNSIDs) and add this new two-page assertion.

In `@tests/api-smoke/pagination_test.go`:
- Around line 11-36: The test currently enforces a hard-coded
expectedPaginationPageSize (expectedPaginationPageSize = 10) inside
TestPaginationSmoke, which prevents collection-specific pageSize overrides;
remove the constant and the gate that checks collection.PageSize against it, and
instead use collection.PageSize directly in the test's pagination queries and
assertions (e.g., in TestPaginationSmoke and any pagination assertions that
referenced expectedPaginationPageSize), or default to the collection.PageSize
when building the request so per-collection page sizes are honored.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ec8087a8-25d8-435c-aa68-045875618d2d

📥 Commits

Reviewing files that changed from the base of the PR and between fbbc7b1 and 441c266.

📒 Files selected for processing (11)
  • .changes/unreleased/add-api-smoke-tests.yaml
  • Makefile
  • tests/api-smoke/README.md
  • tests/api-smoke/config_test.go
  • tests/api-smoke/expectations.json
  • tests/api-smoke/graphql_client_test.go
  • tests/api-smoke/pagination_test.go
  • tests/api-smoke/public_queries_test.go
  • tests/api-smoke/records_test.go
  • tests/api-smoke/rest_test.go
  • tests/api-smoke/schema_test.go

Comment thread tests/api-smoke/config_test.go Outdated
Comment thread tests/api-smoke/pagination_test.go Outdated
@railway-app railway-app Bot temporarily deployed to hyperindex-v2-setup / hyperindex-pr-44 May 4, 2026 06:16 Destroyed
@Kzoeps Kzoeps merged commit db582c8 into main May 4, 2026
10 checks passed
@Kzoeps Kzoeps deleted the smoke-test branch May 4, 2026 06:26
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.

1 participant