-
Notifications
You must be signed in to change notification settings - Fork 62
Layers - 06 - B [Test] Adds Test changes for Create and List Layers api #1781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bhanvimenghani
wants to merge
5
commits into
kruize:mvp_demo
Choose a base branch
from
bhanvimenghani:layers-test-changes
base: mvp_demo
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
993fc64
adds create and list layers tests
bhanvimenghani 754f6d8
adds test docs & neg create layer tests
bhanvimenghani ff8dd59
fix tests, add layers marker, add delete layers dummy function
bhanvimenghani dce3b29
list layer with no layers
bhanvimenghani 5f49b76
update tests to use semeru instead of openj9
bhanvimenghani File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -692,3 +692,85 @@ def update_metadata_profile(metadata_profile_json_file, name=None, **kwargs): | |
| print("Response status code = ", response.status_code) | ||
| print(response.json()) | ||
| return response | ||
|
|
||
|
|
||
| # Description: This function creates a layer using createLayer API | ||
| # Input Parameters: layer input json file | ||
| def create_layer(layer_json_file): | ||
| json_file = open(layer_json_file, "r") | ||
| layer_json = json.loads(json_file.read()) | ||
|
|
||
| print("\nCreating layer...") | ||
| print("\n************************************************************") | ||
| pretty_json_str = json.dumps(layer_json, indent=4) | ||
| print(pretty_json_str) | ||
| print("\n************************************************************") | ||
|
|
||
| url = URL + "/createLayer" | ||
| print("URL = ", url) | ||
|
|
||
| response = requests.post(url, json=layer_json) | ||
| print("Response status code = ", response.status_code) | ||
| print(response.text) | ||
| return response | ||
|
|
||
|
|
||
| # Description: This function lists layers from Kruize Autotune using GET listLayers API | ||
| # Input Parameters: layer name (optional) | ||
| def list_layers(layer_name=None, logging=True): | ||
| print("\nListing the layers...") | ||
|
|
||
| query_params = {} | ||
|
|
||
| if layer_name is not None: | ||
| query_params['name'] = layer_name | ||
|
|
||
| query_string = "&".join(f"{key}={value}" for key, value in query_params.items()) | ||
|
|
||
| url = URL + "/listLayers" | ||
| if query_string: | ||
| url += "?" + query_string | ||
| print("URL = ", url) | ||
| print("PARAMS = ", query_params) | ||
| response = requests.get(url) | ||
|
|
||
| print("Response status code = ", response.status_code) | ||
| if logging: | ||
| print("\n************************************************************") | ||
| print(response.text) | ||
| print("\n************************************************************") | ||
| return response | ||
|
|
||
|
|
||
| # Description: This function deletes a layer from the database (temporary workaround until deleteLayer API is implemented) | ||
| # Input Parameters: layer name | ||
| def delete_layer_from_db(layer_name): | ||
| """ | ||
| Helper function to delete a layer from the database. | ||
| This is a temporary workaround until deleteLayer API is implemented. | ||
|
|
||
| Args: | ||
| layer_name: Name of the layer to delete | ||
|
|
||
| Returns: | ||
| bool: True if deletion succeeded, False otherwise | ||
| """ | ||
| import subprocess | ||
| try: | ||
| cmd = [ | ||
| "kubectl", "exec", "-n", "monitoring", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Namespace is hard coded to monitoring, will not work with openshift |
||
| "deployment/kruize-db-deployment", "--", | ||
| "psql", "-U", "admin", "-d", "kruizeDB", | ||
| "-c", f"DELETE FROM kruize_lm_layer WHERE layer_name='{layer_name}';" | ||
| ] | ||
| result = subprocess.run(cmd, capture_output=True, text=True, timeout=10) | ||
| if result.returncode == 0: | ||
| print(f" ✓ Cleaned up layer '{layer_name}' from database") | ||
| return True | ||
| else: | ||
| # Don't fail - just warn | ||
| print(f" ⚠ Warning: Could not clean up layer '{layer_name}': {result.stderr}") | ||
| return False | ||
| except Exception as e: | ||
| print(f" ⚠ Warning: Error cleaning up layer '{layer_name}': {e}") | ||
| return False | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.