Skip to content

Commit

Permalink
test: tune the retryCap to stabalize the unit test (#920)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nan-yu authored and google-oss-prow[bot] committed Oct 5, 2023
1 parent 3261cb7 commit 85301a9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions pkg/hydrate/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestSourceCommitAndDirWithRetry(t *testing.T) {
},
{
name: "source root directory created within the retry cap",
retryCap: 20 * time.Millisecond,
retryCap: 100 * time.Millisecond,
srcRootCreateLatency: 5 * time.Millisecond,
expectedSourceCommit: commit,
},
Expand All @@ -71,26 +71,26 @@ func TestSourceCommitAndDirWithRetry(t *testing.T) {
},
{
name: "symlink created within the retry cap",
retryCap: 20 * time.Millisecond,
retryCap: 100 * time.Millisecond,
symlinkCreateLatency: 5 * time.Millisecond,
expectedSourceCommit: commit,
},
{
name: "error file exists with empty content",
retryCap: 10 * time.Millisecond,
retryCap: 100 * time.Millisecond,
errFileExists: true,
expectedErrMsg: "is empty. Please check git-sync logs for more info",
},
{
name: "error file exists with non-empty content",
retryCap: 10 * time.Millisecond,
retryCap: 100 * time.Millisecond,
errFileExists: true,
errFileContent: "git-sync error",
expectedErrMsg: "git-sync error",
},
{
name: "sync directory doesn't exist",
retryCap: 10 * time.Millisecond,
retryCap: 100 * time.Millisecond,
syncDir: "unknown",
expectedErrMsg: "failed to evaluate the config directory",
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/parse/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func TestRun(t *testing.T) {
{
id: "1",
name: "source commit directory created within the retry cap",
retryCap: 20 * time.Millisecond,
retryCap: 100 * time.Millisecond,
srcRootCreateLatency: 5 * time.Millisecond,
needRetry: false,
expectedMsg: "Sync Completed",
Expand Down
6 changes: 3 additions & 3 deletions pkg/parse/source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,20 +164,20 @@ func TestReadHydratedDirWithRetry(t *testing.T) {
{
name: "symlink created within the retry cap",
commit: originCommit,
retryCap: 20 * time.Millisecond,
retryCap: 100 * time.Millisecond,
symlinkCreateLatency: 5 * time.Millisecond,
expectedCommit: originCommit,
},
{
name: "error file exists",
retryCap: 10 * time.Millisecond,
retryCap: 100 * time.Millisecond,
hydrationErr: `{"code": "1068", "error": "actionable-error"}`,
expectedErrMsg: "actionable-error",
expectedErrCode: status.ActionableHydrationErrorCode,
},
{
name: "sync directory doesn't exist",
retryCap: 10 * time.Millisecond,
retryCap: 100 * time.Millisecond,
commit: originCommit,
syncDir: "unknown",
expectedErrMsg: "failed to evaluate symbolic link to the hydrated sync directory",
Expand Down

0 comments on commit 85301a9

Please sign in to comment.