Skip to content

Conversation

@bhanvimenghani
Copy link
Contributor

@bhanvimenghani bhanvimenghani commented Nov 12, 2025

Description

This pr includes test changes for the Create Exp + List Exp api in remote monitoring tests for custom terms functionality.
https://docs.google.com/document/d/1yjavz5LnEWQOlGJZTED5YdEiCUNJJUqFr0uhhiJrsqE/edit?usp=sharing

Fixes # (issue)

Type of change

  • Bug fix
  • New feature
  • Docs update
  • Breaking change (What changes might users need to make in their application due to this PR?)
  • Requires DB changes

How has this been tested?

Please describe the tests that were run to verify your changes and steps to reproduce. Please specify any test configuration required.

  • New Test X
  • Functional testsuite

Test Configuration

  • Kubernetes clusters tested on:

Checklist 🎯

  • Followed coding guidelines
  • Comments added
  • Dependent changes merged
  • Documentation updated
  • Tests added or updated

Additional information

Include any additional information such as links, test results, screenshots here

@bhanvimenghani bhanvimenghani changed the title Custom Terms Test Changes - Create Exp api Custom Terms Test Changes - Create + List Experiment Nov 13, 2025
@bhanvimenghani bhanvimenghani linked an issue Nov 13, 2025 that may be closed by this pull request
@bhanvimenghani bhanvimenghani self-assigned this Nov 13, 2025
@bhanvimenghani bhanvimenghani added this to the Kruize 0.8 Release milestone Nov 13, 2025
@bhanvimenghani bhanvimenghani moved this to Under Review in Monitoring Nov 13, 2025
("", "Empty term or model value is not allowed"),
(" ", "Empty term or model value is not allowed"),
("test@term", "is invalid. Only letters, numbers, underscores (_), and hyphens (-) are allowed"),
("test#term", "is invalid. Only letters, numbers, underscores (_), and hyphens (-) are allowed"),
Copy link
Contributor

Choose a reason for hiding this comment

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

You can define these messages in utils and use it here



@pytest.mark.negative
@pytest.mark.parametrize("plots_datapoint_value", [0, -1, -10])
Copy link
Contributor

Choose a reason for hiding this comment

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

Add tests for valid but incorrect plots_datapoint_value along with duration_in_days

Copy link
Contributor

Choose a reason for hiding this comment

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

Validate plots data in the recommendations in the above scenarios

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added the test in create experiment that checks if plots datapoint is positive but greater than the duration in days value, it is creating the experiment, need to make backend change to not allow experiment creation. For now i have added this test but adding skip option so that this does not runs untill i make backend changes

- Update recommendations with end_time preceding start_time
- [SANITY] Update recommendations with valid results for MIG accelerator
- [SANITY] Update recommendations with valid results for Non-MIG Accelerator
- [SANITY] Update recommendations with valid results for a custom term experiment
Copy link
Contributor

Choose a reason for hiding this comment

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

Add details on what term setting combinations are being tested here



@pytest.mark.negative
@pytest.mark.parametrize("plots_datapoint_value", [0, -1, -10])
Copy link
Contributor

Choose a reason for hiding this comment

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

Validate plots data in the recommendations in the above scenarios

# Note: JSON parsing will automatically deduplicate keys, keeping only the last occurrence
# This test validates the behavior - the experiment should be created with only one instance
# or fail depending on backend validation
assert response.status_code == SUCCESS_STATUS_CODE or response.status_code == ERROR_STATUS_CODE
Copy link
Contributor

Choose a reason for hiding this comment

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

Update the assertion as per the expected behavior

response = delete_experiment(tmp_json_file)
print("delete exp = ", response.status_code)

# Sanity test for custom term
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a test to validate if all the default terms can be specified while creating the experiment.

"my_custom_term": {
"duration_in_days": 5.0,
"duration_threshold": "3 days",
"plots_datapoint": 5,
Copy link
Contributor

Choose a reason for hiding this comment

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

Include a test with above settings to generate recommendations and validate the recommendations and the plots data count in the recommendations are as expected.

def test_list_exp_mixed_terms_and_partial_auto_population(cluster_type):
"""
Test Description: This comprehensive test validates auto-population behavior for:
1. Default terms (weekly, monthly) are auto-populated with system-defined values
Copy link
Contributor

Choose a reason for hiding this comment

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

Include a parameterized test to validate auto-population for all default terms

# Verify default terms are auto-populated with system-defined values
assert "weekly" in terms
assert "duration_in_days" in terms["weekly"]
assert terms["weekly"]["duration_in_days"] == 7.0
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't duration_threshold auto-populated, don't see an assertion for this?

@bhanvimenghani bhanvimenghani removed this from the Kruize 0.8 Release milestone Dec 5, 2025
@bhanvimenghani
Copy link
Contributor Author

i have addressed the review comments and stashed the changes locally. Since there were changes in the json design the dev prs needs to be updated to support latest json structure and also incremental prs for it raised post that I will be changing the tests as required and updating this pr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Under Review

Development

Successfully merging this pull request may close these issues.

Test Scenarios for Custom Term Changes

2 participants