summaryrefslogtreecommitdiff
path: root/src/main/java/testing/LogEntry.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/LogEntry.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/LogEntry.java')
-rw-r--r--src/main/java/testing/LogEntry.java73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/main/java/testing/LogEntry.java b/src/main/java/testing/LogEntry.java
new file mode 100644
index 0000000..6bb2ac7
--- /dev/null
+++ b/src/main/java/testing/LogEntry.java
@@ -0,0 +1,73 @@
+package testing;
+
+/**
+ * Represents a single log entry captured during simulation execution.
+ * Immutable data class for thread-safe log collection.
+ */
+public class LogEntry {
+ private final long timestamp;
+ private final String message;
+ private final LogType type;
+ private final int processNum;
+
+ public LogEntry(long timestamp, String message, LogType type, int processNum) {
+ this.timestamp = timestamp;
+ this.message = message;
+ this.type = type;
+ this.processNum = processNum;
+ }
+
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public LogType getType() {
+ return type;
+ }
+
+ public int getProcessNum() {
+ return processNum;
+ }
+
+ public boolean isFromProcess(int processNum) {
+ return this.processNum == processNum;
+ }
+
+ public boolean isGlobal() {
+ return type == LogType.GLOBAL;
+ }
+
+ @Override
+ public String toString() {
+ if (type == LogType.PROCESS) {
+ return String.format("[%d] Process %d: %s", timestamp, processNum, message);
+ } else {
+ return String.format("[%d] %s", timestamp, message);
+ }
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ LogEntry logEntry = (LogEntry) o;
+ return timestamp == logEntry.timestamp &&
+ processNum == logEntry.processNum &&
+ type == logEntry.type &&
+ message.equals(logEntry.message);
+ }
+
+ @Override
+ public int hashCode() {
+ int result = Long.hashCode(timestamp);
+ result = 31 * result + message.hashCode();
+ result = 31 * result + type.hashCode();
+ result = 31 * result + processNum;
+ return result;
+ }
+} \ No newline at end of file