improve e2e resource cleanup#949
Conversation
|
zhao.yuxuan seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (10)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (9)
📝 WalkthroughWalkthroughCentralizes Drive deletion verification, standardizes per-test ChangesE2E Test Cleanup Standardization
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
8169174 to
d66f206
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
tests/cli_e2e/docs/docs_create_fetch_test.go (1)
29-35: ⚡ Quick winUse
defaultAsin bot fetch request as well.At Line 29, principal was centralized, but the bot fetch subtest still relies on implicit defaults. Making fetch explicit avoids environment-dependent flakiness.
Suggested fix
result, err := clie2e.RunCmd(ctx, clie2e.Request{ Args: []string{ "docs", "+fetch", "--doc", docToken, }, + DefaultAs: defaultAs, })🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/cli_e2e/docs/docs_create_fetch_test.go` around lines 29 - 35, The bot fetch subtest is still relying on implicit principal defaults; update the fetch call in the bot fetch subtest to explicitly pass the principal variable defaultAs (the same one used when creating the folder/doc) and the created docToken so the fetch request uses defaultAs rather than an environment default (ensure the fetch invocation in the "fetch" t.Run uses defaultAs and docToken, mirroring createDocWithRetry’s principal usage).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/cli_e2e/drive/helpers.go`:
- Around line 133-143: In IsDriveResourceDeleted, don’t assume ExitCode==0 means
success: parse the JSON envelope in result.Stdout (e.g., using gjson.Get on
fields like "ok" and "code") before treating an empty data.metas as proof of
deletion; if the envelope indicates failure (ok != true or code != 0) return an
error with the stdout/stderr instead of returning true, otherwise proceed to
inspect gjson.Get(result.Stdout, "data.metas").Array() as you do now.
In `@tests/cli_e2e/wiki/helpers_test.go`:
- Around line 232-234: When handling the pre-delete get_node result, don't treat
any non-zero exit as an unrecoverable failure; inspect getResult (specifically
getResult.ExitCode and getResult.Stderr/stdout) for "not found" / "already
deleted" semantics and treat those cases as success before returning. Update the
branch that currently does "if getResult.ExitCode != 0 { return getResult, nil
}" to check for those phrases (or use a small helper like isNotFound(getResult))
and only return a failure for other errors, otherwise proceed as a successful
cleanup.
---
Nitpick comments:
In `@tests/cli_e2e/docs/docs_create_fetch_test.go`:
- Around line 29-35: The bot fetch subtest is still relying on implicit
principal defaults; update the fetch call in the bot fetch subtest to explicitly
pass the principal variable defaultAs (the same one used when creating the
folder/doc) and the created docToken so the fetch request uses defaultAs rather
than an environment default (ensure the fetch invocation in the "fetch" t.Run
uses defaultAs and docToken, mirroring createDocWithRetry’s principal usage).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: dfa99463-c1aa-41be-b0c6-22cca156f496
📒 Files selected for processing (10)
tests/cli_e2e/base/helpers_test.gotests/cli_e2e/docs/docs_create_fetch_test.gotests/cli_e2e/docs/docs_update_test.gotests/cli_e2e/docs/helpers_test.gotests/cli_e2e/drive/helpers.gotests/cli_e2e/sheets/helpers_test.gotests/cli_e2e/sheets/sheets_crud_workflow_test.gotests/cli_e2e/wiki/helpers_test.gotests/cli_e2e/wiki/wiki_shortcut_workflow_test.gotests/cli_e2e/wiki/wiki_workflow_test.go
d66f206 to
a0563d5
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
tests/cli_e2e/wiki/helpers_test.go (1)
222-224:⚠️ Potential issue | 🟠 Major | ⚡ Quick winHandle pre-delete
get_node"already gone" separately from real lookup failures.This still returns
(getResult, nil)for every failed pre-delete lookup. That reports already-deleted nodes as cleanup failures and also drops the root cause for unexpectedget_nodeerrors.Suggested fix
if getResult.ExitCode != 0 { - return getResult, nil + if isWikiNodeDeletedResult(getResult) { + getResult.ExitCode = 0 + return getResult, nil + } + return getResult, fmt.Errorf("get wiki node %s before delete failed: exit=%d stdout=%s stderr=%s", nodeToken, getResult.ExitCode, getResult.Stdout, getResult.Stderr) }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/cli_e2e/wiki/helpers_test.go` around lines 222 - 224, The pre-delete lookup currently treats any non-zero getResult.ExitCode as a generic failure; change the logic after the `if getResult.ExitCode != 0` check to inspect the `getResult.Stdout`/`getResult.Stderr` (or combined output) for the sentinel "already gone" message emitted by `get_node` and treat that case as a non-error (return nil for cleanup), while for all other non-zero exits return the original getResult and a non-nil error (preserving the root cause). Locate the code that calls `get_node` and uses `getResult` and implement a conditional: if exit != 0 && output contains "already gone" then continue (or return nil), else return the getResult and an error.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/cli_e2e/wiki/helpers_test.go`:
- Around line 238-240: The helper is only checking result.ExitCode but must also
validate the API status carried in the JSON envelope on stdout before treating
responses as success; update the code paths that call listWikiNodeChildren and
waitWikiNodeDeleted (and the related blocks at the other ranges) to reuse the
same stdout-status check pattern used by other helpers in this file: parse
childListResult.Stdout (the JSON envelope), assert the envelope indicates
success (API status/errno == 0 or equivalent) before accessing data.* or
deciding the node still exists, and return an error/result when the stdout
envelope shows an API error even if ExitCode == 0.
---
Duplicate comments:
In `@tests/cli_e2e/wiki/helpers_test.go`:
- Around line 222-224: The pre-delete lookup currently treats any non-zero
getResult.ExitCode as a generic failure; change the logic after the `if
getResult.ExitCode != 0` check to inspect the
`getResult.Stdout`/`getResult.Stderr` (or combined output) for the sentinel
"already gone" message emitted by `get_node` and treat that case as a non-error
(return nil for cleanup), while for all other non-zero exits return the original
getResult and a non-nil error (preserving the root cause). Locate the code that
calls `get_node` and uses `getResult` and implement a conditional: if exit != 0
&& output contains "already gone" then continue (or return nil), else return the
getResult and an error.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 5ede533b-fab7-4b92-8bd6-b011a8cdac59
📒 Files selected for processing (10)
tests/cli_e2e/base/helpers_test.gotests/cli_e2e/docs/docs_create_fetch_test.gotests/cli_e2e/docs/docs_update_test.gotests/cli_e2e/docs/helpers_test.gotests/cli_e2e/drive/helpers.gotests/cli_e2e/sheets/helpers_test.gotests/cli_e2e/sheets/sheets_crud_workflow_test.gotests/cli_e2e/wiki/helpers_test.gotests/cli_e2e/wiki/wiki_shortcut_workflow_test.gotests/cli_e2e/wiki/wiki_workflow_test.go
🚧 Files skipped from review as they are similar to previous changes (9)
- tests/cli_e2e/docs/helpers_test.go
- tests/cli_e2e/base/helpers_test.go
- tests/cli_e2e/docs/docs_update_test.go
- tests/cli_e2e/sheets/sheets_crud_workflow_test.go
- tests/cli_e2e/sheets/helpers_test.go
- tests/cli_e2e/wiki/wiki_shortcut_workflow_test.go
- tests/cli_e2e/docs/docs_create_fetch_test.go
- tests/cli_e2e/wiki/wiki_workflow_test.go
- tests/cli_e2e/drive/helpers.go
Change-Id: I3e04a82f622853549f11ac49cbd6fefa194c7c56
a0563d5 to
4557482
Compare
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@4557482b39ca8ab6b6d5ca85d7f534b85fc37bbd🧩 Skill updatenpx skills add yxzhaao/cli#fix/cleanup-created-resources -y -g |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #949 +/- ##
==========================================
+ Coverage 66.40% 66.79% +0.39%
==========================================
Files 560 564 +4
Lines 51548 52441 +893
==========================================
+ Hits 34230 35030 +800
- Misses 14455 14511 +56
- Partials 2863 2900 +37 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Change-Id: I3e04a82f622853549f11ac49cbd6fefa194c7c56
Summary
Changes
Test Plan
lark xxxcommand works as expectedRelated Issues
Summary by CodeRabbit