Add unit tests for Router configuration and transport layers
Some checks failed
Docs CI / lint-and-preview (push) Has been cancelled
Policy Lint & Smoke / policy-lint (push) Has been cancelled

- Implemented tests for RouterConfig, RoutingOptions, StaticInstanceConfig, and RouterConfigOptions to ensure default values are set correctly.
- Added tests for RouterConfigProvider to validate configurations and ensure defaults are returned when no file is specified.
- Created tests for ConfigValidationResult to check success and error scenarios.
- Developed tests for ServiceCollectionExtensions to verify service registration for RouterConfig.
- Introduced UdpTransportTests to validate serialization, connection, request-response, and error handling in UDP transport.
- Added scripts for signing authority gaps and hashing DevPortal SDK snippets.
This commit is contained in:
StellaOps Bot
2025-12-05 08:01:47 +02:00
parent 635c70e828
commit 6a299d231f
294 changed files with 28434 additions and 1329 deletions

View File

@@ -0,0 +1,61 @@
# Sample Stella Microservice Configuration
# This file defines optional endpoint overrides for microservices.
# YAML overrides can only modify endpoints already defined in code;
# they cannot create new endpoints.
#
# Place this file next to your microservice executable and configure
# the ConfigFilePath option in AddStellaMicroservice():
#
# services.AddStellaMicroservice(options =>
# {
# options.ServiceName = "my-service";
# options.Version = "1.0.0";
# options.Region = "us-east";
# options.ConfigFilePath = "microservice.yaml";
# });
# Endpoint overrides
# Each entry must match an existing endpoint by method + path.
# Only the properties you specify will be overridden.
endpoints:
# Override timeout for a long-running operation
- method: POST
path: /api/reports/generate
defaultTimeout: 5m # Supports: "30s", "5m", "1h", or "00:00:30" format
# Enable streaming for a large data endpoint
- method: GET
path: /api/data/stream
supportsStreaming: true
# Add authorization requirements
- method: DELETE
path: /api/admin/users/{id}
requiringClaims:
- type: role
value: admin
- type: permission
value: user:delete
# Full override example with all supported properties
- method: POST
path: /api/batch/process
defaultTimeout: 30m
supportsStreaming: true
requiringClaims:
- type: role
value: operator
- type: scope
value: batch:write
# Notes:
# - method: HTTP method (GET, POST, PUT, DELETE, PATCH, etc.)
# - path: Route template (must match code exactly, including parameters)
# - defaultTimeout: Optional. Overrides the endpoint's default timeout.
# Formats: "30s" (seconds), "5m" (minutes), "1h" (hours), or TimeSpan "00:05:00"
# - supportsStreaming: Optional. Whether the endpoint supports streaming responses.
# - requiringClaims: Optional. Claims required to access the endpoint.
# Each claim has 'type' (required) and 'value' (optional for presence-only checks).
#
# If a YAML override doesn't match any code endpoint, a warning is logged.
# This helps catch typos in method/path combinations.

118
etc/router.yaml.sample Normal file
View File

@@ -0,0 +1,118 @@
# StellaOps Router Configuration
# This file configures the router gateway behavior, services, and routing rules.
# Payload limits control memory usage and protect against oversized requests
payloadLimits:
maxRequestBytesPerCall: 10485760 # 10 MB - max size of a single request
maxRequestBytesPerConnection: 104857600 # 100 MB - max total bytes per connection
maxAggregateInflightBytes: 1073741824 # 1 GB - max total in-flight across all connections
# Routing options control how requests are distributed to microservices
routing:
localRegion: "eu1" # This gateway's region
neighborRegions: # Fallback regions (in order of preference)
- eu2
- us1
tieBreaker: roundRobin # Options: roundRobin, random, leastLoaded, consistentHash
preferLocalRegion: true # Prefer instances in the local region
defaultTimeout: "00:00:30" # 30 seconds default request timeout
# Service definitions describe the microservices the gateway routes to
services:
- serviceName: billing
defaultVersion: "1.0.0"
defaultTransport: tcp # Options: tcp, certificate, udp, rabbitMq, inMemory
endpoints:
- method: POST
path: /invoices
defaultTimeout: "00:00:30" # 30 seconds
supportsStreaming: false
requiringClaims:
- type: role
value: billing-admin
- method: GET
path: /invoices/{id}
defaultTimeout: "00:00:05" # 5 seconds
- method: GET
path: /invoices
defaultTimeout: "00:00:10"
supportsStreaming: true # Streaming for large result sets
- serviceName: inventory
defaultVersion: "2.1.0"
defaultTransport: certificate # TLS with client certificates
endpoints:
- method: GET
path: /items
supportsStreaming: true
- method: POST
path: /items
defaultTimeout: "00:00:15"
requiringClaims:
- type: role
value: inventory-manager
- method: PUT
path: /items/{id}
defaultTimeout: "00:00:15"
- method: DELETE
path: /items/{id}
requiringClaims:
- type: role
value: admin
- serviceName: scanner
defaultVersion: "1.0.0"
defaultTransport: tcp
endpoints:
- method: POST
path: /scan
defaultTimeout: "00:05:00" # 5 minutes for long-running scans
supportsStreaming: true
- method: GET
path: /scan/{id}/status
# Static instances are pre-configured microservices (optional)
# Usually instances are discovered dynamically via HELLO messages
staticInstances:
- serviceName: billing
version: "1.0.0"
region: eu1
host: billing-eu1-01.internal
port: 5100
transport: tcp
weight: 100
metadata:
environment: production
rack: rack-1
- serviceName: billing
version: "1.0.0"
region: eu1
host: billing-eu1-02.internal
port: 5100
transport: tcp
weight: 100
metadata:
environment: production
rack: rack-2
- serviceName: billing
version: "1.0.0"
region: eu2
host: billing-eu2-01.internal
port: 5100
transport: tcp
weight: 80 # Lower weight for cross-region
metadata:
environment: production
# Environment variable overrides:
# STELLAOPS_ROUTER_PAYLOADLIMITS__MAXREQUESTBYTESPERCALL=20971520
# STELLAOPS_ROUTER_ROUTING__DEFAULTTIMEOUT=00:01:00
# STELLAOPS_ROUTER_ROUTING__LOCALREGION=us1