Skip to content

Conversation

@Lindsay-00
Copy link
Contributor

@Lindsay-00 Lindsay-00 commented Jun 18, 2025

Description

Add Integration Tests for workload management rule based autotagging.

This IT can be run using
./gradlew :plugins:workload-management:internalClusterTest --tests "org.opensearch.plugin.wlm.WlmAutoTaggingIT"

Tests include:

  1. testExactIndexMatchTriggersTagging
    Verifies that a rule with an exact index match correctly triggers tagging when a search query is run on that index.

  2. testWildcardBasedAttributesAreTagged
    Ensures that rules using wildcard index patterns (e.g., logs-*) successfully apply tagging when matching queries are executed.

  3. testMultipleRulesDoNotInterfereWithEachOther
    Confirms isolation between multiple auto-tagging rules and workload groups, ensuring that only the matching rule's completions increase.

  4. testTaggingTriggeredAfterRuleUpdate
    Verifies that tagging is correctly triggered after updating an existing rule to match a target index (transition from non-matching to matching).

  5. Nonexistent Workload Group ID
    Validates that creating a rule with a nonexistent workload group ID throws a validation exception.

  6. Too Many Index Patterns
    Ensures that a rule is rejected if more than 10 index patterns are provided for an attribute.

  7. Empty Index Pattern Value
    Confirms that an index pattern with an empty string is invalid.

  8. Index Pattern Exceeding Max Length
    Checks that index pattern values longer than 100 characters are not allowed.

  9. Delete Rule with Nonexistent Rule ID
    Verifies that trying to delete a rule that doesn’t exist fails with an appropriate error.

Related Issues

Resolves #[Issue number to be closed when this PR is merged]

Check List

  • Functionality includes testing.
  • API changes companion pull request created, if applicable.
  • Public documentation issue/PR created, if applicable.

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.

@Lindsay-00 Lindsay-00 requested a review from a team as a code owner June 18, 2025 08:49
@Lindsay-00 Lindsay-00 changed the title Add autotagging rule integration tests [Rule based auto-tagging] Add autotagging rule integration tests Jun 18, 2025
@github-actions
Copy link
Contributor

✅ Gradle check result for d4b9e08: SUCCESS

@codecov
Copy link

codecov bot commented Jun 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.91%. Comparing base (6c4f3d8) to head (fbed93b).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main   #18550      +/-   ##
============================================
+ Coverage     72.88%   72.91%   +0.03%     
+ Complexity    69841    69824      -17     
============================================
  Files          5673     5673              
  Lines        320756   320754       -2     
  Branches      46370    46367       -3     
============================================
+ Hits         233796   233893      +97     
+ Misses        68102    67918     -184     
- Partials      18858    18943      +85     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ruai0511
Copy link
Contributor

Thanks @Lindsay-00 for the tests! For this feature we need integration tests (IT) to verify the end-to-end behavior across the system. However, the current code seems more on the UT side.

Quick recap: Unit Test (UT) vs. Integration Test (IT)
Unit tests (like the current ones using OpenSearchTestCase) focus on isolated components in-memory — no actual cluster, index, or API is involved.
Integration tests (ITs) spin up a test OpenSearch cluster and verify real-world behavior for a feature from end to end. It's like writing down the steps for the Functional testing you finished.

That being said, the current test class is extending a unit test base class (OpenSearchTestCase), but for ITs it should extend classes like OpenSearchIntegTestCase so that it spins up a test cluster and exercises real components.

Ideally each test should include

  • Creating a workload group (you can reuse the helper method from WorkloadManagementIT)
  • Creating an index ingest rules into it
  • Issuing search queries using eg. client().prepareSearch(...) and observing whether they get tagged with the correct workload group

Let me know if you have any questions. Thanks!

@github-actions
Copy link
Contributor

✅ Gradle check result for 3952431: SUCCESS

@github-actions
Copy link
Contributor

❌ Gradle check result for 99d3554: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Lingxi Chen added 7 commits June 25, 2025 14:35
Signed-off-by: Lingxi Chen <lingxich@amazon.com>
Signed-off-by: Lingxi Chen <lingxich@amazon.com>
Signed-off-by: Lingxi Chen <lingxich@amazon.com>
Signed-off-by: Lingxi Chen <lingxich@amazon.com>
Signed-off-by: Lingxi Chen <lingxich@amazon.com>
Signed-off-by: Lingxi Chen <lingxich@amazon.com>
Signed-off-by: Lingxi Chen <lingxich@amazon.com>
@github-actions
Copy link
Contributor

✅ Gradle check result for fceb87a: SUCCESS

Signed-off-by: Lingxi Chen <lingxich@amazon.com>
@github-actions
Copy link
Contributor

❌ Gradle check result for 17a3568: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Signed-off-by: Lingxi Chen <lingxich@amazon.com>
@github-actions
Copy link
Contributor

❌ Gradle check result for f331044: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Signed-off-by: Lingxi Chen <lingxich@amazon.com>
@github-actions
Copy link
Contributor

❌ Gradle check result for 650ea46: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Contributor

@ruai0511 ruai0511 left a comment

Choose a reason for hiding this comment

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

Could we add tests to verify the actual 'tagging' part? As mentioned before, IT is end-to-end testing, so we should have tests that include the complete flow: from creating the rule, to running the query, to verifying whether the query has been tagged with the group ID.

Lingxi Chen added 3 commits June 30, 2025 17:37
Signed-off-by: Lingxi Chen <lingxich@amazon.com>
Signed-off-by: Lingxi Chen <lingxich@amazon.com>
Signed-off-by: Lingxi Chen <lingxich@amazon.com>
@github-actions
Copy link
Contributor

github-actions bot commented Jul 1, 2025

❌ Gradle check result for f09deac: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Signed-off-by: Lingxi Chen <lingxich@amazon.com>
@github-actions
Copy link
Contributor

❌ Gradle check result for b46987f: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Signed-off-by: Lingxi Chen <lingxich@amazon.com>
@github-actions
Copy link
Contributor

❌ Gradle check result for 5f5ee47: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Contributor

@jainankitk jainankitk left a comment

Choose a reason for hiding this comment

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

LGTM!

@jainankitk
Copy link
Contributor

Gradle failure looks unrelated:

[org.opensearch.gateway.remote.RemoteClusterStateServiceTests.testReadClusterStateInParallel_ExceptionDuringRead](https://build.ci.opensearch.org/job/gradle-check/63819/testReport/junit/org.opensearch.gateway.remote/RemoteClusterStateServiceTests/testReadClusterStateInParallel_ExceptionDuringRead/)

have retried the gradle check

@github-actions
Copy link
Contributor

❌ Gradle check result for 5f5ee47: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@jainankitk
Copy link
Contributor

Same test still failing:

[Test Result](https://build.ci.opensearch.org/job/gradle-check/63832/testReport/) (1 failure / +1)

    [org.opensearch.gateway.remote.RemoteClusterStateServiceTests.testReadClusterStateInParallel_ExceptionDuringRead](https://build.ci.opensearch.org/job/gradle-check/63832/testReport/junit/org.opensearch.gateway.remote/RemoteClusterStateServiceTests/testReadClusterStateInParallel_ExceptionDuringRead/)

@Lindsay-00 - can you try merging from main?

@github-actions
Copy link
Contributor

✅ Gradle check result for fbed93b: SUCCESS

@opensearch-trigger-bot opensearch-trigger-bot bot removed the stalled Issues that have stalled label Sep 18, 2025
@jainankitk jainankitk merged commit 4b9aa27 into opensearch-project:main Sep 18, 2025
32 checks passed
@Lindsay-00 Lindsay-00 deleted the rule_IT branch September 19, 2025 18:53
jainankitk pushed a commit to jainankitk/OpenSearch that referenced this pull request Sep 22, 2025
…nsearch-project#18550)

---------

Signed-off-by: Lingxi Chen <lingxich@amazon.com>
Signed-off-by: Lindsay-00 <54655271+Lindsay-00@users.noreply.github.com>
Co-authored-by: Lingxi Chen <lingxich@amazon.com>
jainankitk pushed a commit to jainankitk/OpenSearch that referenced this pull request Sep 22, 2025
…nsearch-project#18550)

---------

Signed-off-by: Lingxi Chen <lingxich@amazon.com>
Signed-off-by: Lindsay-00 <54655271+Lindsay-00@users.noreply.github.com>
Co-authored-by: Lingxi Chen <lingxich@amazon.com>
Signed-off-by: Ankit Jain <jainankitk@apache.org>
jainankitk pushed a commit to jainankitk/OpenSearch that referenced this pull request Sep 22, 2025
…nsearch-project#18550)

---------

Signed-off-by: Lingxi Chen <lingxich@amazon.com>
Signed-off-by: Lindsay-00 <54655271+Lindsay-00@users.noreply.github.com>
Co-authored-by: Lingxi Chen <lingxich@amazon.com>
Signed-off-by: Ankit Jain <jainankitk@apache.org>
asimmahmood1 pushed a commit to jainankitk/OpenSearch that referenced this pull request Sep 23, 2025
…nsearch-project#18550)

---------

Signed-off-by: Lingxi Chen <lingxich@amazon.com>
Signed-off-by: Lindsay-00 <54655271+Lindsay-00@users.noreply.github.com>
Co-authored-by: Lingxi Chen <lingxich@amazon.com>
pranikum pushed a commit to pranikum/OpenSearch that referenced this pull request Sep 23, 2025
…nsearch-project#18550)

---------

Signed-off-by: Lingxi Chen <lingxich@amazon.com>
Signed-off-by: Lindsay-00 <54655271+Lindsay-00@users.noreply.github.com>
Co-authored-by: Lingxi Chen <lingxich@amazon.com>
createRule(ruleId, "initial non-matching rule", "random", featureType, workloadGroupId);

// Wait for rule to be available
Thread.sleep(5500);
Copy link
Member

Choose a reason for hiding this comment

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

Can we please try to avoid using Thread.sleep at all costs? Wait for a condition to be met and proceed otherwise fail the test after some timeout if the condition is not met.

andrross added a commit to andrross/OpenSearch that referenced this pull request Sep 25, 2025
andrross added a commit to andrross/OpenSearch that referenced this pull request Sep 25, 2025
…sts (opensearch-project#18550)"

This reverts commit 4b9aa27.

Signed-off-by: Andrew Ross <andrross@amazon.com>
andrross added a commit to andrross/OpenSearch that referenced this pull request Sep 25, 2025
…sts (opensearch-project#18550)"

This reverts commit 4b9aa27.

Signed-off-by: Andrew Ross <andrross@amazon.com>
vinaykpud pushed a commit to vinaykpud/OpenSearch that referenced this pull request Sep 26, 2025
…nsearch-project#18550)

---------

Signed-off-by: Lingxi Chen <lingxich@amazon.com>
Signed-off-by: Lindsay-00 <54655271+Lindsay-00@users.noreply.github.com>
Co-authored-by: Lingxi Chen <lingxich@amazon.com>
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.

6 participants