From 281ca397f9941bc702d27409d8d73e958fd327e7 Mon Sep 17 00:00:00 2001 From: Teja Kommineni Date: Tue, 31 Dec 2024 10:59:04 -0800 Subject: [PATCH] fix comments --- RELEASE-NOTES.md | 9 +- src/snowflake/cli/_plugins/spcs/common.py | 4 +- .../cli/_plugins/spcs/services/commands.py | 124 ++-- .../cli/_plugins/spcs/services/manager.py | 8 +- tests/__snapshots__/test_help_messages.ambr | 576 +++++++++++++++++- tests/spcs/test_services.py | 16 +- 6 files changed, 654 insertions(+), 83 deletions(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 5aaabc23f0..850b40a4f3 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -25,8 +25,12 @@ * `snow app release-directive set` * `snow app release-directive unset` * `snow app version create` now returns version, patch, and label in JSON format. -* Add ability to specify release channel when creating application instance from release directive: `snow app run --from-release-directive --channel=` -* Add ability to list release channels through `snow app release-channel list` command +* Add support for release channels: + * Add support for release channels feature in native app version creation/drop. + * Add ability to specify release channel when creating application instance from release directive: `snow app run --from-release-directive --channel=` + * Add ability to list release channels through `snow app release-channel list` command + * Add ability to add and remove accounts from release channels through `snow app release-channel add-accounts` and snow app release-channel remove-accounts` commands. + * Add ability to add/remove versions to/from release channels through `snow app release-channel add-version` and `snow app release-channel remove-version` commands. * Add `snow spcs service events` command to retrieve service-specific events: * Supports filtering by service name, container name, instance ID, time intervals (`--since`, `--until`), and pagination (`--first`, `--last`). * Use `--all` to fetch all columns. @@ -34,7 +38,6 @@ * Supports filtering by service name, container name, instance ID, and time intervals (`--since`, `--until`). * Use `--all` to fetch all columns. - ## Fixes and improvements * Fixed crashes with older x86_64 Intel CPUs. * Fixed inability to add patches to lowercase quoted versions diff --git a/src/snowflake/cli/_plugins/spcs/common.py b/src/snowflake/cli/_plugins/spcs/common.py index 770803e717..6855a34419 100644 --- a/src/snowflake/cli/_plugins/spcs/common.py +++ b/src/snowflake/cli/_plugins/spcs/common.py @@ -201,7 +201,7 @@ def format_event_row(event_dict: dict) -> dict: "DATABASE NAME": database_name, "SCHEMA NAME": schema_name, "SERVICE NAME": service_name, - "INSTANCE NAME": instance_name, + "INSTANCE ID": instance_name, "CONTAINER NAME": container_name, "SEVERITY": severity, "EVENT NAME": event_name, @@ -232,7 +232,7 @@ def format_metric_row(metric_dict: dict) -> dict: "DATABASE NAME": database_name, "SCHEMA NAME": schema_name, "SERVICE NAME": service_name, - "INSTANCE NAME": instance_name, + "INSTANCE ID": instance_name, "CONTAINER NAME": container_name, "METRIC NAME": metric_name, "METRIC VALUE": metric_value, diff --git a/src/snowflake/cli/_plugins/spcs/services/commands.py b/src/snowflake/cli/_plugins/spcs/services/commands.py index 9f0c343f93..b8ede471d5 100644 --- a/src/snowflake/cli/_plugins/spcs/services/commands.py +++ b/src/snowflake/cli/_plugins/spcs/services/commands.py @@ -60,6 +60,38 @@ short_help="Manages services.", ) +# Define common options +container_name_option = typer.Option( + ..., + "--container-name", + help="Name of the container.", + show_default=False, +) + +instance_id_option = typer.Option( + ..., + "--instance-id", + help="ID of the service instance, starting with 0.", + show_default=False, +) + +since_option = typer.Option( + default="", + help="Fetch events that are newer than this time ago, in Snowflake interval syntax.", +) + +until_option = typer.Option( + default="", + help="Fetch events that are older than this time ago, in Snowflake interval syntax.", +) + +show_all_columns_option = typer.Option( + False, + "--all", + is_flag=True, + help="Fetch all columns.", +) + def _service_name_callback(name: FQN) -> FQN: if not is_valid_object_name(name.identifier, max_depth=2, allow_quoted=False): @@ -214,18 +246,8 @@ def status(name: FQN = ServiceNameArgument, **options) -> CommandResult: @app.command(requires_connection=True) def logs( name: FQN = ServiceNameArgument, - container_name: str = typer.Option( - ..., - "--container-name", - help="Name of the container.", - show_default=False, - ), - instance_id: str = typer.Option( - ..., - "--instance-id", - help="ID of the service instance, starting with 0.", - show_default=False, - ), + container_name: str = container_name_option, + instance_id: str = instance_id_option, num_lines: int = typer.Option( DEFAULT_NUM_LINES, "--num-lines", help="Number of lines to retrieve." ), @@ -301,51 +323,33 @@ def logs( @app.command(requires_connection=True) def events( name: FQN = ServiceNameArgument, - container_name: str = typer.Option( - ..., - "--container-name", - help="Name of the container.", - show_default=False, - ), - instance_id: str = typer.Option( - ..., - "--instance-id", - help="ID of the service instance, starting with 0.", - show_default=False, - ), - since: str = typer.Option( - default="", - help="Fetch events that are newer than this time ago, in Snowflake interval syntax.", - ), - until: str = typer.Option( - default="", - help="Fetch events that are older than this time ago, in Snowflake interval syntax.", - ), + container_name: str = container_name_option, + instance_id: str = instance_id_option, + since: str = since_option, + until: str = until_option, first: int = typer.Option( - default=-1, + default=None, show_default=False, help="Fetch only the first N events. Cannot be used with --last.", ), last: int = typer.Option( - default=-1, + default=None, show_default=False, help="Fetch only the last N events. Cannot be used with --first.", ), - show_all_columns: bool = typer.Option( - False, - "--all", - is_flag=True, - help="Fetch all columns.", - ), + show_all_columns: bool = show_all_columns_option, **options, ): + """ + Retrieve platform events for a service container. + """ if FeatureFlag.ENABLE_SPCS_SERVICE_EVENTS.is_disabled(): raise FeatureNotEnabledError( "ENABLE_SPCS_SERVICE_EVENTS", "Service events collection from SPCS event table is disabled.", ) - if first >= 0 and last >= 0: + if first is not None and last is not None: raise IncompatibleParametersError(["--first", "--last"]) manager = ServiceManager() @@ -359,40 +363,26 @@ def events( last=last, show_all_columns=show_all_columns, ) + + if not events: + return MessageResult("No events found.") + return CollectionResult(events) @app.command(requires_connection=True) def metrics( name: FQN = ServiceNameArgument, - container_name: str = typer.Option( - ..., - "--container-name", - help="Name of the container.", - show_default=False, - ), - instance_id: str = typer.Option( - ..., - "--instance-id", - help="ID of the service instance, starting with 0.", - show_default=False, - ), - since: str = typer.Option( - default="", - help="Fetch events that are newer than this time ago, in Snowflake interval syntax.", - ), - until: str = typer.Option( - default="", - help="Fetch events that are older than this time ago, in Snowflake interval syntax.", - ), - show_all_columns: bool = typer.Option( - False, - "--all", - is_flag=True, - help="Fetch all columns.", - ), + container_name: str = container_name_option, + instance_id: str = instance_id_option, + since: str = since_option, + until: str = until_option, + show_all_columns: bool = show_all_columns_option, **options, ): + """ + Retrieve platform metrics for a service container. + """ if FeatureFlag.ENABLE_SPCS_SERVICE_METRICS.is_disabled(): raise FeatureNotEnabledError( "ENABLE_SPCS_SERVICE_METRICS", diff --git a/src/snowflake/cli/_plugins/spcs/services/manager.py b/src/snowflake/cli/_plugins/spcs/services/manager.py index ed53c3d87c..86d8dad9a5 100644 --- a/src/snowflake/cli/_plugins/spcs/services/manager.py +++ b/src/snowflake/cli/_plugins/spcs/services/manager.py @@ -223,8 +223,8 @@ def get_events( container_name: str, since: str | datetime | None = None, until: str | datetime | None = None, - first: int = -1, - last: int = -1, + first: Optional[int] = None, + last: Optional[int] = None, show_all_columns: bool = False, ): @@ -234,8 +234,8 @@ def get_events( ) since_clause, until_clause = build_time_clauses(since, until) - first_clause = f"limit {first}" if first >= 0 else "" - last_clause = f"limit {last}" if last >= 0 else "" + first_clause = f"limit {first}" if first is not None else "" + last_clause = f"limit {last}" if last is not None else "" query = f"""\ select * diff --git a/tests/__snapshots__/test_help_messages.ambr b/tests/__snapshots__/test_help_messages.ambr index bb2f3655ae..c47c99e1cc 100644 --- a/tests/__snapshots__/test_help_messages.ambr +++ b/tests/__snapshots__/test_help_messages.ambr @@ -578,6 +578,542 @@ +------------------------------------------------------------------------------+ + ''' +# --- +# name: test_help_messages[app.release-channel.add-accounts] + ''' + + Usage: default app release-channel add-accounts [OPTIONS] CHANNEL + + Adds accounts to a release channel. + + +- Arguments ------------------------------------------------------------------+ + | * channel TEXT The release channel to add accounts to. | + | [required] | + +------------------------------------------------------------------------------+ + +- Options --------------------------------------------------------------------+ + | * --target-accounts TEXT The accounts to add to the release | + | channel. Format has to be | + | org1.account1,org2.account2. | + | [required] | + | --package-entity-id TEXT The ID of the package entity on which | + | to operate when definition_version is | + | 2 or higher. | + | --app-entity-id TEXT The ID of the application entity on | + | which to operate when | + | definition_version is 2 or higher. | + | --project -p TEXT Path where Snowflake project resides. | + | Defaults to current working directory. | + | --env TEXT String in format of key=value. | + | Overrides variables from env section | + | used for templates. | + | --help -h Show this message and exit. | + +------------------------------------------------------------------------------+ + +- Connection configuration ---------------------------------------------------+ + | --connection,--environment -c TEXT Name of the connection, as | + | defined in your config.toml | + | file. Default: default. | + | --host TEXT Host address for the | + | connection. Overrides the | + | value specified for the | + | connection. | + | --port INTEGER Port for the connection. | + | Overrides the value | + | specified for the | + | connection. | + | --account,--accountname TEXT Name assigned to your | + | Snowflake account. Overrides | + | the value specified for the | + | connection. | + | --user,--username TEXT Username to connect to | + | Snowflake. Overrides the | + | value specified for the | + | connection. | + | --password TEXT Snowflake password. | + | Overrides the value | + | specified for the | + | connection. | + | --authenticator TEXT Snowflake authenticator. | + | Overrides the value | + | specified for the | + | connection. | + | --private-key-file,--private… TEXT Snowflake private key file | + | path. Overrides the value | + | specified for the | + | connection. | + | --token-file-path TEXT Path to file with an OAuth | + | token that should be used | + | when connecting to Snowflake | + | --database,--dbname TEXT Database to use. Overrides | + | the value specified for the | + | connection. | + | --schema,--schemaname TEXT Database schema to use. | + | Overrides the value | + | specified for the | + | connection. | + | --role,--rolename TEXT Role to use. Overrides the | + | value specified for the | + | connection. | + | --warehouse TEXT Warehouse to use. Overrides | + | the value specified for the | + | connection. | + | --temporary-connection -x Uses connection defined with | + | command line parameters, | + | instead of one defined in | + | config | + | --mfa-passcode TEXT Token to use for | + | multi-factor authentication | + | (MFA) | + | --enable-diag Run Python connector | + | diagnostic test | + | --diag-log-path TEXT Diagnostic report path | + | --diag-allowlist-path TEXT Diagnostic report path to | + | optional allowlist | + +------------------------------------------------------------------------------+ + +- Global configuration -------------------------------------------------------+ + | --format [TABLE|JSON] Specifies the output format. | + | [default: TABLE] | + | --verbose -v Displays log entries for log levels info | + | and higher. | + | --debug Displays log entries for log levels debug | + | and higher; debug logs contain additional | + | information. | + | --silent Turns off intermediate output to console. | + +------------------------------------------------------------------------------+ + + + ''' +# --- +# name: test_help_messages[app.release-channel.add-version] + ''' + + Usage: default app release-channel add-version [OPTIONS] CHANNEL + + Adds a version to a release channel. + + +- Arguments ------------------------------------------------------------------+ + | * channel TEXT The release channel to add a version to. | + | [required] | + +------------------------------------------------------------------------------+ + +- Options --------------------------------------------------------------------+ + | * --version TEXT The version to add to the release | + | channel. | + | [required] | + | --package-entity-id TEXT The ID of the package entity on which | + | to operate when definition_version is | + | 2 or higher. | + | --app-entity-id TEXT The ID of the application entity on | + | which to operate when | + | definition_version is 2 or higher. | + | --project -p TEXT Path where Snowflake project resides. | + | Defaults to current working directory. | + | --env TEXT String in format of key=value. | + | Overrides variables from env section | + | used for templates. | + | --help -h Show this message and exit. | + +------------------------------------------------------------------------------+ + +- Connection configuration ---------------------------------------------------+ + | --connection,--environment -c TEXT Name of the connection, as | + | defined in your config.toml | + | file. Default: default. | + | --host TEXT Host address for the | + | connection. Overrides the | + | value specified for the | + | connection. | + | --port INTEGER Port for the connection. | + | Overrides the value | + | specified for the | + | connection. | + | --account,--accountname TEXT Name assigned to your | + | Snowflake account. Overrides | + | the value specified for the | + | connection. | + | --user,--username TEXT Username to connect to | + | Snowflake. Overrides the | + | value specified for the | + | connection. | + | --password TEXT Snowflake password. | + | Overrides the value | + | specified for the | + | connection. | + | --authenticator TEXT Snowflake authenticator. | + | Overrides the value | + | specified for the | + | connection. | + | --private-key-file,--private… TEXT Snowflake private key file | + | path. Overrides the value | + | specified for the | + | connection. | + | --token-file-path TEXT Path to file with an OAuth | + | token that should be used | + | when connecting to Snowflake | + | --database,--dbname TEXT Database to use. Overrides | + | the value specified for the | + | connection. | + | --schema,--schemaname TEXT Database schema to use. | + | Overrides the value | + | specified for the | + | connection. | + | --role,--rolename TEXT Role to use. Overrides the | + | value specified for the | + | connection. | + | --warehouse TEXT Warehouse to use. Overrides | + | the value specified for the | + | connection. | + | --temporary-connection -x Uses connection defined with | + | command line parameters, | + | instead of one defined in | + | config | + | --mfa-passcode TEXT Token to use for | + | multi-factor authentication | + | (MFA) | + | --enable-diag Run Python connector | + | diagnostic test | + | --diag-log-path TEXT Diagnostic report path | + | --diag-allowlist-path TEXT Diagnostic report path to | + | optional allowlist | + +------------------------------------------------------------------------------+ + +- Global configuration -------------------------------------------------------+ + | --format [TABLE|JSON] Specifies the output format. | + | [default: TABLE] | + | --verbose -v Displays log entries for log levels info | + | and higher. | + | --debug Displays log entries for log levels debug | + | and higher; debug logs contain additional | + | information. | + | --silent Turns off intermediate output to console. | + +------------------------------------------------------------------------------+ + + + ''' +# --- +# name: test_help_messages[app.release-channel.list] + ''' + + Usage: default app release-channel list [OPTIONS] [CHANNEL] + + Lists the release channels available for an application package. + + +- Arguments ------------------------------------------------------------------+ + | channel [CHANNEL] The release channel to list. If not provided, all | + | release channels are listed. | + +------------------------------------------------------------------------------+ + +- Options --------------------------------------------------------------------+ + | --package-entity-id TEXT The ID of the package entity on which to | + | operate when definition_version is 2 or | + | higher. | + | --app-entity-id TEXT The ID of the application entity on which | + | to operate when definition_version is 2 | + | or higher. | + | --project -p TEXT Path where Snowflake project resides. | + | Defaults to current working directory. | + | --env TEXT String in format of key=value. Overrides | + | variables from env section used for | + | templates. | + | --help -h Show this message and exit. | + +------------------------------------------------------------------------------+ + +- Connection configuration ---------------------------------------------------+ + | --connection,--environment -c TEXT Name of the connection, as | + | defined in your config.toml | + | file. Default: default. | + | --host TEXT Host address for the | + | connection. Overrides the | + | value specified for the | + | connection. | + | --port INTEGER Port for the connection. | + | Overrides the value | + | specified for the | + | connection. | + | --account,--accountname TEXT Name assigned to your | + | Snowflake account. Overrides | + | the value specified for the | + | connection. | + | --user,--username TEXT Username to connect to | + | Snowflake. Overrides the | + | value specified for the | + | connection. | + | --password TEXT Snowflake password. | + | Overrides the value | + | specified for the | + | connection. | + | --authenticator TEXT Snowflake authenticator. | + | Overrides the value | + | specified for the | + | connection. | + | --private-key-file,--private… TEXT Snowflake private key file | + | path. Overrides the value | + | specified for the | + | connection. | + | --token-file-path TEXT Path to file with an OAuth | + | token that should be used | + | when connecting to Snowflake | + | --database,--dbname TEXT Database to use. Overrides | + | the value specified for the | + | connection. | + | --schema,--schemaname TEXT Database schema to use. | + | Overrides the value | + | specified for the | + | connection. | + | --role,--rolename TEXT Role to use. Overrides the | + | value specified for the | + | connection. | + | --warehouse TEXT Warehouse to use. Overrides | + | the value specified for the | + | connection. | + | --temporary-connection -x Uses connection defined with | + | command line parameters, | + | instead of one defined in | + | config | + | --mfa-passcode TEXT Token to use for | + | multi-factor authentication | + | (MFA) | + | --enable-diag Run Python connector | + | diagnostic test | + | --diag-log-path TEXT Diagnostic report path | + | --diag-allowlist-path TEXT Diagnostic report path to | + | optional allowlist | + +------------------------------------------------------------------------------+ + +- Global configuration -------------------------------------------------------+ + | --format [TABLE|JSON] Specifies the output format. | + | [default: TABLE] | + | --verbose -v Displays log entries for log levels info | + | and higher. | + | --debug Displays log entries for log levels debug | + | and higher; debug logs contain additional | + | information. | + | --silent Turns off intermediate output to console. | + +------------------------------------------------------------------------------+ + + + ''' +# --- +# name: test_help_messages[app.release-channel.remove-accounts] + ''' + + Usage: default app release-channel remove-accounts [OPTIONS] CHANNEL + + Removes accounts from a release channel. + + +- Arguments ------------------------------------------------------------------+ + | * channel TEXT The release channel to remove accounts from. | + | [required] | + +------------------------------------------------------------------------------+ + +- Options --------------------------------------------------------------------+ + | * --target-accounts TEXT The accounts to remove from the | + | release channel. Format has to be | + | org1.account1,org2.account2. | + | [required] | + | --package-entity-id TEXT The ID of the package entity on which | + | to operate when definition_version is | + | 2 or higher. | + | --app-entity-id TEXT The ID of the application entity on | + | which to operate when | + | definition_version is 2 or higher. | + | --project -p TEXT Path where Snowflake project resides. | + | Defaults to current working directory. | + | --env TEXT String in format of key=value. | + | Overrides variables from env section | + | used for templates. | + | --help -h Show this message and exit. | + +------------------------------------------------------------------------------+ + +- Connection configuration ---------------------------------------------------+ + | --connection,--environment -c TEXT Name of the connection, as | + | defined in your config.toml | + | file. Default: default. | + | --host TEXT Host address for the | + | connection. Overrides the | + | value specified for the | + | connection. | + | --port INTEGER Port for the connection. | + | Overrides the value | + | specified for the | + | connection. | + | --account,--accountname TEXT Name assigned to your | + | Snowflake account. Overrides | + | the value specified for the | + | connection. | + | --user,--username TEXT Username to connect to | + | Snowflake. Overrides the | + | value specified for the | + | connection. | + | --password TEXT Snowflake password. | + | Overrides the value | + | specified for the | + | connection. | + | --authenticator TEXT Snowflake authenticator. | + | Overrides the value | + | specified for the | + | connection. | + | --private-key-file,--private… TEXT Snowflake private key file | + | path. Overrides the value | + | specified for the | + | connection. | + | --token-file-path TEXT Path to file with an OAuth | + | token that should be used | + | when connecting to Snowflake | + | --database,--dbname TEXT Database to use. Overrides | + | the value specified for the | + | connection. | + | --schema,--schemaname TEXT Database schema to use. | + | Overrides the value | + | specified for the | + | connection. | + | --role,--rolename TEXT Role to use. Overrides the | + | value specified for the | + | connection. | + | --warehouse TEXT Warehouse to use. Overrides | + | the value specified for the | + | connection. | + | --temporary-connection -x Uses connection defined with | + | command line parameters, | + | instead of one defined in | + | config | + | --mfa-passcode TEXT Token to use for | + | multi-factor authentication | + | (MFA) | + | --enable-diag Run Python connector | + | diagnostic test | + | --diag-log-path TEXT Diagnostic report path | + | --diag-allowlist-path TEXT Diagnostic report path to | + | optional allowlist | + +------------------------------------------------------------------------------+ + +- Global configuration -------------------------------------------------------+ + | --format [TABLE|JSON] Specifies the output format. | + | [default: TABLE] | + | --verbose -v Displays log entries for log levels info | + | and higher. | + | --debug Displays log entries for log levels debug | + | and higher; debug logs contain additional | + | information. | + | --silent Turns off intermediate output to console. | + +------------------------------------------------------------------------------+ + + + ''' +# --- +# name: test_help_messages[app.release-channel.remove-version] + ''' + + Usage: default app release-channel remove-version [OPTIONS] CHANNEL + + Removes a version from a release channel. + + +- Arguments ------------------------------------------------------------------+ + | * channel TEXT The release channel to remove a version from. | + | [required] | + +------------------------------------------------------------------------------+ + +- Options --------------------------------------------------------------------+ + | * --version TEXT The version to remove from the release | + | channel. | + | [required] | + | --package-entity-id TEXT The ID of the package entity on which | + | to operate when definition_version is | + | 2 or higher. | + | --app-entity-id TEXT The ID of the application entity on | + | which to operate when | + | definition_version is 2 or higher. | + | --project -p TEXT Path where Snowflake project resides. | + | Defaults to current working directory. | + | --env TEXT String in format of key=value. | + | Overrides variables from env section | + | used for templates. | + | --help -h Show this message and exit. | + +------------------------------------------------------------------------------+ + +- Connection configuration ---------------------------------------------------+ + | --connection,--environment -c TEXT Name of the connection, as | + | defined in your config.toml | + | file. Default: default. | + | --host TEXT Host address for the | + | connection. Overrides the | + | value specified for the | + | connection. | + | --port INTEGER Port for the connection. | + | Overrides the value | + | specified for the | + | connection. | + | --account,--accountname TEXT Name assigned to your | + | Snowflake account. Overrides | + | the value specified for the | + | connection. | + | --user,--username TEXT Username to connect to | + | Snowflake. Overrides the | + | value specified for the | + | connection. | + | --password TEXT Snowflake password. | + | Overrides the value | + | specified for the | + | connection. | + | --authenticator TEXT Snowflake authenticator. | + | Overrides the value | + | specified for the | + | connection. | + | --private-key-file,--private… TEXT Snowflake private key file | + | path. Overrides the value | + | specified for the | + | connection. | + | --token-file-path TEXT Path to file with an OAuth | + | token that should be used | + | when connecting to Snowflake | + | --database,--dbname TEXT Database to use. Overrides | + | the value specified for the | + | connection. | + | --schema,--schemaname TEXT Database schema to use. | + | Overrides the value | + | specified for the | + | connection. | + | --role,--rolename TEXT Role to use. Overrides the | + | value specified for the | + | connection. | + | --warehouse TEXT Warehouse to use. Overrides | + | the value specified for the | + | connection. | + | --temporary-connection -x Uses connection defined with | + | command line parameters, | + | instead of one defined in | + | config | + | --mfa-passcode TEXT Token to use for | + | multi-factor authentication | + | (MFA) | + | --enable-diag Run Python connector | + | diagnostic test | + | --diag-log-path TEXT Diagnostic report path | + | --diag-allowlist-path TEXT Diagnostic report path to | + | optional allowlist | + +------------------------------------------------------------------------------+ + +- Global configuration -------------------------------------------------------+ + | --format [TABLE|JSON] Specifies the output format. | + | [default: TABLE] | + | --verbose -v Displays log entries for log levels info | + | and higher. | + | --debug Displays log entries for log levels debug | + | and higher; debug logs contain additional | + | information. | + | --silent Turns off intermediate output to console. | + +------------------------------------------------------------------------------+ + + + ''' +# --- +# name: test_help_messages[app.release-channel] + ''' + + Usage: default app release-channel [OPTIONS] COMMAND [ARGS]... + + Manages release channels of an application package + + +- Options --------------------------------------------------------------------+ + | --help -h Show this message and exit. | + +------------------------------------------------------------------------------+ + +- Commands -------------------------------------------------------------------+ + | add-accounts Adds accounts to a release channel. | + | add-version Adds a version to a release channel. | + | list Lists the release channels available for an application | + | package. | + | remove-accounts Removes accounts from a release channel. | + | remove-version Removes a version from a release channel. | + +------------------------------------------------------------------------------+ + + ''' # --- # name: test_help_messages[app.release-directive.list] @@ -1777,6 +2313,7 @@ | configured in Snowflake. | | open Opens the Snowflake Native App inside of your browser, | | once it has been installed in your account. | + | release-channel Manages release channels of an application package | | release-directive Manages release directives of an application package | | run Creates an application package in your Snowflake | | account, uploads code files to its stage, then creates | @@ -7095,6 +7632,8 @@ Usage: default spcs service events [OPTIONS] NAME + Retrieve platform events for a service container. + +- Arguments ------------------------------------------------------------------+ | * name TEXT Identifier of the service; for example: my_service | | [required] | @@ -7860,6 +8399,8 @@ Usage: default spcs service metrics [OPTIONS] NAME + Retrieve platform metrics for a service container. + +- Arguments ------------------------------------------------------------------+ | * name TEXT Identifier of the service; for example: my_service | | [required] | @@ -8561,7 +9102,8 @@ | schema. | | describe Provides description of service. | | drop Drops service with given name. | - | events | + | events Retrieve platform events for a service | + | container. | | execute-job Creates and executes a job service in the | | current schema. | | list Lists all available services. | @@ -8571,7 +9113,8 @@ | list-roles Lists all service roles in a service. | | logs Retrieves local logs from a service | | container. | - | metrics | + | metrics Retrieve platform metrics for a service | + | container. | | resume Resumes the service from a SUSPENDED state. | | set Sets one or more properties for the | | service. | @@ -10324,6 +10867,28 @@ +------------------------------------------------------------------------------+ + ''' +# --- +# name: test_help_messages_no_help_flag[app.release-channel] + ''' + + Usage: default app release-channel [OPTIONS] COMMAND [ARGS]... + + Manages release channels of an application package + + +- Options --------------------------------------------------------------------+ + | --help -h Show this message and exit. | + +------------------------------------------------------------------------------+ + +- Commands -------------------------------------------------------------------+ + | add-accounts Adds accounts to a release channel. | + | add-version Adds a version to a release channel. | + | list Lists the release channels available for an application | + | package. | + | remove-accounts Removes accounts from a release channel. | + | remove-version Removes a version from a release channel. | + +------------------------------------------------------------------------------+ + + ''' # --- # name: test_help_messages_no_help_flag[app.release-directive] @@ -10392,6 +10957,7 @@ | configured in Snowflake. | | open Opens the Snowflake Native App inside of your browser, | | once it has been installed in your account. | + | release-channel Manages release channels of an application package | | release-directive Manages release directives of an application package | | run Creates an application package in your Snowflake | | account, uploads code files to its stage, then creates | @@ -10643,7 +11209,8 @@ | schema. | | describe Provides description of service. | | drop Drops service with given name. | - | events | + | events Retrieve platform events for a service | + | container. | | execute-job Creates and executes a job service in the | | current schema. | | list Lists all available services. | @@ -10653,7 +11220,8 @@ | list-roles Lists all service roles in a service. | | logs Retrieves local logs from a service | | container. | - | metrics | + | metrics Retrieve platform metrics for a service | + | container. | | resume Resumes the service from a SUSPENDED state. | | set Sets one or more properties for the | | service. | diff --git a/tests/spcs/test_services.py b/tests/spcs/test_services.py index 88c68568d1..d06fbb86d9 100644 --- a/tests/spcs/test_services.py +++ b/tests/spcs/test_services.py @@ -13,6 +13,7 @@ # limitations under the License. import itertools import json +import re from datetime import datetime from pathlib import Path from textwrap import dedent @@ -997,9 +998,13 @@ def test_latest_metrics(mock_execute_query, mock_is_disabled, runner): " " ) - assert ( - actual_query == expected_query - ), f"Generated query does not match expected query.\n\nActual:\n{repr(actual_query)}\n\nExpected:\n{repr(expected_query)}" + actual_normalized = normalize_query(actual_query) + expected_normalized = normalize_query(expected_query) + + assert actual_normalized == expected_normalized, ( + f"Generated query does not match expected query.\n\n" + f"Actual:\n{actual_query}\n\nExpected:\n{expected_query}" + ) @patch( @@ -1547,3 +1552,8 @@ def test_command_aliases(mock_connector, runner, mock_ctx, command, parameters): queries = ctx.get_queries() assert queries[0] == queries[1] + + +def normalize_query(query): + """Normalize SQL query by stripping extra whitespace and formatting.""" + return re.sub(r"\s+", " ", query.strip())