summaryrefslogtreecommitdiff
path: root/src/test/java/testing
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-06-22 16:45:17 +0300
committerPaul Buetow <paul@buetow.org>2025-06-22 16:45:17 +0300
commit4c16cc3c4da7bbf8375d7951185db1761eb396bf (patch)
tree19199b664ce802ed3e967e318e6d4ffeb8c9bf39 /src/test/java/testing
parent464df52901e2dcb84eb81a22f2db19cbf17e5a9f (diff)
Remove all Raft protocol code
Removed all Raft-related code as it was not working properly: - Removed VSRaftProtocol.java implementation - Removed all Raft test files - Removed Raft example/demo files - Removed Raft documentation - Removed Raft simulation files (.dat) - Removed Raft scripts - Updated VSRegisteredEvents to remove Raft registration - Updated SimulationBuilder to remove RAFT constant - Updated SimulationFactory to remove Raft methods - Updated SimulationBuilderTest to remove Raft tests - Updated pom.xml to remove Raft test configurations The protocol had issues with leader election not completing in GUI mode. 🤖 Generated with Claude Code https://claude.ai/code Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'src/test/java/testing')
-rw-r--r--src/test/java/testing/RaftSimulationTest.java57
-rw-r--r--src/test/java/testing/protocols/RaftProtocolTest.java77
2 files changed, 0 insertions, 134 deletions
diff --git a/src/test/java/testing/RaftSimulationTest.java b/src/test/java/testing/RaftSimulationTest.java
deleted file mode 100644
index b161668..0000000
--- a/src/test/java/testing/RaftSimulationTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package testing;
-
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.BeforeEach;
-import prefs.VSDefaultPrefs;
-import events.VSRegisteredEvents;
-
-import static org.junit.jupiter.api.Assertions.*;
-
-/**
- * Integration test for Raft protocol simulation.
- * Tests that leader election occurs when running a Raft simulation.
- */
-class RaftSimulationTest {
-
- private VSDefaultPrefs prefs;
-
- @BeforeEach
- void setUp() {
- prefs = new VSDefaultPrefs();
- prefs.fillWithDefaults();
- VSRegisteredEvents.init(prefs);
- }
-
- @Test
- void testRaftLeaderElection() throws Exception {
- // This test verifies that the Raft protocol implementation
- // properly elects a leader when running
-
- // For now, we verify the protocol can be instantiated and initialized
- Object raftObj = new utils.VSClassLoader().newInstance("protocols.implementations.VSRaftProtocol");
- assertNotNull(raftObj, "Raft protocol should be instantiable");
- assertTrue(raftObj instanceof protocols.VSAbstractProtocol, "Should be a protocol");
-
- // Verify the protocol has the correct classname set
- protocols.implementations.VSRaftProtocol raftProtocol =
- (protocols.implementations.VSRaftProtocol) raftObj;
- assertNotNull(raftProtocol.getClassname(),
- "Protocol classname should be set");
- assertTrue(raftProtocol.getClassname().contains("VSRaftProtocol"),
- "Protocol classname should contain VSRaftProtocol");
- }
-
- @Test
- void testRaftProtocolRegistration() {
- // Verify Raft protocol is properly registered
- assertTrue(VSRegisteredEvents.getProtocolClassnames().contains(
- "protocols.implementations.VSRaftProtocol"),
- "Raft protocol should be registered");
-
- // Verify it has a proper display name (this is set in lang properties)
- String shortName = VSRegisteredEvents.getShortnameByClassname(
- "protocols.implementations.VSRaftProtocol");
- assertNotNull(shortName, "Raft protocol should have a short name");
- assertEquals("Raft Consensus", shortName);
- }
-} \ No newline at end of file
diff --git a/src/test/java/testing/protocols/RaftProtocolTest.java b/src/test/java/testing/protocols/RaftProtocolTest.java
deleted file mode 100644
index b92606d..0000000
--- a/src/test/java/testing/protocols/RaftProtocolTest.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package testing.protocols;
-
-import testing.*;
-import org.junit.jupiter.api.*;
-import static org.junit.jupiter.api.Assertions.*;
-
-/**
- * Integration test for Raft consensus protocol.
- */
-public class RaftProtocolTest extends BaseProtocolTest {
-
- @Test
- @DisplayName("Test Raft protocol activation and message sending")
- public void testRaftActivation() {
- SimulationResult result = runSimulation(
- "saved-simulations/raft.dat",
- 2000 // 2 seconds should be enough for elections
- );
-
- ProtocolVerifier verifier = new ProtocolVerifier()
- .expectLogExactly("Raft Consensus Server activated", 3)
- .expectLog("FOLLOWER.*initialized")
- .expectLog("Starting election")
- .expectLog("CANDIDATE")
- .expectMessages() // Must have messages
- .expectAtLeastNMessages(10); // Should have many election messages
-
- VerificationResult verification = verifier.verify(result.getAllLogs());
-
- assertTrue(verification.passed(), verification.getFailureMessage());
- assertEquals(3, result.getMetrics().getNumProcesses(),
- "Should have 3 processes");
- }
-
- @Test
- @DisplayName("Test Raft election messages")
- public void testRaftElectionMessages() {
- SimulationResult result = runSimulation(
- "saved-simulations/raft.dat",
- 3000
- );
-
- ProtocolVerifier verifier = new ProtocolVerifier()
- .expectLog("REQUEST_VOTE")
- .expectLog("Message sent.*REQUEST_VOTE")
- .expectAtLeastNMessages(15); // Multiple election rounds
-
- VerificationResult verification = verifier.verify(result.getAllLogs());
- assertTrue(verification.passed(), verification.getFailureMessage());
-
- // Verify term progression
- assertTrue(result.findFirst("term=1").isPresent(), "Should have term 1");
- assertTrue(result.findFirst("term=2").isPresent(), "Should progress to term 2");
- }
-
- @Test
- @DisplayName("Test Raft with clients")
- public void testRaftWithClients() {
- // Skip if file doesn't exist
- if (!new java.io.File("saved-simulations/raft-with-clients.dat").exists()) {
- return;
- }
-
- SimulationResult result = runSimulation(
- "saved-simulations/raft-with-clients.dat",
- 5000
- );
-
- ProtocolVerifier verifier = new ProtocolVerifier()
- .expectLogExactly("Raft Consensus Server activated", 3)
- .expectLogExactly("Raft Consensus Client activated", 2)
- .expectMessages(); // Must have messages
-
- VerificationResult verification = verifier.verify(result.getAllLogs());
- assertTrue(verification.passed(), verification.getFailureMessage());
- }
-} \ No newline at end of file