Skip to content

Fix test hang issues and update test configurations#1351

Merged
PasanT9 merged 12 commits into
wso2:masterfrom
manodyaSenevirathne:master
Mar 26, 2026
Merged

Fix test hang issues and update test configurations#1351
PasanT9 merged 12 commits into
wso2:masterfrom
manodyaSenevirathne:master

Conversation

@manodyaSenevirathne

@manodyaSenevirathne manodyaSenevirathne commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

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.sh to correctly detect MacOS as darwin and added support for arm64 architecture,

  • Added provider information to the environment in GenerateSampleGatewayData.

  • Disabled test suite for get keys command

  • Commented out the consumer secret assertion of ValidateAppExportImportGeneratedKeys

Summary by CodeRabbit

  • Tests

    • Enhanced API deletion and subscription scenario tests; updated MCP server deletion validation to ensure active subscriptions.
    • Adjusted key/subscription test behaviors and temporarily disabled a set of key-retrieval tests.
    • Relaxed some imported-app key-secret comparisons in test validations.
  • Chores

    • CI test runs now emit more verbose output.
    • Updated platform detection: macOS mapped to darwin and added ARM64 architecture support.

@coderabbitai

coderabbitai Bot commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

Add 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

Cohort / File(s) Summary
CI/CD & Test runner
.github/workflows/main.yaml, import-export-cli/integration/go-test.sh
Workflow go test now runs with -v. go-test.sh changes macOS OS_STR from macosxdarwin, adds arm64 mapping, and normalizes i386 mapping.
API deletion tests
import-export-cli/integration/api_test.go, import-export-cli/integration/apiProduct_test.go
TestDeleteApiWithActiveSubscriptionsSuperTenantUser rewritten to create subscriber app and active subscription before validating delete-failure; product test comment spacing/formatted.
Subscription & MCP tests
import-export-cli/integration/getkeys_test.go, import-export-cli/integration/mcpServer_test.go
getkeys_test.go wrapped in a block comment (tests disabled); internal test logic was changed to perform subscription setup (but now commented out). mcpServer_test.go replaces key-based validation with explicit app + subscription creation prior to deletion-failure check.
Test utilities
import-export-cli/integration/testutils/app_testUtils.go, import-export-cli/integration/testutils/gateway_testUtils.go
Removed (commented out) assertions comparing imported ConsumerSecret to original for prod/sandbox keys; GenerateSampleGatewayData() now sets env.Provider = "wso2".

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~35 minutes

Poem

🐰 I hop through tests with careful paws,

I stitch subscriptions on tiny claws,
Darwin waves and secrets hide,
Assertions trimmed, providers supplied,
A joyful leap—CI runs with pride 🥕

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the main objectives (test refactoring, macOS/arm64 support, provider info, disabled get keys tests, commented assertions) but lacks required sections like Purpose with issue links, Goals, Approach, Release notes, Documentation, and Testing details. Expand the description to include all required template sections: Purpose with issue/PR links, Goals, Approach, Release notes, Documentation impact, and Testing/Security details. Currently only lists changes without proper context.
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes key changes: fixing test hang issues and updating test configurations, which aligns with the modifications across test files, OS detection, and test utilities.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 | 🟠 Major

Reintroduce explicit ConsumerSecret verification (or assert rotation behavior) instead of disabling it.

Commenting out both ConsumerSecret assertions 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 Provider field 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

📥 Commits

Reviewing files that changed from the base of the PR and between 41ece4b and 0e8388b.

📒 Files selected for processing (8)
  • .github/workflows/main.yaml
  • import-export-cli/integration/apiProduct_test.go
  • import-export-cli/integration/api_test.go
  • import-export-cli/integration/getkeys_test.go
  • import-export-cli/integration/go-test.sh
  • import-export-cli/integration/mcpServer_test.go
  • import-export-cli/integration/testutils/app_testUtils.go
  • import-export-cli/integration/testutils/gateway_testUtils.go

Comment thread import-export-cli/integration/go-test.sh

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0e8388b and 46e5982.

📒 Files selected for processing (1)
  • import-export-cli/integration/getkeys_test.go

Comment thread import-export-cli/integration/getkeys_test.go
@PasanT9 PasanT9 merged commit 6192883 into wso2:master Mar 26, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants