diff --git a/superset-frontend/src/components/ErrorMessage/types.ts b/superset-frontend/src/components/ErrorMessage/types.ts index a85c2a1292..5ae5e7f85d 100644 --- a/superset-frontend/src/components/ErrorMessage/types.ts +++ b/superset-frontend/src/components/ErrorMessage/types.ts @@ -28,17 +28,13 @@ export const ErrorTypeEnum = { GENERIC_DB_ENGINE_ERROR: 'GENERIC_DB_ENGINE_ERROR', COLUMN_DOES_NOT_EXIST_ERROR: 'COLUMN_DOES_NOT_EXIST_ERROR', TABLE_DOES_NOT_EXIST_ERROR: 'TABLE_DOES_NOT_EXIST_ERROR', - TEST_CONNECTION_INVALID_USERNAME_ERROR: - 'TEST_CONNECTION_INVALID_USERNAME_ERROR', - TEST_CONNECTION_INVALID_PASSWORD_ERROR: - 'TEST_CONNECTION_INVALID_PASSWORD_ERROR', - TEST_CONNECTION_INVALID_HOSTNAME_ERROR: - 'TEST_CONNECTION_INVALID_HOSTNAME_ERROR', - TEST_CONNECTION_PORT_CLOSED_ERROR: 'TEST_CONNECTION_PORT_CLOSED_ERROR', - TEST_CONNECTION_HOST_DOWN_ERROR: 'TEST_CONNECTION_HOST_DOWN_ERROR', - TEST_CONNECTION_ACCESS_DENIED_ERROR: 'TEST_CONNECTION_ACCESS_DENIED_ERROR', - TEST_CONNECTION_UNKNOWN_DATABASE_ERROR: - 'TEST_CONNECTION_UNKNOWN_DATABASE_ERROR', + CONNECTION_INVALID_USERNAME_ERROR: 'CONNECTION_INVALID_USERNAME_ERROR', + CONNECTION_INVALID_PASSWORD_ERROR: 'CONNECTION_INVALID_PASSWORD_ERROR', + CONNECTION_INVALID_HOSTNAME_ERROR: 'CONNECTION_INVALID_HOSTNAME_ERROR', + CONNECTION_PORT_CLOSED_ERROR: 'CONNECTION_PORT_CLOSED_ERROR', + CONNECTION_HOST_DOWN_ERROR: 'CONNECTION_HOST_DOWN_ERROR', + CONNECTION_ACCESS_DENIED_ERROR: 'CONNECTION_ACCESS_DENIED_ERROR', + CONNECTION_UNKNOWN_DATABASE_ERROR: 'CONNECTION_UNKNOWN_DATABASE_ERROR', // Viz errors VIZ_GET_DF_ERROR: 'VIZ_GET_DF_ERROR', diff --git a/superset-frontend/src/setup/setupErrorMessages.ts b/superset-frontend/src/setup/setupErrorMessages.ts index ef34c3b7d3..aebebc34fb 100644 --- a/superset-frontend/src/setup/setupErrorMessages.ts +++ b/superset-frontend/src/setup/setupErrorMessages.ts @@ -52,15 +52,31 @@ export default function setupErrorMessages() { ParameterErrorMessage, ); errorMessageComponentRegistry.registerValue( - ErrorTypeEnum.TEST_CONNECTION_INVALID_HOSTNAME_ERROR, + ErrorTypeEnum.CONNECTION_INVALID_HOSTNAME_ERROR, DatabaseErrorMessage, ); errorMessageComponentRegistry.registerValue( - ErrorTypeEnum.TEST_CONNECTION_PORT_CLOSED_ERROR, + ErrorTypeEnum.CONNECTION_PORT_CLOSED_ERROR, DatabaseErrorMessage, ); errorMessageComponentRegistry.registerValue( - ErrorTypeEnum.TEST_CONNECTION_HOST_DOWN_ERROR, + ErrorTypeEnum.CONNECTION_HOST_DOWN_ERROR, + DatabaseErrorMessage, + ); + errorMessageComponentRegistry.registerValue( + ErrorTypeEnum.CONNECTION_INVALID_USERNAME_ERROR, + DatabaseErrorMessage, + ); + errorMessageComponentRegistry.registerValue( + ErrorTypeEnum.CONNECTION_INVALID_PASSWORD_ERROR, + DatabaseErrorMessage, + ); + errorMessageComponentRegistry.registerValue( + ErrorTypeEnum.CONNECTION_ACCESS_DENIED_ERROR, + DatabaseErrorMessage, + ); + errorMessageComponentRegistry.registerValue( + ErrorTypeEnum.CONNECTION_UNKNOWN_DATABASE_ERROR, DatabaseErrorMessage, ); setupErrorMessagesExtra(); diff --git a/superset/db_engine_specs/mssql.py b/superset/db_engine_specs/mssql.py index 51873ced34..980619778a 100644 --- a/superset/db_engine_specs/mssql.py +++ b/superset/db_engine_specs/mssql.py @@ -29,15 +29,15 @@ logger = logging.getLogger(__name__) # Regular expressions to catch custom errors -TEST_CONNECTION_ACCESS_DENIED_REGEX = re.compile("Adaptive Server connection failed") -TEST_CONNECTION_INVALID_HOSTNAME_REGEX = re.compile( +CONNECTION_ACCESS_DENIED_REGEX = re.compile("Adaptive Server connection failed") +CONNECTION_INVALID_HOSTNAME_REGEX = re.compile( r"Adaptive Server is unavailable or does not exist \((?P.*?)\)" "(?!.*Net-Lib error).*$" ) -TEST_CONNECTION_PORT_CLOSED_REGEX = re.compile( +CONNECTION_PORT_CLOSED_REGEX = re.compile( r"Net-Lib error during Connection refused \(61\)" ) -TEST_CONNECTION_HOST_DOWN_REGEX = re.compile( +CONNECTION_HOST_DOWN_REGEX = re.compile( r"Net-Lib error during Operation timed out \(60\)" ) @@ -65,24 +65,24 @@ class MssqlEngineSpec(BaseEngineSpec): } custom_errors = { - TEST_CONNECTION_ACCESS_DENIED_REGEX: ( + CONNECTION_ACCESS_DENIED_REGEX: ( __('Either the username "%(username)s" or the password is incorrect.'), - SupersetErrorType.TEST_CONNECTION_ACCESS_DENIED_ERROR, + SupersetErrorType.CONNECTION_ACCESS_DENIED_ERROR, ), - TEST_CONNECTION_INVALID_HOSTNAME_REGEX: ( + CONNECTION_INVALID_HOSTNAME_REGEX: ( __('The hostname "%(hostname)s" cannot be resolved.'), - SupersetErrorType.TEST_CONNECTION_INVALID_HOSTNAME_ERROR, + SupersetErrorType.CONNECTION_INVALID_HOSTNAME_ERROR, ), - TEST_CONNECTION_PORT_CLOSED_REGEX: ( + CONNECTION_PORT_CLOSED_REGEX: ( __('Port %(port)s on hostname "%(hostname)s" refused the connection.'), - SupersetErrorType.TEST_CONNECTION_PORT_CLOSED_ERROR, + SupersetErrorType.CONNECTION_PORT_CLOSED_ERROR, ), - TEST_CONNECTION_HOST_DOWN_REGEX: ( + CONNECTION_HOST_DOWN_REGEX: ( __( 'The host "%(hostname)s" might be down, and can\'t be ' "reached on port %(port)s." ), - SupersetErrorType.TEST_CONNECTION_HOST_DOWN_ERROR, + SupersetErrorType.CONNECTION_HOST_DOWN_ERROR, ), } diff --git a/superset/db_engine_specs/mysql.py b/superset/db_engine_specs/mysql.py index 049ff16795..e9b46b634f 100644 --- a/superset/db_engine_specs/mysql.py +++ b/superset/db_engine_specs/mysql.py @@ -41,18 +41,16 @@ from superset.utils import core as utils from superset.utils.core import ColumnSpec, GenericDataType # Regular expressions to catch custom errors -TEST_CONNECTION_ACCESS_DENIED_REGEX = re.compile( +CONNECTION_ACCESS_DENIED_REGEX = re.compile( "Access denied for user '(?P.*?)'@'(?P.*?)'. " ) -TEST_CONNECTION_INVALID_HOSTNAME_REGEX = re.compile( +CONNECTION_INVALID_HOSTNAME_REGEX = re.compile( "Unknown MySQL server host '(?P.*?)'." ) -TEST_CONNECTION_HOST_DOWN_REGEX = re.compile( +CONNECTION_HOST_DOWN_REGEX = re.compile( "Can't connect to MySQL server on '(?P.*?)'." ) -TEST_CONNECTION_UNKNOWN_DATABASE_REGEX = re.compile( - "Unknown database '(?P.*?)'." -) +CONNECTION_UNKNOWN_DATABASE_REGEX = re.compile("Unknown database '(?P.*?)'.") class MySQLEngineSpec(BaseEngineSpec): @@ -110,24 +108,24 @@ class MySQLEngineSpec(BaseEngineSpec): type_code_map: Dict[int, str] = {} # loaded from get_datatype only if needed custom_errors = { - TEST_CONNECTION_ACCESS_DENIED_REGEX: ( + CONNECTION_ACCESS_DENIED_REGEX: ( __('Either the username "%(username)s" or the password is incorrect.'), - SupersetErrorType.TEST_CONNECTION_ACCESS_DENIED_ERROR, + SupersetErrorType.CONNECTION_ACCESS_DENIED_ERROR, ), - TEST_CONNECTION_INVALID_HOSTNAME_REGEX: ( + CONNECTION_INVALID_HOSTNAME_REGEX: ( __('Unknown MySQL server host "%(hostname)s".'), - SupersetErrorType.TEST_CONNECTION_INVALID_HOSTNAME_ERROR, + SupersetErrorType.CONNECTION_INVALID_HOSTNAME_ERROR, ), - TEST_CONNECTION_HOST_DOWN_REGEX: ( + CONNECTION_HOST_DOWN_REGEX: ( __('The host "%(hostname)s" might be down and can\'t be reached.'), - SupersetErrorType.TEST_CONNECTION_HOST_DOWN_ERROR, + SupersetErrorType.CONNECTION_HOST_DOWN_ERROR, ), - TEST_CONNECTION_UNKNOWN_DATABASE_REGEX: ( + CONNECTION_UNKNOWN_DATABASE_REGEX: ( __( 'We were unable to connect to your database named "%(database)s". ' "Please verify your database name and try again." ), - SupersetErrorType.TEST_CONNECTION_UNKNOWN_DATABASE_ERROR, + SupersetErrorType.CONNECTION_UNKNOWN_DATABASE_ERROR, ), } diff --git a/superset/db_engine_specs/postgres.py b/superset/db_engine_specs/postgres.py index 9de1264379..1dc91a9931 100644 --- a/superset/db_engine_specs/postgres.py +++ b/superset/db_engine_specs/postgres.py @@ -56,27 +56,27 @@ class FixedOffsetTimezone(_FixedOffset): # Regular expressions to catch custom errors -TEST_CONNECTION_INVALID_USERNAME_REGEX = re.compile( +CONNECTION_INVALID_USERNAME_REGEX = re.compile( 'role "(?P.*?)" does not exist' ) -TEST_CONNECTION_INVALID_PASSWORD_REGEX = re.compile( +CONNECTION_INVALID_PASSWORD_REGEX = re.compile( 'password authentication failed for user "(?P.*?)"' ) -TEST_CONNECTION_INVALID_HOSTNAME_REGEX = re.compile( +CONNECTION_INVALID_HOSTNAME_REGEX = re.compile( 'could not translate host name "(?P.*?)" to address: ' "nodename nor servname provided, or not known" ) -TEST_CONNECTION_PORT_CLOSED_REGEX = re.compile( +CONNECTION_PORT_CLOSED_REGEX = re.compile( r"could not connect to server: Connection refused\s+Is the server " r'running on host "(?P.*?)" (\(.*?\) )?and accepting\s+TCP/IP ' r"connections on port (?P.*?)\?" ) -TEST_CONNECTION_HOST_DOWN_REGEX = re.compile( +CONNECTION_HOST_DOWN_REGEX = re.compile( r"could not connect to server: (?P.*?)\s+Is the server running on " r'host "(?P.*?)" (\(.*?\) )?and accepting\s+TCP/IP ' r"connections on port (?P.*?)\?" ) -TEST_CONNECTION_UNKNOWN_DATABASE_REGEX = re.compile( +CONNECTION_UNKNOWN_DATABASE_REGEX = re.compile( 'database "(?P.*?)" does not exist' ) @@ -100,35 +100,35 @@ class PostgresBaseEngineSpec(BaseEngineSpec): } custom_errors = { - TEST_CONNECTION_INVALID_USERNAME_REGEX: ( + CONNECTION_INVALID_USERNAME_REGEX: ( __('The username "%(username)s" does not exist.'), - SupersetErrorType.TEST_CONNECTION_INVALID_USERNAME_ERROR, + SupersetErrorType.CONNECTION_INVALID_USERNAME_ERROR, ), - TEST_CONNECTION_INVALID_PASSWORD_REGEX: ( + CONNECTION_INVALID_PASSWORD_REGEX: ( __('The password provided for username "%(username)s" is incorrect.'), - SupersetErrorType.TEST_CONNECTION_INVALID_PASSWORD_ERROR, + SupersetErrorType.CONNECTION_INVALID_PASSWORD_ERROR, ), - TEST_CONNECTION_INVALID_HOSTNAME_REGEX: ( + CONNECTION_INVALID_HOSTNAME_REGEX: ( __('The hostname "%(hostname)s" cannot be resolved.'), - SupersetErrorType.TEST_CONNECTION_INVALID_HOSTNAME_ERROR, + SupersetErrorType.CONNECTION_INVALID_HOSTNAME_ERROR, ), - TEST_CONNECTION_PORT_CLOSED_REGEX: ( + CONNECTION_PORT_CLOSED_REGEX: ( __('Port %(port)s on hostname "%(hostname)s" refused the connection.'), - SupersetErrorType.TEST_CONNECTION_PORT_CLOSED_ERROR, + SupersetErrorType.CONNECTION_PORT_CLOSED_ERROR, ), - TEST_CONNECTION_HOST_DOWN_REGEX: ( + CONNECTION_HOST_DOWN_REGEX: ( __( 'The host "%(hostname)s" might be down, and can\'t be ' "reached on port %(port)s." ), - SupersetErrorType.TEST_CONNECTION_HOST_DOWN_ERROR, + SupersetErrorType.CONNECTION_HOST_DOWN_ERROR, ), - TEST_CONNECTION_UNKNOWN_DATABASE_REGEX: ( + CONNECTION_UNKNOWN_DATABASE_REGEX: ( __( 'We were unable to connect to your database named "%(database)s".' " Please verify your database name and try again." ), - SupersetErrorType.TEST_CONNECTION_UNKNOWN_DATABASE_ERROR, + SupersetErrorType.CONNECTION_UNKNOWN_DATABASE_ERROR, ), } diff --git a/superset/db_engine_specs/redshift.py b/superset/db_engine_specs/redshift.py index 113cadf98d..60953f575d 100644 --- a/superset/db_engine_specs/redshift.py +++ b/superset/db_engine_specs/redshift.py @@ -22,24 +22,24 @@ from superset.db_engine_specs.postgres import PostgresBaseEngineSpec from superset.errors import SupersetErrorType # Regular expressions to catch custom errors -TEST_CONNECTION_ACCESS_DENIED_REGEX = re.compile( +CONNECTION_ACCESS_DENIED_REGEX = re.compile( 'password authentication failed for user "(?P.*?)"' ) -TEST_CONNECTION_INVALID_HOSTNAME_REGEX = re.compile( +CONNECTION_INVALID_HOSTNAME_REGEX = re.compile( 'could not translate host name "(?P.*?)" to address: ' "nodename nor servname provided, or not known" ) -TEST_CONNECTION_PORT_CLOSED_REGEX = re.compile( +CONNECTION_PORT_CLOSED_REGEX = re.compile( r"could not connect to server: Connection refused\s+Is the server " r'running on host "(?P.*?)" (\(.*?\) )?and accepting\s+TCP/IP ' r"connections on port (?P.*?)\?" ) -TEST_CONNECTION_HOST_DOWN_REGEX = re.compile( +CONNECTION_HOST_DOWN_REGEX = re.compile( r"could not connect to server: (?P.*?)\s+Is the server running on " r'host "(?P.*?)" (\(.*?\) )?and accepting\s+TCP/IP ' r"connections on port (?P.*?)\?" ) -TEST_CONNECTION_UNKNOWN_DATABASE_REGEX = re.compile( +CONNECTION_UNKNOWN_DATABASE_REGEX = re.compile( 'database "(?P.*?)" does not exist' ) @@ -50,31 +50,31 @@ class RedshiftEngineSpec(PostgresBaseEngineSpec): max_column_name_length = 127 custom_errors = { - TEST_CONNECTION_ACCESS_DENIED_REGEX: ( + CONNECTION_ACCESS_DENIED_REGEX: ( __('Either the username "%(username)s" or the password is incorrect.'), - SupersetErrorType.TEST_CONNECTION_ACCESS_DENIED_ERROR, + SupersetErrorType.CONNECTION_ACCESS_DENIED_ERROR, ), - TEST_CONNECTION_INVALID_HOSTNAME_REGEX: ( + CONNECTION_INVALID_HOSTNAME_REGEX: ( __('The hostname "%(hostname)s" cannot be resolved.'), - SupersetErrorType.TEST_CONNECTION_INVALID_HOSTNAME_ERROR, + SupersetErrorType.CONNECTION_INVALID_HOSTNAME_ERROR, ), - TEST_CONNECTION_PORT_CLOSED_REGEX: ( + CONNECTION_PORT_CLOSED_REGEX: ( __('Port %(port)s on hostname "%(hostname)s" refused the connection.'), - SupersetErrorType.TEST_CONNECTION_PORT_CLOSED_ERROR, + SupersetErrorType.CONNECTION_PORT_CLOSED_ERROR, ), - TEST_CONNECTION_HOST_DOWN_REGEX: ( + CONNECTION_HOST_DOWN_REGEX: ( __( 'The host "%(hostname)s" might be down, and can\'t be ' "reached on port %(port)s." ), - SupersetErrorType.TEST_CONNECTION_HOST_DOWN_ERROR, + SupersetErrorType.CONNECTION_HOST_DOWN_ERROR, ), - TEST_CONNECTION_UNKNOWN_DATABASE_REGEX: ( + CONNECTION_UNKNOWN_DATABASE_REGEX: ( __( 'We were unable to connect to your database named "%(database)s".' " Please verify your database name and try again." ), - SupersetErrorType.TEST_CONNECTION_UNKNOWN_DATABASE_ERROR, + SupersetErrorType.CONNECTION_UNKNOWN_DATABASE_ERROR, ), } diff --git a/superset/errors.py b/superset/errors.py index dc60083612..d8049719cf 100644 --- a/superset/errors.py +++ b/superset/errors.py @@ -39,13 +39,13 @@ class SupersetErrorType(str, Enum): GENERIC_DB_ENGINE_ERROR = "GENERIC_DB_ENGINE_ERROR" COLUMN_DOES_NOT_EXIST_ERROR = "COLUMN_DOES_NOT_EXIST_ERROR" TABLE_DOES_NOT_EXIST_ERROR = "TABLE_DOES_NOT_EXIST_ERROR" - TEST_CONNECTION_INVALID_USERNAME_ERROR = "TEST_CONNECTION_INVALID_USERNAME_ERROR" - TEST_CONNECTION_INVALID_PASSWORD_ERROR = "TEST_CONNECTION_INVALID_PASSWORD_ERROR" - TEST_CONNECTION_INVALID_HOSTNAME_ERROR = "TEST_CONNECTION_INVALID_HOSTNAME_ERROR" - TEST_CONNECTION_PORT_CLOSED_ERROR = "TEST_CONNECTION_PORT_CLOSED_ERROR" - TEST_CONNECTION_HOST_DOWN_ERROR = "TEST_CONNECTION_HOST_DOWN_ERROR" - TEST_CONNECTION_ACCESS_DENIED_ERROR = "TEST_CONNECTION_ACCESS_DENIED_ERROR" - TEST_CONNECTION_UNKNOWN_DATABASE_ERROR = "TEST_CONNECTION_UNKNOWN_DATABASE_ERROR" + CONNECTION_INVALID_USERNAME_ERROR = "CONNECTION_INVALID_USERNAME_ERROR" + CONNECTION_INVALID_PASSWORD_ERROR = "CONNECTION_INVALID_PASSWORD_ERROR" + CONNECTION_INVALID_HOSTNAME_ERROR = "CONNECTION_INVALID_HOSTNAME_ERROR" + CONNECTION_PORT_CLOSED_ERROR = "CONNECTION_PORT_CLOSED_ERROR" + CONNECTION_HOST_DOWN_ERROR = "CONNECTION_HOST_DOWN_ERROR" + CONNECTION_ACCESS_DENIED_ERROR = "CONNECTION_ACCESS_DENIED_ERROR" + CONNECTION_UNKNOWN_DATABASE_ERROR = "CONNECTION_UNKNOWN_DATABASE_ERROR" # Viz errors VIZ_GET_DF_ERROR = "VIZ_GET_DF_ERROR" @@ -125,16 +125,16 @@ ERROR_TYPES_TO_ISSUE_CODES_MAPPING = { ), }, ], - SupersetErrorType.TEST_CONNECTION_INVALID_HOSTNAME_ERROR: [ + SupersetErrorType.CONNECTION_INVALID_HOSTNAME_ERROR: [ { "code": 1007, "message": _("Issue 1007 - The hostname provided can't be resolved."), }, ], - SupersetErrorType.TEST_CONNECTION_PORT_CLOSED_ERROR: [ + SupersetErrorType.CONNECTION_PORT_CLOSED_ERROR: [ {"code": 1008, "message": _("Issue 1008 - The port is closed."),}, ], - SupersetErrorType.TEST_CONNECTION_HOST_DOWN_ERROR: [ + SupersetErrorType.CONNECTION_HOST_DOWN_ERROR: [ { "code": 1009, "message": _( @@ -157,7 +157,7 @@ ERROR_TYPES_TO_ISSUE_CODES_MAPPING = { "message": _("Issue 1011 - Superset encountered an unexpected error."), }, ], - SupersetErrorType.TEST_CONNECTION_INVALID_USERNAME_ERROR: [ + SupersetErrorType.CONNECTION_INVALID_USERNAME_ERROR: [ { "code": 1012, "message": _( @@ -166,7 +166,7 @@ ERROR_TYPES_TO_ISSUE_CODES_MAPPING = { ), }, ], - SupersetErrorType.TEST_CONNECTION_INVALID_PASSWORD_ERROR: [ + SupersetErrorType.CONNECTION_INVALID_PASSWORD_ERROR: [ { "code": 1013, "message": _( @@ -175,13 +175,13 @@ ERROR_TYPES_TO_ISSUE_CODES_MAPPING = { ), }, ], - SupersetErrorType.TEST_CONNECTION_ACCESS_DENIED_ERROR: [ + SupersetErrorType.CONNECTION_ACCESS_DENIED_ERROR: [ { "code": 1014, "message": _("Issue 1014 - Either the username or the password is wrong."), } ], - SupersetErrorType.TEST_CONNECTION_UNKNOWN_DATABASE_ERROR: [ + SupersetErrorType.CONNECTION_UNKNOWN_DATABASE_ERROR: [ { "code": 1015, "message": _( diff --git a/tests/databases/api_tests.py b/tests/databases/api_tests.py index cc360a09b1..39a73e6e61 100644 --- a/tests/databases/api_tests.py +++ b/tests/databases/api_tests.py @@ -915,7 +915,7 @@ class TestDatabaseApi(SupersetTestCase): mock_build_db.return_value.db_engine_spec.__name__ = "Some name" superset_error = SupersetError( message='Unable to resolve hostname "locahost".', - error_type="TEST_CONNECTION_INVALID_HOSTNAME_ERROR", + error_type="CONNECTION_INVALID_HOSTNAME_ERROR", level="error", extra={ "hostname": "locahost", diff --git a/tests/db_engine_specs/mssql_tests.py b/tests/db_engine_specs/mssql_tests.py index cfc75cf09e..0822f426ee 100644 --- a/tests/db_engine_specs/mssql_tests.py +++ b/tests/db_engine_specs/mssql_tests.py @@ -165,7 +165,7 @@ Unable to connect: Adaptive Server is unavailable or does not exist (locahost) result = MssqlEngineSpec.extract_errors(Exception(msg)) assert result == [ SupersetError( - error_type=SupersetErrorType.TEST_CONNECTION_INVALID_HOSTNAME_ERROR, + error_type=SupersetErrorType.CONNECTION_INVALID_HOSTNAME_ERROR, message='The hostname "locahost" cannot be resolved.', level=ErrorLevel.ERROR, extra={ @@ -195,7 +195,7 @@ Net-Lib error during Connection refused (61) ) assert result == [ SupersetError( - error_type=SupersetErrorType.TEST_CONNECTION_PORT_CLOSED_ERROR, + error_type=SupersetErrorType.CONNECTION_PORT_CLOSED_ERROR, message='Port 12345 on hostname "localhost" refused the connection.', level=ErrorLevel.ERROR, extra={ @@ -222,7 +222,7 @@ Net-Lib error during Operation timed out (60) ) assert result == [ SupersetError( - error_type=SupersetErrorType.TEST_CONNECTION_HOST_DOWN_ERROR, + error_type=SupersetErrorType.CONNECTION_HOST_DOWN_ERROR, message=( 'The host "example.com" might be down, ' "and can't be reached on port 12345." @@ -255,7 +255,7 @@ Net-Lib error during Operation timed out (60) ) assert result == [ SupersetError( - error_type=SupersetErrorType.TEST_CONNECTION_HOST_DOWN_ERROR, + error_type=SupersetErrorType.CONNECTION_HOST_DOWN_ERROR, message=( 'The host "93.184.216.34" might be down, ' "and can't be reached on port 12345." @@ -289,7 +289,7 @@ Adaptive Server connection failed (mssqldb.cxiotftzsypc.us-west-2.rds.amazonaws. assert result == [ SupersetError( message='Either the username "testuser" or the password is incorrect.', - error_type=SupersetErrorType.TEST_CONNECTION_ACCESS_DENIED_ERROR, + error_type=SupersetErrorType.CONNECTION_ACCESS_DENIED_ERROR, level=ErrorLevel.ERROR, extra={ "engine_name": "Microsoft SQL", diff --git a/tests/db_engine_specs/mysql_tests.py b/tests/db_engine_specs/mysql_tests.py index f619bdd066..e732bf4381 100644 --- a/tests/db_engine_specs/mysql_tests.py +++ b/tests/db_engine_specs/mysql_tests.py @@ -114,7 +114,7 @@ class TestMySQLEngineSpecsDbEngineSpec(TestDbEngineSpec): result = MySQLEngineSpec.extract_errors(Exception(msg)) assert result == [ SupersetError( - error_type=SupersetErrorType.TEST_CONNECTION_ACCESS_DENIED_ERROR, + error_type=SupersetErrorType.CONNECTION_ACCESS_DENIED_ERROR, message='Either the username "test" or the password is incorrect.', level=ErrorLevel.ERROR, extra={ @@ -134,7 +134,7 @@ class TestMySQLEngineSpecsDbEngineSpec(TestDbEngineSpec): result = MySQLEngineSpec.extract_errors(Exception(msg)) assert result == [ SupersetError( - error_type=SupersetErrorType.TEST_CONNECTION_INVALID_HOSTNAME_ERROR, + error_type=SupersetErrorType.CONNECTION_INVALID_HOSTNAME_ERROR, message='Unknown MySQL server host "badhostname.com".', level=ErrorLevel.ERROR, extra={ @@ -154,7 +154,7 @@ class TestMySQLEngineSpecsDbEngineSpec(TestDbEngineSpec): result = MySQLEngineSpec.extract_errors(Exception(msg)) assert result == [ SupersetError( - error_type=SupersetErrorType.TEST_CONNECTION_HOST_DOWN_ERROR, + error_type=SupersetErrorType.CONNECTION_HOST_DOWN_ERROR, message='The host "badconnection.com" might be ' "down and can't be reached.", level=ErrorLevel.ERROR, @@ -175,7 +175,7 @@ class TestMySQLEngineSpecsDbEngineSpec(TestDbEngineSpec): result = MySQLEngineSpec.extract_errors(Exception(msg)) assert result == [ SupersetError( - error_type=SupersetErrorType.TEST_CONNECTION_HOST_DOWN_ERROR, + error_type=SupersetErrorType.CONNECTION_HOST_DOWN_ERROR, message='The host "93.184.216.34" might be down and can\'t be reached.', level=ErrorLevel.ERROR, extra={ @@ -195,7 +195,7 @@ class TestMySQLEngineSpecsDbEngineSpec(TestDbEngineSpec): result = MySQLEngineSpec.extract_errors(Exception(msg)) assert result == [ SupersetError( - error_type=SupersetErrorType.TEST_CONNECTION_UNKNOWN_DATABASE_ERROR, + error_type=SupersetErrorType.CONNECTION_UNKNOWN_DATABASE_ERROR, message='We were unable to connect to your database named "badDB".' " Please verify your database name and try again.", level=ErrorLevel.ERROR, diff --git a/tests/db_engine_specs/postgres_tests.py b/tests/db_engine_specs/postgres_tests.py index 164c1211d6..2121e929e9 100644 --- a/tests/db_engine_specs/postgres_tests.py +++ b/tests/db_engine_specs/postgres_tests.py @@ -220,7 +220,7 @@ class TestPostgresDbEngineSpec(TestDbEngineSpec): result = PostgresEngineSpec.extract_errors(Exception(msg)) assert result == [ SupersetError( - error_type=SupersetErrorType.TEST_CONNECTION_INVALID_USERNAME_ERROR, + error_type=SupersetErrorType.CONNECTION_INVALID_USERNAME_ERROR, message='The username "testuser" does not exist.', level=ErrorLevel.ERROR, extra={ @@ -245,7 +245,7 @@ class TestPostgresDbEngineSpec(TestDbEngineSpec): result = PostgresEngineSpec.extract_errors(Exception(msg)) assert result == [ SupersetError( - error_type=SupersetErrorType.TEST_CONNECTION_INVALID_HOSTNAME_ERROR, + error_type=SupersetErrorType.CONNECTION_INVALID_HOSTNAME_ERROR, message='The hostname "locahost" cannot be resolved.', level=ErrorLevel.ERROR, extra={ @@ -274,7 +274,7 @@ could not connect to server: Connection refused result = PostgresEngineSpec.extract_errors(Exception(msg)) assert result == [ SupersetError( - error_type=SupersetErrorType.TEST_CONNECTION_PORT_CLOSED_ERROR, + error_type=SupersetErrorType.CONNECTION_PORT_CLOSED_ERROR, message='Port 12345 on hostname "localhost" refused the connection.', level=ErrorLevel.ERROR, extra={ @@ -296,7 +296,7 @@ psql: error: could not connect to server: Operation timed out result = PostgresEngineSpec.extract_errors(Exception(msg)) assert result == [ SupersetError( - error_type=SupersetErrorType.TEST_CONNECTION_HOST_DOWN_ERROR, + error_type=SupersetErrorType.CONNECTION_HOST_DOWN_ERROR, message=( 'The host "example.com" might be down, ' "and can't be reached on port 12345." @@ -326,7 +326,7 @@ psql: error: could not connect to server: Operation timed out result = PostgresEngineSpec.extract_errors(Exception(msg)) assert result == [ SupersetError( - error_type=SupersetErrorType.TEST_CONNECTION_HOST_DOWN_ERROR, + error_type=SupersetErrorType.CONNECTION_HOST_DOWN_ERROR, message=( 'The host "93.184.216.34" might be down, ' "and can't be reached on port 12345." @@ -349,7 +349,7 @@ psql: error: could not connect to server: Operation timed out result = PostgresEngineSpec.extract_errors(Exception(msg)) assert result == [ SupersetError( - error_type=SupersetErrorType.TEST_CONNECTION_INVALID_PASSWORD_ERROR, + error_type=SupersetErrorType.CONNECTION_INVALID_PASSWORD_ERROR, message=('The password provided for username "postgres" is incorrect.'), level=ErrorLevel.ERROR, extra={ @@ -371,7 +371,7 @@ psql: error: could not connect to server: Operation timed out result = PostgresEngineSpec.extract_errors(Exception(msg)) assert result == [ SupersetError( - error_type=SupersetErrorType.TEST_CONNECTION_UNKNOWN_DATABASE_ERROR, + error_type=SupersetErrorType.CONNECTION_UNKNOWN_DATABASE_ERROR, message='We were unable to connect to your database named "badDB".' " Please verify your database name and try again.", level=ErrorLevel.ERROR, diff --git a/tests/db_engine_specs/redshift_tests.py b/tests/db_engine_specs/redshift_tests.py index fa0353d1af..ff97ebee42 100644 --- a/tests/db_engine_specs/redshift_tests.py +++ b/tests/db_engine_specs/redshift_tests.py @@ -31,7 +31,7 @@ class TestRedshiftDbEngineSpec(TestDbEngineSpec): result = RedshiftEngineSpec.extract_errors(Exception(msg)) assert result == [ SupersetError( - error_type=SupersetErrorType.TEST_CONNECTION_ACCESS_DENIED_ERROR, + error_type=SupersetErrorType.CONNECTION_ACCESS_DENIED_ERROR, message='Either the username "wronguser" or the password is incorrect.', level=ErrorLevel.ERROR, extra={ @@ -54,7 +54,7 @@ class TestRedshiftDbEngineSpec(TestDbEngineSpec): result = RedshiftEngineSpec.extract_errors(Exception(msg)) assert result == [ SupersetError( - error_type=SupersetErrorType.TEST_CONNECTION_INVALID_HOSTNAME_ERROR, + error_type=SupersetErrorType.CONNECTION_INVALID_HOSTNAME_ERROR, message='The hostname "badhost" cannot be resolved.', level=ErrorLevel.ERROR, extra={ @@ -82,7 +82,7 @@ could not connect to server: Connection refused result = RedshiftEngineSpec.extract_errors(Exception(msg)) assert result == [ SupersetError( - error_type=SupersetErrorType.TEST_CONNECTION_PORT_CLOSED_ERROR, + error_type=SupersetErrorType.CONNECTION_PORT_CLOSED_ERROR, message='Port 12345 on hostname "localhost" refused the connection.', level=ErrorLevel.ERROR, extra={ @@ -104,7 +104,7 @@ psql: error: could not connect to server: Operation timed out result = RedshiftEngineSpec.extract_errors(Exception(msg)) assert result == [ SupersetError( - error_type=SupersetErrorType.TEST_CONNECTION_HOST_DOWN_ERROR, + error_type=SupersetErrorType.CONNECTION_HOST_DOWN_ERROR, message=( 'The host "example.com" might be down, ' "and can't be reached on port 12345." @@ -134,7 +134,7 @@ psql: error: could not connect to server: Operation timed out result = RedshiftEngineSpec.extract_errors(Exception(msg)) assert result == [ SupersetError( - error_type=SupersetErrorType.TEST_CONNECTION_HOST_DOWN_ERROR, + error_type=SupersetErrorType.CONNECTION_HOST_DOWN_ERROR, message=( 'The host "93.184.216.34" might be down, ' "and can't be reached on port 12345." @@ -157,7 +157,7 @@ psql: error: could not connect to server: Operation timed out result = RedshiftEngineSpec.extract_errors(Exception(msg)) assert result == [ SupersetError( - error_type=SupersetErrorType.TEST_CONNECTION_UNKNOWN_DATABASE_ERROR, + error_type=SupersetErrorType.CONNECTION_UNKNOWN_DATABASE_ERROR, message='We were unable to connect to your database named "badDB".' " Please verify your database name and try again.", level=ErrorLevel.ERROR,