|
| 1 | +# Fixture Schema Reference |
| 2 | + |
| 3 | +## Overview |
| 4 | +Quick reference for the YAML fixture schema structure, valid values, and common patterns. |
| 5 | + |
| 6 | +## Schema Structure |
| 7 | + |
| 8 | +```yaml |
| 9 | +name: string # Required: Human-readable scenario name |
| 10 | +description: string # Required: Detailed description |
| 11 | +incidents: array # Required: Array of incident objects |
| 12 | + - id: string # Required: Unique incident identifier |
| 13 | + component: string # Required: Component affected |
| 14 | + layer: string # Required: Layer (core/Others) |
| 15 | + timeline: object # Optional: Timeline information |
| 16 | + start: string # Required: When incident started |
| 17 | + end: string # Optional: When incident ended |
| 18 | + severityChanges: array # Optional: Severity changes over time |
| 19 | + alerts: array # Required: Array of alert objects |
| 20 | + - name: string # Required: Alert name |
| 21 | + namespace: string # Required: Alert namespace |
| 22 | + severity: string # Required: Alert severity |
| 23 | + firing: boolean # Optional: Firing state |
| 24 | + managed_cluster: string # Optional: Managed cluster ID |
| 25 | +``` |
| 26 | +
|
| 27 | +## Valid Values |
| 28 | +
|
| 29 | +### Components |
| 30 | +- `monitoring` - Monitoring infrastructure |
| 31 | +- `storage` - Storage systems |
| 32 | +- `network` - Network components |
| 33 | +- `compute` - Compute resources |
| 34 | +- `api-server` - Kubernetes API server |
| 35 | +- `etcd` - etcd cluster |
| 36 | +- `version` - Cluster version |
| 37 | +- `Others` - Other components |
| 38 | + |
| 39 | +### Layers |
| 40 | +- `core` - Core OpenShift components |
| 41 | +- `Others` - Non-core components |
| 42 | + |
| 43 | +### Severities |
| 44 | +- `critical` - Critical alerts |
| 45 | +- `warning` - Warning alerts |
| 46 | +- `info` - Informational alerts |
| 47 | + |
| 48 | +### Duration Format |
| 49 | +- Pattern: `^\d+[smhd]$` |
| 50 | +- Examples: `"30m"`, `"2h"`, `"7d"`, `"1h"` |
| 51 | +- Units: `s` (seconds), `m` (minutes), `h` (hours), `d` (days) |
| 52 | + |
| 53 | +## Common Alert Names |
| 54 | + |
| 55 | +### Monitoring Component |
| 56 | +```yaml |
| 57 | +- name: "AlertmanagerReceiversNotConfigured" |
| 58 | + namespace: "openshift-monitoring" |
| 59 | + severity: "warning" |
| 60 | +
|
| 61 | +- name: "KubeDeploymentReplicasMismatch" |
| 62 | + namespace: "openshift-monitoring" |
| 63 | + severity: "critical" |
| 64 | +
|
| 65 | +- name: "KubePodCrashLooping" |
| 66 | + namespace: "openshift-monitoring" |
| 67 | + severity: "warning" |
| 68 | +
|
| 69 | +- name: "PrometheusConfigReloadFailure" |
| 70 | + namespace: "openshift-monitoring" |
| 71 | + severity: "warning" |
| 72 | +
|
| 73 | +- name: "Watchdog" |
| 74 | + namespace: "openshift-monitoring" |
| 75 | + severity: "info" |
| 76 | +``` |
| 77 | + |
| 78 | +### Storage Component |
| 79 | +```yaml |
| 80 | +- name: "KubePersistentVolumeFillingUp" |
| 81 | + namespace: "openshift-storage" |
| 82 | + severity: "critical" |
| 83 | +
|
| 84 | +- name: "DiskSpaceRunningLow" |
| 85 | + namespace: "openshift-storage" |
| 86 | + severity: "critical" |
| 87 | +
|
| 88 | +- name: "VolumeReadOnly" |
| 89 | + namespace: "openshift-storage" |
| 90 | + severity: "critical" |
| 91 | +``` |
| 92 | + |
| 93 | +### Network Component |
| 94 | +```yaml |
| 95 | +- name: "NetworkLatencyHigh" |
| 96 | + namespace: "openshift-network" |
| 97 | + severity: "warning" |
| 98 | +
|
| 99 | +- name: "EtcdMemberCommunicationSlow" |
| 100 | + namespace: "openshift-etcd" |
| 101 | + severity: "warning" |
| 102 | +``` |
| 103 | + |
| 104 | +### Compute Component |
| 105 | +```yaml |
| 106 | +- name: "NodeNotReady" |
| 107 | + namespace: "openshift-machine-api" |
| 108 | + severity: "critical" |
| 109 | +
|
| 110 | +- name: "KubeNodeUnreachable" |
| 111 | + namespace: "openshift-machine-api" |
| 112 | + severity: "critical" |
| 113 | +``` |
| 114 | + |
| 115 | +## Timeline Patterns |
| 116 | + |
| 117 | +### Simple Ongoing Incident |
| 118 | +```yaml |
| 119 | +timeline: |
| 120 | + start: "2h" # Started 2 hours ago |
| 121 | +``` |
| 122 | + |
| 123 | +### Resolved Incident |
| 124 | +```yaml |
| 125 | +timeline: |
| 126 | + start: "4h" # Started 4 hours ago |
| 127 | + end: "1h" # Resolved 1 hour ago |
| 128 | +``` |
| 129 | + |
| 130 | +### Severity Escalation |
| 131 | +```yaml |
| 132 | +timeline: |
| 133 | + start: "3h" # Started 3 hours ago |
| 134 | + severityChanges: |
| 135 | + - time: "3h" # Started as warning |
| 136 | + severity: "warning" |
| 137 | + - time: "1h" # Escalated to critical 1 hour ago |
| 138 | + severity: "critical" |
| 139 | +``` |
| 140 | + |
| 141 | +## Validation Rules |
| 142 | + |
| 143 | +### Required Fields |
| 144 | +- Root: `name`, `description`, `incidents` |
| 145 | +- Incident: `id`, `component`, `layer`, `alerts` |
| 146 | +- Alert: `name`, `namespace`, `severity` |
| 147 | +- Timeline: `start` |
| 148 | + |
| 149 | +### Format Constraints |
| 150 | +- Incident ID: Pattern `^[a-zA-Z0-9-_]+$` |
| 151 | +- Duration: Pattern `^\d+[smhd]$` |
| 152 | +- Component/Layer/Severity: Must be valid enum values |
| 153 | + |
| 154 | +### Array Constraints |
| 155 | +- Incidents: `minItems: 0` |
| 156 | +- Alerts: `minItems: 1` per incident |
| 157 | + |
| 158 | +## Usage in Tests |
| 159 | + |
| 160 | +```typescript |
| 161 | +// Load YAML fixture |
| 162 | +cy.mockIncidentFixture('cypress/fixtures/incident-scenarios/critical-monitoring-issues.yaml'); |
| 163 | +
|
| 164 | +// Load JSON fixture (backward compatibility) |
| 165 | +cy.mockIncidentFixture('cypress/fixtures/incident-scenarios/some-scenario.json'); |
| 166 | +``` |
| 167 | + |
| 168 | +## Validation Tools |
| 169 | + |
| 170 | +### CLI Validation |
| 171 | +```bash |
| 172 | +cd web/cypress/support/incidents_prometheus_query_mocks |
| 173 | +node validate-fixtures.js --all |
| 174 | +node validate-fixtures.js specific-file.yaml |
| 175 | +``` |
| 176 | + |
| 177 | +### Schema Files |
| 178 | +- Schema: `web/cypress/support/incidents_prometheus_query_mocks/fixture-schema.json` |
| 179 | +- Validator: `web/cypress/support/incidents_prometheus_query_mocks/schema-validator.ts` |
| 180 | +- CLI Tool: `web/cypress/support/incidents_prometheus_query_mocks/validate-fixtures.js` |
| 181 | + |
| 182 | +## Best Practices |
| 183 | + |
| 184 | +1. **Naming**: Use descriptive, specific names |
| 185 | +2. **Comments**: Add helpful comments for timeline values |
| 186 | +3. **Realistic Data**: Use actual OpenShift alert names |
| 187 | +4. **Consistent Format**: Follow established patterns |
| 188 | +5. **Validation**: Always validate before committing |
0 commit comments