| Crates.io | llm-optimizer-api-tests |
| lib.rs | llm-optimizer-api-tests |
| version | 0.1.1 |
| created_at | 2025-11-11 03:05:20.525844+00 |
| updated_at | 2025-11-11 03:05:20.525844+00 |
| description | Comprehensive API testing suite |
| homepage | https://github.com/globalbusinessadvisors/llm-auto-optimizer |
| repository | https://github.com/globalbusinessadvisors/llm-auto-optimizer |
| max_upload_size | |
| id | 1926647 |
| size | 318,136 |
Comprehensive test suite for REST APIs, gRPC APIs, and API Gateway with security validation, performance benchmarks, and integration tests.
This crate provides extensive testing coverage for all API implementations in the LLM Auto Optimizer project:
# Install Rust (1.75+)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Install testing tools (optional but recommended)
cargo install cargo-tarpaulin # Code coverage
brew install k6 # Load testing (macOS)
# or
sudo apt-get install wrk # Alternative load testing
# Run all tests
cargo test --all
# Run specific test suites
cargo test --test rest_api
cargo test --test grpc_api
cargo test --test gateway
cargo test --test security
cargo test --test integration
# Run with output
cargo test -- --nocapture
# Run benchmarks
cargo bench
# Generate coverage report
cargo tarpaulin --out Html --output-dir coverage
# Run all tests with comprehensive reporting
./scripts/run_all_tests.sh
# Run load tests
export API_BASE_URL=http://localhost:8080
./scripts/load_test.sh
# Run security scan
./scripts/security_scan.sh
api-tests/
├── src/
│ ├── lib.rs # Test library
│ ├── common.rs # Common utilities
│ ├── fixtures.rs # Test fixtures and mock data
│ └── helpers.rs # Helper functions (JWT, HTTP client)
├── tests/
│ ├── rest_api/ # REST API tests
│ │ ├── endpoints.rs # CRUD operations, pagination
│ │ ├── auth.rs # Authentication, authorization
│ │ ├── validation.rs # Request/response validation
│ │ ├── ratelimit.rs # Rate limiting tests
│ │ └── performance.rs # REST performance tests
│ ├── grpc_api/ # gRPC API tests
│ │ ├── services.rs # RPC method tests
│ │ ├── streaming.rs # Streaming tests
│ │ ├── interceptors.rs # Interceptor tests
│ │ └── performance.rs # gRPC performance tests
│ ├── gateway/ # API Gateway tests
│ │ ├── routing.rs # Routing tests
│ │ ├── translation.rs # Protocol translation
│ │ ├── composition.rs # Service composition
│ │ └── security.rs # Gateway security
│ ├── security/ # Security tests
│ │ ├── owasp_api_top10.rs # OWASP compliance
│ │ ├── auth_security.rs # Auth security
│ │ └── penetration.rs # Penetration tests
│ └── integration/ # Integration tests
│ └── e2e.rs # End-to-end workflows
├── benches/ # Performance benchmarks
│ ├── latency_bench.rs # Latency benchmarks
│ ├── load_test.rs # Load testing
│ └── streaming_bench.rs # Streaming performance
├── scripts/ # Test automation scripts
│ ├── run_all_tests.sh # Run all tests
│ ├── load_test.sh # Load testing script
│ └── security_scan.sh # Security scanning
├── proto/ # Protocol buffer definitions
│ └── optimizer.proto # gRPC service definitions
└── README.md # This file
Endpoints Tests (tests/rest_api/endpoints.rs):
Authentication Tests (tests/rest_api/auth.rs):
Validation Tests (tests/rest_api/validation.rs):
Rate Limiting Tests (tests/rest_api/ratelimit.rs):
Performance Tests (tests/rest_api/performance.rs):
Service Tests (tests/grpc_api/services.rs):
Streaming Tests (tests/grpc_api/streaming.rs):
Interceptor Tests (tests/grpc_api/interceptors.rs):
Performance Tests (tests/grpc_api/performance.rs):
Routing Tests (tests/gateway/routing.rs):
Translation Tests (tests/gateway/translation.rs):
Composition Tests (tests/gateway/composition.rs):
Security Tests (tests/gateway/security.rs):
OWASP API Security Top 10 (tests/security/owasp_api_top10.rs):
Authentication Security (tests/security/auth_security.rs):
Penetration Tests (tests/security/penetration.rs):
Latency Benchmarks (benches/latency_bench.rs):
Load Tests (benches/load_test.rs):
Streaming Benchmarks (benches/streaming_bench.rs):
End-to-End Tests (tests/integration/e2e.rs):
| Metric | Target | Current Status |
|---|---|---|
| REST API p50 | <10ms | ✅ |
| REST API p95 | <50ms | ✅ |
| REST API p99 | <100ms | ✅ |
| gRPC API p50 | <5ms | ✅ |
| gRPC API p95 | <25ms | ✅ |
| gRPC API p99 | <50ms | ✅ |
| Throughput | >10,000 req/sec | ✅ |
| Concurrent Connections | 1000+ | ✅ |
| Streaming Throughput | >1000 msg/sec | ✅ |
| Code Coverage | >90% | 📊 In Progress |
name: API Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Run tests
run: cargo test --all
- name: Run benchmarks
run: cargo bench --no-run
- name: Security scan
run: ./scripts/security_scan.sh
- name: Generate coverage
run: cargo tarpaulin --out Xml
- name: Upload coverage
uses: codecov/codecov-action@v3
cargo test --releasesrc/fixtures.rscargo testApache 2.0 - See LICENSE file for details