summaryrefslogtreecommitdiff
path: root/src/main/java/testing/LogCapture.java
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-06-22 11:58:00 +0300
committerPaul Buetow <paul@buetow.org>2025-06-22 11:58:00 +0300
commit0b5afe8839241dec66ba832cf42860ec69b87df8 (patch)
treee100d2d6204f8c04dc33418ae9f193fa6b1a83c2 /src/main/java/testing/LogCapture.java
parentb0fc02ce45cb51ce7c8d607d4773808cfa9b6c87 (diff)
Fix message delivery in headless test environment
- Fixed HeadlessSimulationEngine to use correct task manager from receiving process - Reduced message delays for testing (10-50ms instead of 500-2000ms) - Fixed process ID method call (getProcessID not getProcessId) - Improved message delivery scheduling to ensure tasks go to the right task manager This resolves message delivery issues where messages were sent but not received. BasicMulticast test now passes, but 12 protocol tests still failing. 🤖 Generated with Claude Code https://claude.ai/code Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'src/main/java/testing/LogCapture.java')
-rw-r--r--src/main/java/testing/LogCapture.java29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/main/java/testing/LogCapture.java b/src/main/java/testing/LogCapture.java
index 97bb127..ddd0ad0 100644
--- a/src/main/java/testing/LogCapture.java
+++ b/src/main/java/testing/LogCapture.java
@@ -30,6 +30,17 @@ public class LogCapture extends VSLogging {
this.printLogs = printLogs;
}
+ public void setSimulatorCanvas(VSSimulatorVisualization viz) {
+ // Store reference for process count
+ try {
+ Field field = VSLogging.class.getDeclaredField("simulatorVisualization");
+ field.setAccessible(true);
+ field.set(this, viz);
+ } catch (Exception e) {
+ // Ignore
+ }
+ }
+
public void setLogPrefix(String prefix) {
this.logPrefix = prefix;
}
@@ -136,9 +147,23 @@ public class LogCapture extends VSLogging {
public Map<Integer, Integer> getProcessMessageCounts() {
Map<Integer, Integer> counts = new HashMap<>();
- for (Map.Entry<Integer, List<LogEntry>> entry : processLogs.entrySet()) {
- counts.put(entry.getKey(), entry.getValue().size());
+
+ // Initialize counts for all processes
+ VSSimulatorVisualization viz = getSimulatorVisualization();
+ if (viz != null) {
+ for (int i = 0; i < viz.getNumProcesses(); i++) {
+ counts.put(i, 0);
+ }
}
+
+ // Count messages from all captured logs
+ for (LogEntry log : capturedLogs) {
+ if (log.getMessage().contains("Message sent")) {
+ int processNum = log.getProcessNum();
+ counts.put(processNum, counts.getOrDefault(processNum, 0) + 1);
+ }
+ }
+
return counts;
}