blob: 9ea907dcf92cca4062baa2ae37ff45c05ade85ef (
plain)
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
|
# DS-Sim Testing Framework Usage
## Overview
The DS-Sim testing framework provides headless testing capabilities for protocol simulations without requiring GUI components.
## Quick Start
Run all protocol tests:
```bash
./run-tests.sh
```
## Test Runners
### 1. Standard Test Runner (with logs)
Shows test results with protocol logs:
```bash
java -cp target/classes testing.ProtocolTestRunnerWithLogs
```
### 2. Quiet Test Runner
Filters out GUI-related errors for cleaner output:
```bash
java -cp target/classes testing.QuietProtocolTestRunner
# or
./run-tests.sh -q
```
### 3. Verbose Test Runner
Shows detailed logs for debugging:
```bash
java -cp target/classes testing.ProtocolTestRunner -v
# or
./run-tests.sh -v
```
## Running Specific Tests
To run tests programmatically:
```java
HeadlessSimulationRunner runner = new HeadlessSimulationRunner();
runner.setPrintLogs(true); // Enable log output
SimulationResult result = runner.runSimulation(
"saved-simulations/ping-pong.dat",
2000 // Duration in ms
);
// Verify results
ProtocolVerifier verifier = new ProtocolVerifier()
.expectLog("Ping-Pong.*activated")
.expectLog("Message sent")
.expectNoLog("ERROR");
VerificationResult verification = verifier.verify(result.getAllLogs());
System.out.println("Test passed: " + verification.passed());
```
## Test Coverage
The framework tests all non-Raft protocols:
- Ping-Pong
- Ping-Pong Sturm
- Broadcast
- Basic Multicast
- Reliable Multicast
- Berkeley Time Sync
- Internal Time Sync
- External vs Internal Sync
- One-Phase Commit
- Two-Phase Commit
- Slow Connection
## Known Limitations
- Some GUI-related errors may appear due to DS-Sim's tight coupling with visual components
- These errors don't affect test functionality
- Use quiet mode (`-q`) to filter them out
## Maven Integration
Run tests as part of the build:
```bash
mvn test
```
Note: Ensure Maven Surefire plugin is properly configured to discover test classes.
|