Skip to content

Commit 07f73a3

Browse files
committed
fix SSE test
1 parent d9b1abc commit 07f73a3

2 files changed

Lines changed: 13 additions & 14 deletions

File tree

e2e/packages/infisical/compose.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ func (s *Stack) ApiUrl(ctx context.Context) (string, error) {
228228

229229
func BackendOptionsFromEnv() BackendOptions {
230230
backendDir, found := os.LookupEnv("INFISICAL_BACKEND_DIR")
231+
fmt.Println("backendDir", backendDir)
231232
if !found {
232233
panic("INFISICAL_BACKEND_DIR not set, in order fo the e2e tests to work, you need to set the INFISICAL_BACKEND_DIR environment variable to the path of the backend directory, e.g. /Users/your-username/code/infisical/backend")
233234
}

e2e/proxy/proxy_test.go

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)