-
Notifications
You must be signed in to change notification settings - Fork 79
feat: [SNOW-2155083] spcs service: support auto-suspend-secs #2487
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
Merged
sfc-gh-jwilkowski
merged 3 commits into
main
from
jw/SNOW-2155083-auto-suspend-secs-support
Oct 22, 2025
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
6d93b48
feat: [SNOW-2155083] add auto_suspend_secs parameter support
sfc-gh-jwilkowski 2e83f1d
Merge branch 'main' into jw/SNOW-2155083-auto-suspend-secs-support
sfc-gh-jwilkowski 339a050
feat: [SNOW-2155083] add support for auto-suspend-secs in spcs services
sfc-gh-jwilkowski 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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1531,6 +1531,7 @@ def test_set_property(mock_execute_query): | |
| max_instances = 3 | ||
| query_warehouse = "test_warehouse" | ||
| auto_resume = False | ||
| auto_suspend_secs = 600 | ||
| external_access_integrations = [ | ||
| "google_apis_access_integration", | ||
| "salesforce_api_access_integration", | ||
|
|
@@ -1544,6 +1545,7 @@ def test_set_property(mock_execute_query): | |
| max_instances=max_instances, | ||
| query_warehouse=query_warehouse, | ||
| auto_resume=auto_resume, | ||
| auto_suspend_secs=auto_suspend_secs, | ||
| external_access_integrations=external_access_integrations, | ||
| comment=comment, | ||
| ) | ||
|
|
@@ -1555,6 +1557,7 @@ def test_set_property(mock_execute_query): | |
| f"max_instances = {max_instances}", | ||
| f"query_warehouse = {query_warehouse}", | ||
| f"auto_resume = {auto_resume}", | ||
| f"auto_suspend_secs = {auto_suspend_secs}", | ||
| f"external_access_integrations = ({eai_list})", | ||
| f"comment = {comment}", | ||
| ] | ||
|
|
@@ -1566,7 +1569,9 @@ def test_set_property(mock_execute_query): | |
| def test_set_property_no_properties(): | ||
| service_name = "test_service" | ||
| with pytest.raises(NoPropertiesProvidedError) as e: | ||
| ServiceManager().set_property(service_name, None, None, None, None, None, None) | ||
| ServiceManager().set_property( | ||
| service_name, None, None, None, None, None, None, None | ||
| ) | ||
| assert ( | ||
| e.value.message | ||
| == f"No properties specified for service '{service_name}'. Please provide at least one property to set." | ||
|
|
@@ -1582,6 +1587,7 @@ def test_set_property_cli(mock_set, mock_statement_success, runner): | |
| max_instances = 3 | ||
| query_warehouse = "test_warehouse" | ||
| auto_resume = False | ||
| auto_suspend_secs = 600 | ||
| external_access_integrations = [ | ||
| "google_apis_access_integration", | ||
| "salesforce_api_access_integration", | ||
|
|
@@ -1600,6 +1606,8 @@ def test_set_property_cli(mock_set, mock_statement_success, runner): | |
| "--query-warehouse", | ||
| query_warehouse, | ||
| "--no-auto-resume", | ||
| "--auto-suspend-secs", | ||
| str(auto_suspend_secs), | ||
| "--eai-name", | ||
| "google_apis_access_integration", | ||
| "--eai-name", | ||
|
|
@@ -1614,6 +1622,7 @@ def test_set_property_cli(mock_set, mock_statement_success, runner): | |
| max_instances=max_instances, | ||
| query_warehouse=query_warehouse, | ||
| auto_resume=auto_resume, | ||
| auto_suspend_secs=auto_suspend_secs, | ||
| external_access_integrations=external_access_integrations, | ||
| comment=to_string_literal(comment), | ||
| ) | ||
|
|
@@ -1636,6 +1645,7 @@ def test_set_property_no_properties_cli(mock_set, runner): | |
| max_instances=None, | ||
| query_warehouse=None, | ||
| auto_resume=None, | ||
| auto_suspend_secs=None, | ||
| external_access_integrations=None, | ||
| comment=None, | ||
| ) | ||
|
|
@@ -1646,16 +1656,20 @@ def test_unset_property(mock_execute_query): | |
| service_name = "test_service" | ||
| cursor = Mock(spec=SnowflakeCursor) | ||
| mock_execute_query.return_value = cursor | ||
| result = ServiceManager().unset_property(service_name, True, True, True, True, True) | ||
| expected_query = "alter service test_service unset min_instances,max_instances,query_warehouse,auto_resume,comment" | ||
| result = ServiceManager().unset_property( | ||
| service_name, True, True, True, True, True, True | ||
| ) | ||
| expected_query = "alter service test_service unset min_instances,max_instances,query_warehouse,auto_resume,auto_suspend_secs,comment" | ||
| mock_execute_query.assert_called_once_with(expected_query) | ||
| assert result == cursor | ||
|
|
||
|
|
||
| def test_unset_property_no_properties(): | ||
| service_name = "test_service" | ||
| with pytest.raises(NoPropertiesProvidedError) as e: | ||
| ServiceManager().unset_property(service_name, False, False, False, False, False) | ||
| ServiceManager().unset_property( | ||
| service_name, False, False, False, False, False, False | ||
| ) | ||
| assert ( | ||
| e.value.message | ||
| == f"No properties specified for service '{service_name}'. Please provide at least one property to reset to its default value." | ||
|
|
@@ -1677,6 +1691,7 @@ def test_unset_property_cli(mock_unset, mock_statement_success, runner): | |
| "--max-instances", | ||
| "--query-warehouse", | ||
| "--auto-resume", | ||
| "--auto-suspend-secs", | ||
| "--comment", | ||
| ] | ||
| ) | ||
|
|
@@ -1686,6 +1701,7 @@ def test_unset_property_cli(mock_unset, mock_statement_success, runner): | |
| max_instances=True, | ||
| query_warehouse=True, | ||
| auto_resume=True, | ||
| auto_suspend_secs=True, | ||
| comment=True, | ||
| ) | ||
| assert result.exit_code == 0, result.output | ||
|
|
@@ -1707,10 +1723,47 @@ def test_unset_property_no_properties_cli(mock_unset, runner): | |
| max_instances=False, | ||
| query_warehouse=False, | ||
| auto_resume=False, | ||
| auto_suspend_secs=False, | ||
| comment=False, | ||
| ) | ||
|
|
||
|
|
||
| @patch(EXECUTE_QUERY) | ||
| def test_set_property_auto_suspend_secs_only(mock_execute_query): | ||
| service_name = "test_service" | ||
| auto_suspend_secs = 300 | ||
|
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. Here is another magic value. Why not 600 like earlier? 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. as above, the exact value doesn't really matter, it just needs to be some positive integer |
||
| cursor = Mock(spec=SnowflakeCursor) | ||
| mock_execute_query.return_value = cursor | ||
| result = ServiceManager().set_property( | ||
| service_name=service_name, | ||
| min_instances=None, | ||
| max_instances=None, | ||
| query_warehouse=None, | ||
| auto_resume=None, | ||
| auto_suspend_secs=auto_suspend_secs, | ||
| external_access_integrations=None, | ||
| comment=None, | ||
| ) | ||
| expected_query = ( | ||
| f"alter service {service_name} set\nauto_suspend_secs = {auto_suspend_secs}" | ||
| ) | ||
| mock_execute_query.assert_called_once_with(expected_query) | ||
| assert result == cursor | ||
|
|
||
|
|
||
| @patch(EXECUTE_QUERY) | ||
| def test_unset_property_auto_suspend_secs_only(mock_execute_query): | ||
| service_name = "test_service" | ||
| cursor = Mock(spec=SnowflakeCursor) | ||
| mock_execute_query.return_value = cursor | ||
| result = ServiceManager().unset_property( | ||
| service_name, False, False, False, False, True, False | ||
| ) | ||
| expected_query = f"alter service {service_name} unset auto_suspend_secs" | ||
| mock_execute_query.assert_called_once_with(expected_query) | ||
| assert result == cursor | ||
|
|
||
|
|
||
| def test_unset_property_with_args(runner): | ||
| service_name = "test_service" | ||
| result = runner.invoke( | ||
|
|
||
17 changes: 17 additions & 0 deletions
17
tests_integration/test_data/projects/spcs_service_no_public/snowflake.yml
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 |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| definition_version: "2" | ||
|
|
||
| entities: | ||
| service: | ||
| type: service | ||
| identifier: | ||
| name: | ||
| stage: | ||
| compute_pool: snowcli_compute_pool | ||
| spec_file: spec.yml | ||
| min_instances: 1 | ||
| max_instances: 1 | ||
| query_warehouse: xsmall | ||
| auto_suspend_secs: 600 | ||
| comment: "Test service without public endpoint" | ||
| artifacts: | ||
| - spec.yml |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this could be defined instead of magic number?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None of those matter really, it's just an integer. This variable is local to this test only, I wouldn't see any point in extracting values of service_name, min_instances, max_instances etc either