diff options
| author | Paul Buetow <paul@buetow.org> | 2025-06-21 15:54:07 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-06-21 15:54:07 +0300 |
| commit | d3b697218773eaa5a3dd368705184726dbc0fa38 (patch) | |
| tree | e466fb78829c957f70e88ab92651896b49120856 /src/test/java/testing/protocols/BaseProtocolTest.java | |
| parent | dedec9b18bafa2bcfdb05429f717f95f2236d811 (diff) | |
Implement headless testing framework for DS-Sim protocol simulations
- Created HeadlessSimulationRunner that loads and runs simulations without GUI
- Implemented LogCapture to intercept and store all simulation logs
- Added ProtocolVerifier for flexible pattern-based log verification
- Created test runners: standard, with logs, and clean (filters GUI errors)
- Implemented tests for all non-Raft protocols
- Added DummySimulatorFrame to satisfy GUI dependencies during loading
- Created CleanHeadlessRunner that filters GUI-related errors from output
- Updated run-tests.sh script with quiet mode option
- Documented the framework architecture and usage
The framework successfully runs protocol tests and verifies behavior through
log analysis. GUI errors occur internally due to tight coupling in DS-Sim
but are filtered in quiet mode for clean output.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'src/test/java/testing/protocols/BaseProtocolTest.java')
| -rw-r--r-- | src/test/java/testing/protocols/BaseProtocolTest.java | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/test/java/testing/protocols/BaseProtocolTest.java b/src/test/java/testing/protocols/BaseProtocolTest.java new file mode 100644 index 0000000..e9cbc81 --- /dev/null +++ b/src/test/java/testing/protocols/BaseProtocolTest.java @@ -0,0 +1,45 @@ +package testing.protocols; + +import testing.*; +import org.junit.jupiter.api.*; + +/** + * Base class for protocol tests providing common setup and utilities. + */ +public abstract class BaseProtocolTest { + protected HeadlessSimulationRunner runner; + + @BeforeEach + public void baseSetup() { + runner = new HeadlessSimulationRunner(); + } + + @AfterEach + public void baseTeardown() { + if (runner != null) { + runner.shutdown(); + } + } + + /** + * Run a simulation and get the result with error handling. + */ + protected SimulationResult runSimulation(String file, long duration) { + try { + return runner.runSimulation(file, duration); + } catch (Exception e) { + throw new RuntimeException("Failed to run simulation: " + file, e); + } + } + + /** + * Create a basic verifier that checks for no errors. + */ + protected ProtocolVerifier createBasicVerifier() { + return new ProtocolVerifier() + .expectNoLog("ERROR") + .expectNoLog("Exception") + .expectNoLog("null") + .expectNoLog("NullPointer"); + } +}
\ No newline at end of file |
