Fix test hang issues and update test configurations#1351
Conversation
Fix test hang issue
…eneratedKeys function
WalkthroughAdd verbose flag to CI test run; adjust go-test OS/arch mappings; disable one test file; update multiple integration tests to explicitly create active subscriptions before deletion checks; tweak test utilities (remove ConsumerSecret asserts, set gateway provider); minor comment formatting change. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~35 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
import-export-cli/integration/testutils/app_testUtils.go (1)
337-346:⚠️ Potential issue | 🟠 MajorReintroduce explicit
ConsumerSecretverification (or assert rotation behavior) instead of disabling it.Commenting out both
ConsumerSecretassertions removes validation of a core exported/imported credential path. This can let key-secret regressions pass unnoticed. If secrets are expected to be preserved, restore equality checks; if rotation is expected, assert that contract explicitly (NotEmpty, and documented expected equality/inequality).Suggested fix direction
if key.KeyType == utils.ProductionKeyType { assert.Equal(t, applicationKey1.ConsumerKey, key.ConsumerKey, "Production Consumer key mismatched") - // assert.Equal(t, applicationKey1.ConsumerSecret, key.ConsumerSecret, "Production Consumer secret mismatched") + assert.Equal(t, applicationKey1.ConsumerSecret, key.ConsumerSecret, "Production Consumer secret mismatched") } if key.KeyType == utils.SandboxKeyType { assert.Equal(t, applicationKey2.ConsumerKey, key.ConsumerKey, "Sandbox Consumer key mismatched") - // assert.Equal(t, applicationKey2.ConsumerSecret, key.ConsumerSecret, "Sandbox Consumer secret mismatched") + assert.Equal(t, applicationKey2.ConsumerSecret, key.ConsumerSecret, "Sandbox Consumer secret mismatched") }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@import-export-cli/integration/testutils/app_testUtils.go` around lines 337 - 346, The ConsumerSecret assertions were commented out; restore explicit verification in the loop over importedApplicationKeysList.List so credential regressions are caught: for keys with utils.ProductionKeyType and utils.SandboxKeyType, either re-enable assert.Equal against applicationKey1.ConsumerSecret / applicationKey2.ConsumerSecret if secrets must be preserved, or replace with explicit rotation checks such as assert.NotEmpty and assert.NotEqual (or document expected equality/inequality) to assert rotation behavior; update the checks next to the existing ConsumerKey assertions in the same loop to maintain symmetry and clarity.
🧹 Nitpick comments (2)
import-export-cli/integration/apiProduct_test.go (1)
718-720: Non-standard comment formatting with tab indentation.Line 719 includes a tab character after
//, which is unconventional for Go multi-line comments. Standard Go comment style uses consistent//prefixes without indentation for continuation lines.📝 Proposed fix for standard Go comment formatting
// Export an API Product with its dependent APIs from one environment as super tenant user with Internal/devops role -// -// and import to another environment freshly as tenant admin and try to update that API Product and dependent APIs. -// +// and import to another environment freshly as tenant admin and try to update that API Product and dependent APIs. // This same command can be used to update only the dependent APIs as well.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@import-export-cli/integration/apiProduct_test.go` around lines 718 - 720, The continuation line in the comment block uses a tab after the '//' which breaks Go's conventional comment formatting; edit the comment in import-export-cli/integration/apiProduct_test.go so that the line starting with '//' has a single space after '//' (i.e., use '// ' instead of '//\t') and ensure all lines in that multi-line comment use consistent '// ' prefixes with no tab characters.import-export-cli/integration/testutils/gateway_testUtils.go (1)
47-47: LGTM! Provider field successfully added to test data.The addition of the
Providerfield with value"wso2"aligns with the PR objective to add provider information to the gateway environment. This change enables proper testing of gateway environment creation.Optional suggestion: Consider extracting the provider value to a named constant (e.g.,
const DefaultTestProvider = "wso2") for improved maintainability, though the current hardcoded approach is acceptable for test utilities.♻️ Optional refactor to use a named constant
Add a constant at the package level:
const DefaultTestProvider = "wso2"Then update line 47:
- env.Provider = "wso2" + env.Provider = DefaultTestProvider🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@import-export-cli/integration/testutils/gateway_testUtils.go` at line 47, Add a package-level constant (e.g., const DefaultTestProvider = "wso2") and replace the hardcoded assignment env.Provider = "wso2" with env.Provider = DefaultTestProvider; update any imports/refs if needed and keep the constant name (DefaultTestProvider) to make the test utility easier to maintain and reuse.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@import-export-cli/integration/go-test.sh`:
- Around line 29-39: The OS/arch mappings in go-test.sh are inconsistent with
build.sh causing macOS test lookups to fail; update the uname case logic so
Darwin sets OS_STR to the same value build.sh uses (restore OS_STR="macosx" or
otherwise match build.sh naming) and ensure the uname -m branch maps x86_64 to
ARCH_STR="amd64" for Darwin (while preserving current x64 for Linux/Windows) so
the produced archive names (apictl-*-macosx-amd64.tar.gz or
apictl-*-darwin-amd64.tar.gz depending on which OS_STR you choose) match what
build.sh creates; modify the OS_STR and ARCH_STR case blocks (the `case
"\`uname\`"` and `case "\`uname -m\`"` sections) accordingly and run the same
build.sh commands to verify file name alignment.
---
Outside diff comments:
In `@import-export-cli/integration/testutils/app_testUtils.go`:
- Around line 337-346: The ConsumerSecret assertions were commented out; restore
explicit verification in the loop over importedApplicationKeysList.List so
credential regressions are caught: for keys with utils.ProductionKeyType and
utils.SandboxKeyType, either re-enable assert.Equal against
applicationKey1.ConsumerSecret / applicationKey2.ConsumerSecret if secrets must
be preserved, or replace with explicit rotation checks such as assert.NotEmpty
and assert.NotEqual (or document expected equality/inequality) to assert
rotation behavior; update the checks next to the existing ConsumerKey assertions
in the same loop to maintain symmetry and clarity.
---
Nitpick comments:
In `@import-export-cli/integration/apiProduct_test.go`:
- Around line 718-720: The continuation line in the comment block uses a tab
after the '//' which breaks Go's conventional comment formatting; edit the
comment in import-export-cli/integration/apiProduct_test.go so that the line
starting with '//' has a single space after '//' (i.e., use '// ' instead of
'//\t') and ensure all lines in that multi-line comment use consistent '// '
prefixes with no tab characters.
In `@import-export-cli/integration/testutils/gateway_testUtils.go`:
- Line 47: Add a package-level constant (e.g., const DefaultTestProvider =
"wso2") and replace the hardcoded assignment env.Provider = "wso2" with
env.Provider = DefaultTestProvider; update any imports/refs if needed and keep
the constant name (DefaultTestProvider) to make the test utility easier to
maintain and reuse.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e33e24ae-7490-4377-8b73-1d1708ff5f41
📒 Files selected for processing (8)
.github/workflows/main.yamlimport-export-cli/integration/apiProduct_test.goimport-export-cli/integration/api_test.goimport-export-cli/integration/getkeys_test.goimport-export-cli/integration/go-test.shimport-export-cli/integration/mcpServer_test.goimport-export-cli/integration/testutils/app_testUtils.goimport-export-cli/integration/testutils/gateway_testUtils.go
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@import-export-cli/integration/getkeys_test.go`:
- Around line 21-23: The test file was fully commented out which removes all CI
coverage and stops compilation; instead remove the file-level block comment and
keep each test compiled but conditionally skipped by calling a helper like
skipGetKeysTests(t) at the top of every affected test function (those that call
testutils.ValidateGetKeys* or similar helpers), and add a TODO/issue link in the
skip message; ensure getkeys_test.go no longer has /* ... */ around the suite so
the test functions (e.g., TestGetKeys_* or any functions invoking
testutils.ValidateGetKeys*) compile and report skipped rather than being
quarantined.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 94862597-86c0-4736-b666-84e1a277a841
📒 Files selected for processing (1)
import-export-cli/integration/getkeys_test.go
Purpose
Updates integration tests to directly create an application and subscribe to relevant API instead of reusing existing default cli application, for better manageability.
Updated
go-test.shto correctly detect MacOS asdarwinand added support forarm64architecture,Added provider information to the environment in
GenerateSampleGatewayData.Disabled test suite for get keys command
Commented out the consumer secret assertion of
ValidateAppExportImportGeneratedKeysSummary by CodeRabbit
Tests
Chores