@@ -604,15 +604,40 @@ def start_server():
604604 with open (client_log_path , "r" ) as f :
605605 loss_log = f .read ()
606606
607- if (
608- "disconnected" in loss_log
609- or "Connection lost" in loss_log
610- or "Reconnecting" in loss_log
611- ):
607+ if "Connection lost" in loss_log :
612608 print ("✓ Phase 2: Client detected connection loss" )
613609 else :
614610 print ("⚠ Phase 2: Client may not have detected loss (checking Phase 3)" )
615611
612+ # Verify client does NOT falsely report successful reconnection while server is down
613+ # Split log into lines after "Connection lost" to check behavior during downtime
614+ loss_idx = loss_log .find ("Connection lost" )
615+ if loss_idx >= 0 :
616+ downtime_log = loss_log [loss_idx :]
617+ false_reconnects = downtime_log .count ("Reconnected successfully" )
618+ if false_reconnects > 0 :
619+ print (
620+ f"✗ Phase 2: Client falsely reported 'Reconnected successfully' { false_reconnects } time(s) while server was down"
621+ )
622+ test_results ["transmission" ]["reconnect" ] = False
623+ return False
624+ else :
625+ print ("✓ Phase 2: No false reconnection reports during server downtime" )
626+
627+ # Verify client shows disconnected status (not connected) during downtime
628+ downtime_stats = [l for l in downtime_log .splitlines () if "[STATS]" in l ]
629+ false_connected = [l for l in downtime_stats if "Status: connected" in l ]
630+ if false_connected :
631+ print (
632+ f"✗ Phase 2: Client reported 'connected' status { len (false_connected )} time(s) while server was down"
633+ )
634+ test_results ["transmission" ]["reconnect" ] = False
635+ return False
636+ else :
637+ print (
638+ "✓ Phase 2: Client correctly reported disconnected status during downtime"
639+ )
640+
616641 # Phase 3: Restart server, verify client reconnects and resumes traffic
617642 print ("[RECONN] Phase 3: Restarting server..." )
618643 server_proc = start_server ()
@@ -644,33 +669,36 @@ def start_server():
644669 test_results ["transmission" ]["reconnect" ] = False
645670 return False
646671
647- # Check if the last few stats lines show data reception
672+ # Verify "Reconnected successfully" appears after server restart
673+ # (should only appear now, not during Phase 2 downtime)
674+ has_reconnected_msg = "Reconnected successfully" in full_log
675+ if has_reconnected_msg :
676+ print ("✓ Phase 3: Client reported successful reconnection" )
677+ else :
678+ print ("✗ Phase 3: Client never reported 'Reconnected successfully'" )
679+ test_results ["transmission" ]["reconnect" ] = False
680+ return False
681+
682+ # Check the last few stats lines show connected status and data flow
648683 last_stats = stats_lines [- 3 :]
684+ has_connected_status = any ("Status: connected" in l for l in last_stats )
649685 recovered = False
650686 for line in last_stats :
651687 rx_match = re .search (r"Rx:\s*([0-9.]+)\s*Mbps" , line )
652688 if rx_match and float (rx_match .group (1 )) > 0.1 :
653689 recovered = True
654690 break
655691
656- # Also check for connected status in recent lines
657- has_connected_status = any (
658- "connected" in l and "disconnected" not in l
659- for l in full_log .splitlines ()[- 10 :]
660- if "[STATS]" in l
661- )
662-
663- # Check for reconnection log messages
664- has_reconnect_msg = "Reconnect" in full_log or "Registration sent" in full_log
665-
666- if recovered or has_connected_status :
667- print ("✓ Phase 3: Client reconnected and resumed receiving data" )
692+ if has_connected_status and recovered :
693+ print ("✓ Phase 3: Client connected and receiving data after recovery" )
668694 test_results ["transmission" ]["reconnect" ] = True
669695 success = True
670- elif has_reconnect_msg :
671- print (
672- "✓ Phase 3: Client attempted reconnection (traffic may still be ramping up)"
673- )
696+ elif has_connected_status :
697+ print ("✓ Phase 3: Client connected (traffic still ramping up)" )
698+ test_results ["transmission" ]["reconnect" ] = True
699+ success = True
700+ elif recovered :
701+ print ("✓ Phase 3: Client receiving data after recovery" )
674702 test_results ["transmission" ]["reconnect" ] = True
675703 success = True
676704 else :
0 commit comments