|
| 1 | +# Test Data for CRD Converter |
| 2 | + |
| 3 | +This directory contains test data for the Kubernetes CRD to RouterConfig converter. |
| 4 | + |
| 5 | +## Directory Structure |
| 6 | + |
| 7 | +``` |
| 8 | +testdata/ |
| 9 | +├── base-config.yaml # Static base configuration (shared across all tests) |
| 10 | +├── input/ # Input CRD YAML files (IntelligentPool + IntelligentRoute) |
| 11 | +│ ├── 01-basic.yaml |
| 12 | +│ ├── 02-keyword-only.yaml |
| 13 | +│ ├── ... |
| 14 | +│ └── 15-keyword-embedding-domain-no-plugin.yaml |
| 15 | +└── output/ # Generated RouterConfig YAML files |
| 16 | + ├── 01-basic.yaml |
| 17 | + ├── 02-keyword-only.yaml |
| 18 | + ├── ... |
| 19 | + └── 15-keyword-embedding-domain-no-plugin.yaml |
| 20 | +``` |
| 21 | + |
| 22 | +## Base Configuration |
| 23 | + |
| 24 | +`base-config.yaml` contains static configuration that doesn't come from CRDs: |
| 25 | +- Reasoning families (deepseek, qwen3, gpt) |
| 26 | +- Default reasoning effort level |
| 27 | +- BERT model configuration |
| 28 | +- Semantic cache settings |
| 29 | +- Tools configuration |
| 30 | +- Prompt guard settings |
| 31 | +- Classifier configuration |
| 32 | +- Router options |
| 33 | +- Embedding models paths |
| 34 | +- API configuration |
| 35 | +- Observability settings |
| 36 | + |
| 37 | +## Test Scenarios Overview |
| 38 | + |
| 39 | +| # | File | Keyword | Embedding | Domain | Plugin | Use Case | |
| 40 | +|---|------|---------|-----------|--------|--------|----------| |
| 41 | +| 1 | 01-basic.yaml | ✓ | ✓ | ✓ | ✓ | Basic comprehensive example | |
| 42 | +| 2 | 02-keyword-only.yaml | ✓ | ✗ | ✗ | ✗ | FAQ detection, greetings | |
| 43 | +| 3 | 03-embedding-only.yaml | ✗ | ✓ | ✗ | ✗ | Customer support, technical issues | |
| 44 | +| 4 | 04-domain-only.yaml | ✗ | ✗ | ✓ | ✗ | STEM queries, subject routing | |
| 45 | +| 5 | 05-keyword-embedding.yaml | ✓ | ✓ | ✗ | ✗ | Urgent support with semantics | |
| 46 | +| 6 | 06-keyword-domain.yaml | ✓ | ✗ | ✓ | ✗ | Academic homework assistance | |
| 47 | +| 7 | 07-domain-embedding.yaml | ✗ | ✓ | ✓ | ✗ | Research queries by domain | |
| 48 | +| 8 | 08-keyword-embedding-domain.yaml | ✓ | ✓ | ✓ | ✗ | Comprehensive tech support | |
| 49 | +| 9 | 09-keyword-plugin.yaml | ✓ | ✗ | ✗ | ✓ | FAQ with caching | |
| 50 | +| 10 | 10-embedding-plugin.yaml | ✗ | ✓ | ✗ | ✓ | PII-protected queries | |
| 51 | +| 11 | 11-domain-plugin.yaml | ✗ | ✗ | ✓ | ✓ | Legal advice with disclaimers | |
| 52 | +| 12 | 12-keyword-embedding-plugin.yaml | ✓ | ✓ | ✗ | ✓ | Security queries with protection | |
| 53 | +| 13 | 13-keyword-domain-plugin.yaml | ✓ | ✗ | ✓ | ✓ | Medical queries with PII | |
| 54 | +| 14 | 14-domain-embedding-plugin.yaml | ✗ | ✓ | ✓ | ✓ | Financial advice with protection | |
| 55 | +| 15 | 15-keyword-embedding-domain-plugin.yaml | ✓ | ✓ | ✓ | ✓ | Enterprise compliance (full) | |
| 56 | +| 16 | 16-keyword-embedding-domain-no-plugin.yaml | ✓ | ✓ | ✓ | ✗ | Educational tutorials | |
| 57 | + |
| 58 | +## Test Scenarios Details |
| 59 | + |
| 60 | +### Signal Type Combinations (No Plugins) |
| 61 | + |
| 62 | +1. **02-keyword-only.yaml** - Only keyword signals |
| 63 | + - Use case: FAQ detection, greeting responses |
| 64 | + - Signals: urgent, greeting keywords |
| 65 | + |
| 66 | +2. **03-embedding-only.yaml** - Only embedding signals |
| 67 | + - Use case: Customer support, technical issue detection |
| 68 | + - Signals: customer_support, technical_issue embeddings |
| 69 | + |
| 70 | +3. **04-domain-only.yaml** - Only domain signals |
| 71 | + - Use case: STEM queries, subject-specific routing |
| 72 | + - Signals: math, physics, computer_science, chemistry domains |
| 73 | + |
| 74 | +4. **05-keyword-embedding.yaml** - Keyword + Embedding |
| 75 | + - Use case: Urgent support requests with semantic matching |
| 76 | + - Signals: urgent keywords + support_request embeddings |
| 77 | + |
| 78 | +5. **06-keyword-domain.yaml** - Keyword + Domain |
| 79 | + - Use case: Academic homework assistance |
| 80 | + - Signals: homework keywords + math/physics/chemistry domains |
| 81 | + |
| 82 | +6. **07-domain-embedding.yaml** - Domain + Embedding |
| 83 | + - Use case: Research queries in specific domains |
| 84 | + - Signals: research_question embeddings + biology/chemistry/physics domains |
| 85 | + |
| 86 | +7. **08-keyword-embedding-domain.yaml** - All three signal types |
| 87 | + - Use case: Comprehensive technical support routing |
| 88 | + - Signals: urgent keywords + technical_help embeddings + CS/engineering/math domains |
| 89 | + |
| 90 | +### Signal Type Combinations (With Plugins) |
| 91 | + |
| 92 | +8. **09-keyword-plugin.yaml** - Keyword + Plugins |
| 93 | + - Use case: FAQ with aggressive caching |
| 94 | + - Plugins: semantic-cache, header_mutation |
| 95 | + |
| 96 | +9. **10-embedding-plugin.yaml** - Embedding + Plugins |
| 97 | + - Use case: PII-protected sensitive data handling |
| 98 | + - Plugins: pii (redaction), jailbreak protection |
| 99 | + |
| 100 | +10. **11-domain-plugin.yaml** - Domain + Plugins |
| 101 | + - Use case: Legal advice with disclaimers |
| 102 | + - Plugins: system_prompt, semantic-cache |
| 103 | + |
| 104 | +11. **12-keyword-embedding-plugin.yaml** - Keyword + Embedding + Plugins |
| 105 | + - Use case: Security queries with protection |
| 106 | + - Plugins: jailbreak, system_prompt, header_mutation |
| 107 | + |
| 108 | +12. **13-keyword-domain-plugin.yaml** - Keyword + Domain + Plugins |
| 109 | + - Use case: Medical queries with PII protection |
| 110 | + - Plugins: pii (hash mode), system_prompt, semantic-cache |
| 111 | + |
| 112 | +13. **14-domain-embedding-plugin.yaml** - Domain + Embedding + Plugins |
| 113 | + - Use case: Financial advice with comprehensive protection |
| 114 | + - Plugins: pii, system_prompt, jailbreak, semantic-cache |
| 115 | + |
| 116 | +14. **15-keyword-embedding-domain-plugin.yaml** - Keyword + Embedding + Domain + Plugins |
| 117 | + - Use case: Enterprise compliance and legal queries with full protection |
| 118 | + - Signals: compliance/confidential keywords + business_analysis/legal_review embeddings + business/law/economics domains |
| 119 | + - Plugins: pii (hash/mask modes), jailbreak, system_prompt, semantic-cache, header_mutation |
| 120 | + - Multiple decisions with different plugin configurations |
| 121 | + |
| 122 | +15. **16-keyword-embedding-domain-no-plugin.yaml** - All signals, no plugins |
| 123 | + - Use case: Educational tutorials across multiple domains |
| 124 | + - Signals: tutorial keywords + learning_intent embeddings + CS/math/engineering domains |
| 125 | + - Multiple decisions with different priorities |
| 126 | + |
| 127 | +## Plugin Types Used |
| 128 | + |
| 129 | +- **semantic-cache**: Cache responses for similar queries |
| 130 | +- **pii**: Detect and redact/mask/hash PII entities |
| 131 | +- **jailbreak**: Detect and block jailbreak attempts |
| 132 | +- **system_prompt**: Inject custom system prompts |
| 133 | +- **header_mutation**: Add custom headers to requests |
| 134 | + |
| 135 | +## Running Tests |
| 136 | + |
| 137 | +```bash |
| 138 | +cd src/semantic-router |
| 139 | +go test ./pkg/k8s -v -run TestConverterWithTestData |
| 140 | +``` |
| 141 | + |
| 142 | +This will: |
| 143 | +1. Load `base-config.yaml` as the static configuration base |
| 144 | +2. Parse each input YAML file (IntelligentPool + IntelligentRoute) |
| 145 | +3. Convert CRDs to RouterConfig format |
| 146 | +4. Merge static base config with dynamic CRD-derived config |
| 147 | +5. Generate output YAML files in `testdata/output/` |
| 148 | +6. Validate that output can be unmarshaled correctly |
| 149 | + |
| 150 | +## Output Structure |
| 151 | + |
| 152 | +Each generated output file contains: |
| 153 | +- **Static parts** (from base-config.yaml): |
| 154 | + - embedding_models, bert_model, classifier, prompt_guard |
| 155 | + - semantic_cache, observability, api, tools |
| 156 | + - reasoning_families, default_reasoning_effort |
| 157 | + |
| 158 | +- **Dynamic parts** (from CRDs): |
| 159 | + - keyword_rules (from signals.keywords) |
| 160 | + - embedding_rules (from signals.embeddings) |
| 161 | + - categories (from signals.domains) |
| 162 | + - decisions (from decisions) |
| 163 | + - model_config (from IntelligentPool.models) |
| 164 | + - default_model (from IntelligentPool.defaultModel) |
| 165 | + |
0 commit comments