summaryrefslogtreecommitdiff
path: root/src/main/java/testing/examples/QuickTest.java
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-06-21 15:54:07 +0300
committerPaul Buetow <paul@buetow.org>2025-06-21 15:54:07 +0300
commitd3b697218773eaa5a3dd368705184726dbc0fa38 (patch)
treee466fb78829c957f70e88ab92651896b49120856 /src/main/java/testing/examples/QuickTest.java
parentdedec9b18bafa2bcfdb05429f717f95f2236d811 (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/main/java/testing/examples/QuickTest.java')
-rw-r--r--src/main/java/testing/examples/QuickTest.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/main/java/testing/examples/QuickTest.java b/src/main/java/testing/examples/QuickTest.java
new file mode 100644
index 0000000..f6f3e86
--- /dev/null
+++ b/src/main/java/testing/examples/QuickTest.java
@@ -0,0 +1,40 @@
+package testing.examples;
+
+import testing.*;
+
+public class QuickTest {
+ public static void main(String[] args) throws Exception {
+ // Use command line arg or default
+ String simulationFile = args.length > 0 ? args[0] : "saved-simulations/ping-pong.dat";
+ long duration = args.length > 1 ? Long.parseLong(args[1]) : 1000;
+
+ if (args.length == 0) {
+ System.out.println("=== Quick Headless Test ===\n");
+ }
+
+ HeadlessSimulationRunner runner = new HeadlessSimulationRunner();
+
+ try {
+ SimulationResult result = runner.runSimulation(
+ simulationFile,
+ duration
+ );
+
+ System.out.println("Captured " + result.getAllLogs().size() + " logs");
+ System.out.println("\nFirst 5 logs:");
+ result.getAllLogs().stream()
+ .limit(5)
+ .forEach(log -> System.out.println(" " + log));
+
+ // Simple verification
+ boolean hasActivation = result.countLogs("activated") > 0;
+ boolean hasMessages = result.countLogs("Message") > 0;
+
+ System.out.println("\nāœ“ Protocol activated: " + hasActivation);
+ System.out.println("āœ“ Messages exchanged: " + hasMessages);
+
+ } finally {
+ runner.shutdown();
+ }
+ }
+} \ No newline at end of file