cqlite-cli 0.11.0

Command-line interface for CQLite โ€” read Apache Cassandra 5.0 SSTables without a cluster
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
# ๐Ÿ˜ CQLite Cassandra Compatibility Testing Guide

This comprehensive guide covers the automated compatibility testing framework that ensures CQLite remains compatible with all Cassandra versions as they evolve.

## ๐ŸŽฏ Overview

The compatibility testing framework automatically:

- โœ… **Tests multiple Cassandra versions** (4.0, 4.1, 5.0, 5.1, 6.0+)
- ๐Ÿ” **Detects SSTable format changes** between versions
- ๐Ÿ“Š **Validates data integrity** across versions
- โšก **Measures performance** and identifies regressions
- ๐Ÿšจ **Alerts on compatibility issues** via CI/CD
- ๐Ÿ“ˆ **Tracks trends** over time for proactive maintenance

## ๐Ÿš€ Quick Start

### 1. Setup (One-time)

```bash
# Clone and setup the testing environment
cd cqlite-cli
./tests/compatibility/scripts/setup.sh
```

### 2. Run Tests

```bash
# Test specific Cassandra version
./tests/compatibility/scripts/compatibility_checker.sh --version 5.1 --test-suite comprehensive

# Run full compatibility matrix
./tests/compatibility/scripts/compatibility_checker.sh --matrix

# Monitor continuously (for production)
./tests/compatibility/scripts/compatibility_checker.sh --monitor 24h
```

### 3. View Results

```bash
# Open the compatibility dashboard
open tests/compatibility/results/compatibility-dashboard.md

# View detailed JSON results
cat tests/compatibility/results/compatibility-matrix.json
```

## ๐Ÿ—๏ธ Architecture

### Core Components

#### 1. **Version Manager** (`src/version_manager.rs`)
- Docker-based Cassandra version management
- Automatic setup/teardown of test clusters
- Health checking and readiness validation
- Port management for parallel testing

```rust
let mut manager = CassandraVersionManager::new();
let version_info = manager.start_version("5.1").await?;
let results = manager.run_compatibility_matrix().await?;
```

#### 2. **Format Detective** (`src/format_detective.rs`)
- Binary analysis of SSTable files
- Automatic detection of format changes
- Impact assessment (breaking vs. compatible)
- Format evolution tracking

```rust
let detective = FormatDetective::new();
let format = detective.analyze_sstable_format(&sstable_path).await?;
let diff = detective.compare_formats("4.0", "5.1")?;
```

#### 3. **Data Generator** (`src/data_generator.rs`)
- Deterministic test data across versions
- All CQL data types (basic, collections, UDTs)
- Complex nested structures
- Performance datasets

```rust
let mut generator = TestDataGenerator::new(output_dir);
let datasets = generator.generate_all_versions().await?;
```

#### 4. **Test Suite** (`src/suite.rs`)
- Comprehensive compatibility validation
- SSTable parsing verification
- Query compatibility testing
- Performance regression analysis

```rust
let mut suite = CompatibilityTestSuite::new(data_dir);
let report = suite.run_full_compatibility_suite().await?;
```

## ๐Ÿงช Test Levels

### Basic Testing
- Core SSTable parsing
- Basic data types (text, int, uuid)
- Simple queries
- **Runtime**: ~5 minutes

### Comprehensive Testing (Default)
- All CQL data types
- Collections (list, set, map)
- User-defined types (UDTs)
- Complex queries and indexes
- **Runtime**: ~20 minutes

### Full Testing
- All comprehensive tests
- Performance benchmarks
- Edge cases and stress testing
- Large dataset validation
- **Runtime**: ~60 minutes

## ๐Ÿ“Š Supported Cassandra Versions

| Version | Status | SSTable Format | Key Features |
|---------|--------|----------------|--------------|
| 4.0.x | โœ… Stable | `big` | Baseline compatibility |
| 4.1.x | โœ… Stable | `big` | Virtual tables |
| 5.0.x | โœ… Stable | `big` | SAI indexes, Vector search |
| 5.1.x | โœ… Stable | `big` | Enhanced vector support |
| 6.0.x | ๐Ÿ”„ Testing | `big`* | Future features |

*Format may change in future versions

## ๐Ÿ” Format Change Detection

The framework automatically detects:

### Binary Format Changes
- Magic bytes modifications
- Header structure changes
- Metadata format evolution
- Compression algorithm updates

### Compatibility Impact Assessment
- **Fully Compatible**: No parser changes needed
- **Backward Compatible**: New features, old parsing works
- **Requires Update**: Parser modifications needed
- **Breaking**: Incompatible changes

### Example Detection

```bash
# Detect changes in new SSTable files
./compatibility_checker.sh detect --sstable-dir ./new-version-data --baseline 4.0

# Output:
๐Ÿ” Format changes detected:
  - โœ… New compression type: ZSTD
  - ๐ŸŸก Enhanced metadata format
  - โš ๏ธ Modified statistics layout (requires parser update)
```

## ๐Ÿšจ Automated Monitoring

### CI/CD Integration

The framework includes a GitHub Actions workflow (`.github/workflows/cassandra-compatibility.yml`) that:

1. **Runs on every push/PR** - Catch compatibility issues early
2. **Daily scheduled runs** - Detect new Cassandra releases
3. **Matrix testing** - Parallel testing of all versions
4. **Automatic reporting** - PR comments with results
5. **Documentation updates** - Auto-update compatibility status

### Continuous Monitoring

```bash
# Monitor compatibility every 24 hours
./compatibility_checker.sh --monitor 24h --webhook "https://hooks.slack.com/..."

# Custom monitoring intervals
./compatibility_checker.sh --monitor 1h    # Hourly
./compatibility_checker.sh --monitor 7d    # Weekly
```

### Notifications

Set up notifications for compatibility issues:

```bash
# Slack webhook
export WEBHOOK_URL="https://hooks.slack.com/services/..."

# Email notifications (via webhook service)
export WEBHOOK_URL="https://api.mailgun.com/v3/..."
```

## ๐Ÿ“ˆ Performance Monitoring

### Metrics Tracked

- **Parsing Speed**: Rows per second
- **Memory Usage**: Peak and average consumption
- **File Size**: SSTable compression ratios
- **Query Performance**: Execution time comparisons

### Regression Detection

The framework automatically identifies:

- Parsing speed degradation > 20%
- Memory usage increases > 50%
- Query performance regressions > 30%

### Performance Reports

```json
{
  "version": "5.1",
  "performance_metrics": {
    "parsing_time_ms": 1250,
    "memory_usage_mb": 45.2,
    "throughput_rows_per_sec": 8000.0,
    "baseline_comparison": 0.95
  }
}
```

## ๐Ÿ”ง Configuration

### Environment Variables

```bash
# Test configuration
export DEFAULT_TEST_SUITE=comprehensive
export OUTPUT_DIR=./results
export CASSANDRA_VERSIONS=4.0,4.1,5.0,5.1

# Performance thresholds
export MIN_COMPATIBILITY_SCORE=95
export PERFORMANCE_THRESHOLD=0.8

# Monitoring
export MONITOR_INTERVAL=24h
export WEBHOOK_URL=https://hooks.slack.com/...
```

### Docker Configuration

```yaml
# tests/compatibility/docker/docker-compose.yml
services:
  cassandra-4-0:
    image: cassandra:4.0
    ports: ["9042:9042"]
  cassandra-5-1:
    image: cassandra:5.1
    ports: ["9045:9042"]
```

## ๐Ÿ“Š Report Formats

### JSON (Machine-readable)
```bash
./compatibility_checker.sh --matrix --format json
```

### Markdown (Human-readable)
```bash
./compatibility_checker.sh --matrix --format markdown
```

### Dashboard (Web-friendly)
```bash
# Generates compatibility-dashboard.md
./compatibility_checker.sh --matrix
```

## ๐Ÿšจ Troubleshooting

### Common Issues

#### Docker Permission Errors
```bash
# Add user to docker group
sudo usermod -aG docker $USER
# Re-login or restart terminal
```

#### Cassandra Startup Timeouts
```bash
# Increase Docker memory
# Docker Desktop > Settings > Resources > Memory: 4GB+

# Check container logs
docker logs cassandra-5.1
```

#### Port Conflicts
```bash
# Check if ports are in use
lsof -i :9042

# Use custom ports
./compatibility_checker.sh --version 5.1 --port 9999
```

### Debug Mode

```bash
# Enable verbose output
./compatibility_checker.sh --version 5.1 --verbose

# Keep containers running for debugging
./compatibility_checker.sh --version 5.1 --no-cleanup
```

## ๐Ÿ› ๏ธ Development

### Adding New Cassandra Versions

1. **Update version lists**:
```rust
// src/version_manager.rs
supported_versions: vec![
    "4.0".to_string(),
    "4.1".to_string(),
    "5.0".to_string(),
    "5.1".to_string(),
    "6.0".to_string(),  // Add new version
],
```

2. **Update Docker Compose**:
```yaml
# docker/docker-compose.yml
cassandra-6-0:
  image: cassandra:6.0
  ports: ["9046:9042"]
```

3. **Update CI workflow**:
```yaml
# .github/workflows/cassandra-compatibility.yml
matrix:
  include: [4.0, 4.1, 5.0, 5.1, 6.0]  # Add new version
```

### Adding New Test Cases

```rust
// src/data_generator.rs
fn generate_new_feature_test_cases(&self) -> Vec<TestCase> {
    vec![
        TestCase {
            name: "new_feature_test".to_string(),
            description: "Test new Cassandra feature".to_string(),
            insert_statements: vec![
                "CREATE TABLE test.new_feature (id UUID PRIMARY KEY, data NEW_TYPE)".to_string(),
            ],
            complexity_level: ComplexityLevel::Complex,
            cassandra_version_min: "6.0".to_string(),
        },
    ]
}
```

## ๐ŸŽฏ Future Enhancements

### Planned Features

1. **๐Ÿค– AI-Powered Analysis**
   - Automatic issue classification
   - Suggested parser fixes
   - Compatibility prediction

2. **๐Ÿ“Š Advanced Analytics**
   - Trend analysis
   - Compatibility scoring evolution
   - Performance forecasting

3. **๐Ÿ”— Integration Expansions**
   - DataStax Enterprise versions
   - ScyllaDB compatibility
   - Custom Cassandra builds

4. **โšก Performance Optimizations**
   - Parallel format analysis
   - Incremental testing
   - Smart test selection

## ๐Ÿค Contributing

### Running Tests

```bash
# Unit tests
cd tests/compatibility
cargo test

# Integration tests
./scripts/compatibility_checker.sh --version 4.0 --test-suite basic

# Full test suite
./scripts/compatibility_checker.sh --matrix --test-suite comprehensive
```

### Code Style

```bash
# Format code
cargo fmt

# Lint
cargo clippy

# Documentation
cargo doc --open
```

## ๐Ÿ“š Resources

- **Documentation**: `tests/compatibility/README.md`
- **Configuration**: `tests/compatibility/.env`
- **Scripts**: `tests/compatibility/scripts/`
- **Results**: `tests/compatibility/results/`
- **Docker Setup**: `tests/compatibility/docker/`

## ๐Ÿ“ž Support

- **Issues**: Create GitHub issues for bugs or feature requests
- **Discussions**: Use GitHub Discussions for questions
- **Documentation**: Check inline code documentation
- **CI Status**: Monitor GitHub Actions for compatibility status

---

This compatibility testing framework ensures CQLite stays compatible with Cassandra's evolution, providing confidence for users and maintainers alike! ๐Ÿš€