Skip to content

Commit ece5c77

Browse files
test(integrationtests): increase SDK key expiry margin and big-segment sync timeout (#711)
Reduces flaky Integration Tests - staging failures by relaxing two timing constants only in tests—no production Relay behavior changes. In testSDKKeyExpires, the deprecated-key grace period is increased from 5s to 30s so sequential rotateSDKKeys calls (one per environment) still send a future expiry to staging after CI latency and clock skew; the test still sleeps only until keys expire before asserting cleanup. In verifyEvaluationWithBigSegment, the assert.Eventually poll window is increased from 20s to 60s so a second big-segment update can propagate via streaming in slow environments; passing runs still exit as soon as evaluations match.
1 parent 33cbf23 commit ece5c77

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

integrationtests/big_segments_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ func verifyEvaluationWithBigSegment(
110110
// Poll the evaluation endpoint until we see the expected flag values. We're using a
111111
// longer timeout here than we use in tests that don't involve big segments, because
112112
// the user segment state caching inside the SDK makes it hard to say how soon we'll
113-
// see the effect of an update.
113+
// see the effect of an update. 60s gives enough headroom for streaming propagation
114+
// of a second segment update to complete in staging CI environments.
114115
success := assert.Eventually(t, func() bool {
115116
ok := true
116117
for i, env := range environments {
@@ -125,7 +126,7 @@ func verifyEvaluationWithBigSegment(
125126
}
126127
}
127128
return ok
128-
}, time.Second*20, time.Millisecond*100, "Did not see expected flag values from Relay")
129+
}, time.Second*60, time.Millisecond*100, "Did not see expected flag values from Relay")
129130

130131
if !success {
131132
manager.loggers.Infof("EXPLANATION OF TEST FAILURE FOLLOWS:")

integrationtests/offline_mode_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,11 @@ func testSDKKeyExpires(t *testing.T, manager *integrationTestManager) {
168168
fileName := "archive.tar.gz"
169169
filePath := filepath.Join(manager.relaySharedDir, fileName)
170170

171-
const keyGracePeriod = 5 * time.Second
171+
// 30s gives plenty of margin for multiple sequential staging API calls to succeed
172+
// even with round-trip latency and clock skew between the CI runner and staging.
173+
// Previously 5s was too tight: the second rotateSDKKey call could arrive at staging
174+
// with an expiry at-or-before "now", causing a 400 Bad Request.
175+
const keyGracePeriod = 30 * time.Second
172176
// Relay will check for expired keys at this interval.
173177
const cleanupInterval = 100 * time.Millisecond
174178

0 commit comments

Comments
 (0)