@@ -746,25 +746,24 @@ func TestProxy_SSEConnectionRecovery(t *testing.T) {
746746 }, 60 * time .Second , 200 * time .Millisecond , "Backend container should have restarted" )
747747 slog .Info ("Backend restarted" )
748748
749- // wait for SSE reconnection (second occurrence of "SSE connection established")
750- slog .Info ("Waiting for SSE reconnection" )
751- waitResult := helpers .WaitFor (t , helpers.WaitForOptions {
749+ // trigger normal client traffic so EnsureSubscription can recreate SSE if retries were exhausted
750+ slog .Info ("Fetching secrets after backend restart to trigger SSE re-subscription" )
751+ respAfterRestart := helper .GetSecretsWithProxy (ctx )
752+ require .Equal (t , http .StatusOK , respAfterRestart .StatusCode ())
753+
754+ // wait for SSE re-subscription after the fetch trigger
755+ slog .Info ("Waiting for SSE re-subscription after fetch trigger" )
756+ result = helpers .WaitForStderr (t , helpers.WaitForStderrOptions {
752757 EnsureCmdRunning : proxyCmd ,
758+ ExpectedString : "SSE connection established" ,
753759 Timeout : 120 * time .Second ,
754- Interval : 2 * time .Second ,
755- Condition : func () helpers.ConditionResult {
756- if strings .Count (proxyCmd .Stderr (), "SSE connection established" ) >= 2 {
757- return helpers .ConditionSuccess
758- }
759- return helpers .ConditionWait
760- },
761760 })
762- require .Equal (t , helpers .WaitSuccess , waitResult , "SSE should reconnect after backend restart" )
761+ require .Equal (t , helpers .WaitSuccess , result , "SSE should re-subscribe after backend restart and a trigger fetch " )
763762
764763 // verify proxy is still functional
765764 slog .Info ("Verifying proxy still works after SSE reconnection" )
766- resp2 := helper .GetSecretsWithProxy (ctx )
767- require .Equal (t , http .StatusOK , resp2 .StatusCode ())
765+ respAfterReconnect := helper .GetSecretsWithProxy (ctx )
766+ require .Equal (t , http .StatusOK , respAfterReconnect .StatusCode ())
768767
769768 require .True (t , proxyCmd .IsRunning (), "Proxy should still be running" )
770769
@@ -885,4 +884,3 @@ func TestProxy_SSEMultipleProjects(t *testing.T) {
885884 }
886885 require .True (t , foundOriginal , "Original secret not found in project 2" )
887886}
888-
0 commit comments