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..bda84bd59d 100644 --- a/src/snowflake/cli/_plugins/spcs/services/commands.py +++ b/src/snowflake/cli/_plugins/spcs/services/commands.py @@ -322,12 +322,12 @@ def events( help="Fetch events that are older than this time ago, in Snowflake interval syntax.", ), 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.", ), @@ -339,13 +339,16 @@ def events( ), **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,6 +362,10 @@ def events( last=last, show_all_columns=show_all_columns, ) + + if not events: + return MessageResult("No events found.") + return CollectionResult(events) @@ -393,6 +400,9 @@ def metrics( ), **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..9e8d9b808d 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 | @@ -7088,109 +7625,6 @@ +------------------------------------------------------------------------------+ - ''' -# --- -# name: test_help_messages[spcs.service.events] - ''' - - Usage: default spcs service events [OPTIONS] NAME - - +- Arguments ------------------------------------------------------------------+ - | * name TEXT Identifier of the service; for example: my_service | - | [required] | - +------------------------------------------------------------------------------+ - +- Options --------------------------------------------------------------------+ - | * --container-name TEXT Name of the container. | - | [required] | - | * --instance-id TEXT ID of the service instance, starting | - | with 0. | - | [required] | - | --since TEXT Fetch events that are newer than this | - | time ago, in Snowflake interval | - | syntax. | - | --until TEXT Fetch events that are older than this | - | time ago, in Snowflake interval | - | syntax. | - | --first INTEGER Fetch only the first N events. Cannot | - | be used with --last. | - | --last INTEGER Fetch only the last N events. Cannot | - | be used with --first. | - | --all Fetch all columns. | - | --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[spcs.service.execute-job] @@ -7853,103 +8287,6 @@ +------------------------------------------------------------------------------+ - ''' -# --- -# name: test_help_messages[spcs.service.metrics] - ''' - - Usage: default spcs service metrics [OPTIONS] NAME - - +- Arguments ------------------------------------------------------------------+ - | * name TEXT Identifier of the service; for example: my_service | - | [required] | - +------------------------------------------------------------------------------+ - +- Options --------------------------------------------------------------------+ - | * --container-name TEXT Name of the container. | - | [required] | - | * --instance-id TEXT ID of the service instance, starting with | - | 0. | - | [required] | - | --since TEXT Fetch events that are newer than this | - | time ago, in Snowflake interval syntax. | - | --until TEXT Fetch events that are older than this | - | time ago, in Snowflake interval syntax. | - | --all Fetch all columns. | - | --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[spcs.service.resume] @@ -8561,7 +8898,6 @@ | schema. | | describe Provides description of service. | | drop Drops service with given name. | - | events | | execute-job Creates and executes a job service in the | | current schema. | | list Lists all available services. | @@ -8571,7 +8907,6 @@ | list-roles Lists all service roles in a service. | | logs Retrieves local logs from a service | | container. | - | metrics | | resume Resumes the service from a SUSPENDED state. | | set Sets one or more properties for the | | service. | @@ -10324,6 +10659,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 +10749,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 +11001,6 @@ | schema. | | describe Provides description of service. | | drop Drops service with given name. | - | events | | execute-job Creates and executes a job service in the | | current schema. | | list Lists all available services. | @@ -10653,7 +11010,6 @@ | list-roles Lists all service roles in a service. | | logs Retrieves local logs from a service | | container. | - | metrics | | 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())