Replace type synonym Projects.ProjectId with UUIDId constructor
in all test files to fix "Illegal term-level use of type constructor"
errors that occur with GHC 9.12's TypeAbstractions extension.
Update all integration tests to properly unpack tuple response from testServant helper, which now returns (RespHeaders a, a).
Key changes:
- Add servant and servant-htmx to integration test dependencies
- Fix tuple unpacking in all test specs (AnomalyList, Log, Alerts, ManageMembers, Projects, BusinessFlows, Reports, Api, ApiCatalog, GrpcIngestion)
- Fix BusinessFlowsSpec imports to use ResponseHeader data constructor
- Fix type-level string usage for header lookups
- Fix ProjectId to Text conversions using .toText
- Add missing pattern match cases to avoid incomplete pattern warnings
Move test helper functions for creating API keys and ingesting
telemetry data (logs, traces, metrics) from GrpcIngestionSpec into
the shared TestUtils module. This includes:
- createTestAPIKey: Create API keys via handler
- ingestLog/Trace/Metric: Ingest via resource attributes
- ingestLogWithHeader/TraceWithHeader/MetricWithHeader: Ingest via gRPC Authorization header
- toBaseServantResponse: Run base context handlers in tests
Add necessary imports (Proto, OTLP modules, Api module) and derive
Generic for AuthContext to support the new test infrastructure.
Metadata authentication:
- Add OtlpRequestMetadata type to parse Authorization header from gRPC metadata
- Support both 'Bearer <token>' and raw token formats
- Update processTraceRequest, processLogsRequest, processMetricsRequest to accept
metadata API key parameter
- Add RPC handlers that extract API key from gRPC metadata
- Combine metadata API key with resource attribute keys for authentication
- Add test helpers for ingesting telemetry with gRPC headers
Grapesy API compatibility (for upgraded library):
- Replace NoMethods with NoMoreMethods constructor
- Update sendFinalOutput calls to pass tuple (defMessage, NoMetadata)
- Add type instance declarations for response metadata
Update expectLogsJson helper to use fail instead of expectationFailure
for proper IO type compatibility, add handling for LogsPatternList
constructor, and fix Test 3.2 to properly expect GrpcUnauthenticated
exception when API key is missing.
- Add Data.Aeson qualified import
- Fix queryLogs return type: LogsResp -> LogsGet
- Make expectLogsJson type more specific
- Add LogsQueryLibrary case to expectLogsJson pattern match
- Add testTimeRange constant for common time range setup
- Add helper functions: ingestLog, ingestTrace, ingestMetric
- Add queryLogs helper to replace repetitive 22-parameter apiLogH calls
- Add expectLogsJson helper for unified response extraction
- Use traverse and zip/zip3 for cleaner iteration patterns
- Reduced from 447 lines to 176 lines (60% reduction)
- All tests still target complete handler chains
Update integration tests to use the new TestResources pattern for better
test organization and consistency.
Changes:
- Replace withSetup callback with withTestResources
- Use runTestBg helper instead of runTestBackground
- Access test resources via TestResources record fields
- Remove redundant imports (execute from DBT)
- Simplify test setup code
This refactoring improves test readability and reduces boilerplate.