Refactor code structure and optimize performance across multiple modules
This commit is contained in:
@@ -48,17 +48,48 @@ Before working in this directory:
|
||||
|
||||
## Test Categories
|
||||
|
||||
When writing tests, use appropriate xUnit traits:
|
||||
Use the standardized test categories from `StellaOps.TestKit.TestCategories`:
|
||||
|
||||
```csharp
|
||||
[Trait("Category", "Unit")] // Fast, isolated unit tests
|
||||
[Trait("Category", "Integration")] // Tests requiring infrastructure
|
||||
[Trait("Category", "E2E")] // Full end-to-end workflows
|
||||
[Trait("Category", "AirGap")] // Must work without network
|
||||
[Trait("Category", "Interop")] // Third-party tool compatibility
|
||||
[Trait("Category", "Performance")] // Performance benchmarks
|
||||
[Trait("Category", "Chaos")] // Failure injection tests
|
||||
[Trait("Category", "Security")] // Security-focused tests
|
||||
using StellaOps.TestKit;
|
||||
|
||||
// PR-GATING TESTS (run on every push/PR)
|
||||
[Trait("Category", TestCategories.Unit)] // Fast, in-memory, no external dependencies
|
||||
[Trait("Category", TestCategories.Architecture)] // Module dependency rules, naming conventions
|
||||
[Trait("Category", TestCategories.Contract)] // API/WebService contract verification
|
||||
[Trait("Category", TestCategories.Integration)] // Testcontainers, PostgreSQL, Valkey
|
||||
[Trait("Category", TestCategories.Security)] // Cryptographic validation, vulnerability scanning
|
||||
[Trait("Category", TestCategories.Golden)] // Output comparison against known-good references
|
||||
|
||||
// SCHEDULED/ON-DEMAND TESTS
|
||||
[Trait("Category", TestCategories.Performance)] // Performance measurements, SLO enforcement
|
||||
[Trait("Category", TestCategories.Benchmark)] // BenchmarkDotNet measurements
|
||||
[Trait("Category", TestCategories.AirGap)] // Offline/air-gapped environment validation
|
||||
[Trait("Category", TestCategories.Chaos)] // Fault injection, failure recovery
|
||||
[Trait("Category", TestCategories.Determinism)] // Reproducibility, stable ordering, idempotency
|
||||
[Trait("Category", TestCategories.Resilience)] // Retry policies, circuit breakers, timeouts
|
||||
[Trait("Category", TestCategories.Observability)] // OpenTelemetry traces, metrics, logging
|
||||
|
||||
// OTHER CATEGORIES
|
||||
[Trait("Category", TestCategories.Property)] // FsCheck/generative testing for invariants
|
||||
[Trait("Category", TestCategories.Snapshot)] // Golden master regression testing
|
||||
[Trait("Category", TestCategories.Live)] // Require external services (Rekor, feeds)
|
||||
```
|
||||
|
||||
### CI/CD Integration
|
||||
|
||||
Tests are discovered dynamically by `.gitea/workflows/test-matrix.yml` which runs all `*.Tests.csproj` files with Category filtering:
|
||||
- **PR-Gating:** Unit, Architecture, Contract, Integration, Security, Golden
|
||||
- **Scheduled:** Performance, Benchmark (daily)
|
||||
- **On-Demand:** AirGap, Chaos, Determinism, Resilience, Observability
|
||||
|
||||
### Validation
|
||||
|
||||
Run the validation script to ensure all tests have Category traits:
|
||||
```bash
|
||||
python devops/scripts/validate-test-traits.py # Report coverage
|
||||
python devops/scripts/validate-test-traits.py --fix # Add default Unit trait
|
||||
python devops/scripts/validate-test-traits.py --json # JSON output for CI
|
||||
```
|
||||
|
||||
## Key Patterns
|
||||
|
||||
Reference in New Issue
Block a user