Fix the filter of integTestWithSecurity#5098
Fix the filter of integTestWithSecurity#5098qianheng-aws merged 9 commits intoopensearch-project:mainfrom
Conversation
Signed-off-by: Lantao Jin <ltjin@amazon.com>
📝 WalkthroughSummary by CodeRabbit
WalkthroughThis PR consolidates multi-cluster test initialization logic by introducing a new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
Signed-off-by: Lantao Jin <ltjin@amazon.com>
Signed-off-by: Lantao Jin <ltjin@amazon.com>
Signed-off-by: Lantao Jin <ltjin@amazon.com>
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)
integ-test/src/test/java/org/opensearch/sql/security/PPLPermissionsIT.java (1)
60-99:⚠️ Potential issue | 🟡 MinorUse a static initialized flag to prevent redundant cluster-scoped security setup.
The instance field
initializedis ineffective across test instances since JUnit creates a new instance per@Beforemethod. WithsetUpIndices()callinginit()before each test, the guard will always evaluate tofalse, causing security roles and users to be recreated for every test method. WhilecreateRole()andcreateUser()are idempotent PUT requests that don't break test independence, this pattern is inefficient and misleading. Follow the pattern used inGeoIpFunctionsIT—useprivate static boolean initialized—to correctly guard one-time cluster-scoped setup across all test methods in the class.
🤖 Fix all issues with AI agents
In
`@integ-test/src/test/java/org/opensearch/sql/security/CrossClusterTestBase.java`:
- Around line 16-27: The static initializer in CrossClusterTestBase uses
System.getProperty("cluster.names").split(",") which can NPE if the property is
missing; modify the static block that computes REMOTE_CLUSTER to defensively
handle a null property by reading System.getProperty("cluster.names") into a
local variable, check for null/blank and substitute a sensible default (e.g.,
"remoteCluster" or a single-entry string) or throw a clear
IllegalStateException, then split that safe value and proceed to pick the first
cluster that startsWith("remote") (referencing the REMOTE_CLUSTER symbol and the
local variables clusterNames/remote in the static block).
🧹 Nitpick comments (2)
integ-test/src/test/java/org/opensearch/sql/security/CalciteCrossClusterSearchIT.java (2)
135-136: Inconsistent literal types inverifyDataRowscall.The
rows()arguments mixint(451) andLong(504L,45L) literals. If the matcher performs strict type checking, this inconsistency could cause unexpected test failures. Consider using consistent types.♻️ Proposed fix for type consistency
- verifyDataRows(result, rows(451, "20.0-30.0"), rows(504L, "30.0-40.0"), rows(45L, "40.0-50.0")); + verifyDataRows(result, rows(451L, "20.0-30.0"), rows(504L, "30.0-40.0"), rows(45L, "40.0-50.0"));
188-189: Same type inconsistency as above.♻️ Proposed fix for type consistency
- verifyDataRows(result, rows(451, "20-30"), rows(504L, "30-40"), rows(45L, "40-50")); + verifyDataRows(result, rows(451L, "20-30"), rows(504L, "30-40"), rows(45L, "40-50"));
integ-test/src/test/java/org/opensearch/sql/security/CrossClusterTestBase.java
Show resolved
Hide resolved
* Fix the filter of integTestWithSecurity Signed-off-by: Lantao Jin <ltjin@amazon.com> * Fix IT Signed-off-by: Lantao Jin <ltjin@amazon.com> * Fix IT Signed-off-by: Lantao Jin <ltjin@amazon.com> * refactor Signed-off-by: Lantao Jin <ltjin@amazon.com> * fix IT Signed-off-by: Lantao Jin <ltjin@amazon.com> * Use Junit4 Signed-off-by: Lantao Jin <ltjin@amazon.com> * fix Signed-off-by: Lantao Jin <ltjin@amazon.com> * fix httpclient leaking Signed-off-by: Lantao Jin <ltjin@amazon.com> * Fix permission IT in Junit4 Signed-off-by: Lantao Jin <ltjin@amazon.com> --------- Signed-off-by: Lantao Jin <ltjin@amazon.com> (cherry picked from commit 9886100) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
* Fix the filter of integTestWithSecurity * Fix IT * Fix IT * refactor * fix IT * Use Junit4 * fix * fix httpclient leaking * Fix permission IT in Junit4 --------- (cherry picked from commit 9886100) Signed-off-by: Lantao Jin <ltjin@amazon.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
* Fix the filter of integTestWithSecurity Signed-off-by: Lantao Jin <ltjin@amazon.com> * Fix IT Signed-off-by: Lantao Jin <ltjin@amazon.com> * Fix IT Signed-off-by: Lantao Jin <ltjin@amazon.com> * refactor Signed-off-by: Lantao Jin <ltjin@amazon.com> * fix IT Signed-off-by: Lantao Jin <ltjin@amazon.com> * Use Junit4 Signed-off-by: Lantao Jin <ltjin@amazon.com> * fix Signed-off-by: Lantao Jin <ltjin@amazon.com> * fix httpclient leaking Signed-off-by: Lantao Jin <ltjin@amazon.com> * Fix permission IT in Junit4 Signed-off-by: Lantao Jin <ltjin@amazon.com> --------- Signed-off-by: Lantao Jin <ltjin@amazon.com> # Conflicts: # integ-test/src/test/java/org/opensearch/sql/security/CrossClusterSearchIT.java
Description
Currently, the
integTestWithSecurityonly enabled theCrossClusterSearchITandPPLPermissionsIT, but we have other classes such asCalciteCrossClusterSearchITandCrossClusterCoalesceITin code which are not enabled due to theintegTestWithSecuritytask only work with JUnit5.This PR change them to JUnit4 framework which could trigger all ITs in the task.
Related Issues
Resolves #5097
Check List
--signoffor-s.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.