From d3b697218773eaa5a3dd368705184726dbc0fa38 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 21 Jun 2025 15:54:07 +0300 Subject: Implement headless testing framework for DS-Sim protocol simulations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- src/main/java/examples/TestRaftLoading.java | 57 +++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/main/java/examples/TestRaftLoading.java (limited to 'src/main/java/examples/TestRaftLoading.java') diff --git a/src/main/java/examples/TestRaftLoading.java b/src/main/java/examples/TestRaftLoading.java new file mode 100644 index 0000000..ebad379 --- /dev/null +++ b/src/main/java/examples/TestRaftLoading.java @@ -0,0 +1,57 @@ +package examples; + +import events.VSRegisteredEvents; +import prefs.VSDefaultPrefs; +import java.util.Vector; + +/** + * Test if Raft protocol is properly registered and loadable + */ +public class TestRaftLoading { + public static void main(String[] args) { + // Initialize + VSDefaultPrefs prefs = new VSDefaultPrefs(); + prefs.fillWithDefaults(); + VSRegisteredEvents.init(prefs); + + // List all registered protocols + System.out.println("=== Registered Protocols ==="); + Vector protocolNames = VSRegisteredEvents.getProtocolNames(); + for (String name : protocolNames) { + String className = VSRegisteredEvents.getClassnameByEventname(name); + System.out.println(name + " -> " + className); + } + + System.out.println("\n=== Protocol Classnames ==="); + Vector protocolClassnames = VSRegisteredEvents.getProtocolClassnames(); + for (String className : protocolClassnames) { + String shortName = VSRegisteredEvents.getShortnameByClassname(className); + System.out.println(className + " (short: " + shortName + ")"); + } + + // Check Raft specifically + System.out.println("\n=== Raft Protocol Check ==="); + String raftClass = "protocols.implementations.VSRaftProtocol"; + String raftShortName = VSRegisteredEvents.getShortnameByClassname(raftClass); + String raftEventName = VSRegisteredEvents.getNameByClassname(raftClass); + + System.out.println("Class: " + raftClass); + System.out.println("Short name: " + raftShortName); + System.out.println("Event name: " + raftEventName); + + // Try to load the class + try { + Class clazz = Class.forName(raftClass); + System.out.println("Class loaded successfully: " + clazz.getName()); + + // Check if it's a protocol + if (protocols.VSAbstractProtocol.class.isAssignableFrom(clazz)) { + System.out.println("✓ Is a valid protocol class"); + } else { + System.out.println("✗ NOT a protocol class!"); + } + } catch (ClassNotFoundException e) { + System.out.println("✗ Class not found: " + e.getMessage()); + } + } +} \ No newline at end of file -- cgit v1.2.3