Skip to content

Commit 33604b6

Browse files
committed
chore: test: remove shell version of meta-meta compat test
Remove shell-based compatibility test after migration to Python. Update README with comprehensive documentation for the Python implementation, including usage examples, test descriptions, and compatibility handling details.
1 parent f89f448 commit 33604b6

File tree

3 files changed

+74
-212
lines changed

3 files changed

+74
-212
lines changed

tests/compat/meta_meta/README.md

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,61 @@
11
# Test protocol compatibility between latest and old databend-meta
22

3+
Tests cross-version compatibility of databend-meta, ensuring new versions can communicate with old versions in a cluster.
4+
35
## Prerequisites
46

5-
- Current version of databend-meta must reside in `./bins`:
6-
- `./bins/current/databend-meta`
7+
- Current version binaries must exist in `./bins/current/bin/`:
8+
- `databend-meta`
9+
- `databend-metactl`
10+
- `databend-metabench`
11+
12+
Since building binaries takes several minutes, this is usually done by CI scripts.
13+
14+
## Usage
15+
16+
```bash
17+
python3 test_meta_meta.py <leader-version> <follower-version>
18+
```
19+
20+
Examples:
21+
```bash
22+
# Test current version with old version
23+
python3 test_meta_meta.py current 1.2.615
24+
25+
# Test two old versions
26+
python3 test_meta_meta.py 1.2.615 1.2.600
27+
```
28+
29+
The script automatically downloads old version binaries from GitHub releases if not present in `./bins/<version>/`.
30+
31+
## Tests
32+
33+
### test_snapshot_replication
34+
35+
Tests snapshot-based replication between versions:
36+
1. Start leader node, feed data
37+
2. Trigger snapshot, feed more data
38+
3. Start follower node (joins via snapshot)
39+
4. Verify state machine data consistency
40+
5. Re-import with current metactl and verify again
41+
42+
### test_vote_request
43+
44+
Tests vote request compatibility between versions:
45+
1. Start two-node cluster with different versions
46+
2. Feed data, restart cluster
47+
3. Feed more data, trigger snapshots
48+
4. Verify state machine data consistency
49+
50+
This test normalizes time precision differences:
51+
- `time_ms`: truncates last 3 digits to 000
52+
- `expire_at`: converts milliseconds to seconds
53+
54+
## Compatibility Handling
755

8-
Since building a binary takes several minutes,
9-
this step is usually done by the calling process, e.g., the CI script.
56+
The tests account for version differences:
57+
- **proposed_at_ms**: Removed during comparison (not present in all versions)
58+
- **Time precision**: Normalized in vote_request test (ms vs sec)
59+
- **DataHeader**: Excluded from comparison (contains version info)
60+
- **NodeId**: Excluded from re-import comparison
61+
- **Expire/GenericKV**: Excluded during re-import (format changed in V002)

tests/compat/meta_meta/test_meta_meta.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,30 @@
99
import platform
1010
import re
1111
import shutil
12+
import socket
1213
import subprocess
1314
import sys
1415
import time
1516
import urllib.request
1617
from pathlib import Path
1718

1819

20+
def wait_tcp_port(port: int, timeout: int = 20) -> None:
21+
"""Wait for TCP port to become available."""
22+
print(f" === Waiting for port {port} (timeout: {timeout}s)")
23+
start_time = time.time()
24+
while time.time() - start_time < timeout:
25+
try:
26+
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
27+
sock.settimeout(1)
28+
sock.connect(("127.0.0.1", port))
29+
print(f" === Port {port} is ready")
30+
return
31+
except (socket.error, socket.timeout):
32+
time.sleep(0.5)
33+
raise TimeoutError(f"Port {port} did not become available within {timeout} seconds")
34+
35+
1936
class TestContext:
2037
"""Test environment state and operations."""
2138

@@ -65,9 +82,7 @@ def start_node(self, version: str, node_id: int, extra_args: list[str], raft_dir
6582
print(f" === Running: {' '.join(cmd)}")
6683
subprocess.Popen(cmd)
6784

68-
wait_cmd = ["python3", str(self.root_dir / "scripts/ci/wait_tcp.py"), "--timeout", "20", "--port", str(11000 + node_id)]
69-
print(f" === Running: {' '.join(wait_cmd)}")
70-
subprocess.run(wait_cmd, check=True)
85+
wait_tcp_port(11000 + node_id, timeout=20)
7186
print(f" === databend-meta ver={version} id={node_id} started")
7287

7388
def feed_data(self, node_id: int, number: int = 10) -> None:

tests/compat/meta_meta/test_meta_meta.sh

Lines changed: 0 additions & 205 deletions
This file was deleted.

0 commit comments

Comments
 (0)