Skip to content

Commit 85301a9

Browse files
nan-yugoogle-oss-prow[bot]
authored andcommitted
test: tune the retryCap to stabalize the unit test (#920)
A 20ms retry cap seems not long enough for the test directories to be created, e.g.: https://oss.gprow.dev/view/gs/oss-prow-build-kpt-config-sync/pr-logs/pull/GoogleContainerTools_kpt-config-sync/918/kpt-config-sync-presubmit/1709704761911021568 1. started calling readHydratedDirWithRetry at 2023-10-04 23:02:16.385300841 2. retryied 6 times whithin 20ms ``` I1004 23:02:16.385422 17534 retry.go:75] failed to load the hydrated configs under /tmp/read-hydrated-dir-test3711104822/hydrated I1004 23:02:16.386681 17534 retry.go:75] failed to load the hydrated configs under /tmp/read-hydrated-dir-test3711104822/hydrated I1004 23:02:16.389097 17534 retry.go:75] failed to load the hydrated configs under /tmp/read-hydrated-dir-test3711104822/hydrated I1004 23:02:16.394563 17534 retry.go:75] failed to load the hydrated configs under /tmp/read-hydrated-dir-test3711104822/hydrated I1004 23:02:16.403944 17534 retry.go:75] failed to load the hydrated configs under /tmp/read-hydrated-dir-test3711104822/hydrated ``` 3. sync directory created 68ms later: sync directory "/tmp/read-hydrated-dir-test3711104822/hydrated/1234567890abcde/configs" created at 2023-10-04 23:02:16.453810924 4. symlink created 69ms later: symlink "/tmp/read-hydrated-dir-test3711104822/hydrated/rev" created and linked to "/tmp/read-hydrated-dir-test3711104822/hydrated/1234567890abcde" at 2023-10-04 23:02:16.454404483 This commit increases the cap from 20ms to 100ms.
1 parent 3261cb7 commit 85301a9

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

pkg/hydrate/controller_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func TestSourceCommitAndDirWithRetry(t *testing.T) {
5959
},
6060
{
6161
name: "source root directory created within the retry cap",
62-
retryCap: 20 * time.Millisecond,
62+
retryCap: 100 * time.Millisecond,
6363
srcRootCreateLatency: 5 * time.Millisecond,
6464
expectedSourceCommit: commit,
6565
},
@@ -71,26 +71,26 @@ func TestSourceCommitAndDirWithRetry(t *testing.T) {
7171
},
7272
{
7373
name: "symlink created within the retry cap",
74-
retryCap: 20 * time.Millisecond,
74+
retryCap: 100 * time.Millisecond,
7575
symlinkCreateLatency: 5 * time.Millisecond,
7676
expectedSourceCommit: commit,
7777
},
7878
{
7979
name: "error file exists with empty content",
80-
retryCap: 10 * time.Millisecond,
80+
retryCap: 100 * time.Millisecond,
8181
errFileExists: true,
8282
expectedErrMsg: "is empty. Please check git-sync logs for more info",
8383
},
8484
{
8585
name: "error file exists with non-empty content",
86-
retryCap: 10 * time.Millisecond,
86+
retryCap: 100 * time.Millisecond,
8787
errFileExists: true,
8888
errFileContent: "git-sync error",
8989
expectedErrMsg: "git-sync error",
9090
},
9191
{
9292
name: "sync directory doesn't exist",
93-
retryCap: 10 * time.Millisecond,
93+
retryCap: 100 * time.Millisecond,
9494
syncDir: "unknown",
9595
expectedErrMsg: "failed to evaluate the config directory",
9696
},

pkg/parse/run_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ func TestRun(t *testing.T) {
192192
{
193193
id: "1",
194194
name: "source commit directory created within the retry cap",
195-
retryCap: 20 * time.Millisecond,
195+
retryCap: 100 * time.Millisecond,
196196
srcRootCreateLatency: 5 * time.Millisecond,
197197
needRetry: false,
198198
expectedMsg: "Sync Completed",

pkg/parse/source_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,20 +164,20 @@ func TestReadHydratedDirWithRetry(t *testing.T) {
164164
{
165165
name: "symlink created within the retry cap",
166166
commit: originCommit,
167-
retryCap: 20 * time.Millisecond,
167+
retryCap: 100 * time.Millisecond,
168168
symlinkCreateLatency: 5 * time.Millisecond,
169169
expectedCommit: originCommit,
170170
},
171171
{
172172
name: "error file exists",
173-
retryCap: 10 * time.Millisecond,
173+
retryCap: 100 * time.Millisecond,
174174
hydrationErr: `{"code": "1068", "error": "actionable-error"}`,
175175
expectedErrMsg: "actionable-error",
176176
expectedErrCode: status.ActionableHydrationErrorCode,
177177
},
178178
{
179179
name: "sync directory doesn't exist",
180-
retryCap: 10 * time.Millisecond,
180+
retryCap: 100 * time.Millisecond,
181181
commit: originCommit,
182182
syncDir: "unknown",
183183
expectedErrMsg: "failed to evaluate symbolic link to the hydrated sync directory",

0 commit comments

Comments
 (0)