chore: rename connection errors (#14169)

This commit is contained in:
Beto Dealmeida 2021-04-15 10:57:02 -07:00 committed by GitHub
parent c1cb3619ab
commit 21c6efea67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 121 additions and 111 deletions

View File

@ -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',

View File

@ -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();

View File

@ -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<hostname>.*?)\)"
"(?!.*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,
),
}

View File

@ -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<username>.*?)'@'(?P<hostname>.*?)'. "
)
TEST_CONNECTION_INVALID_HOSTNAME_REGEX = re.compile(
CONNECTION_INVALID_HOSTNAME_REGEX = re.compile(
"Unknown MySQL server host '(?P<hostname>.*?)'."
)
TEST_CONNECTION_HOST_DOWN_REGEX = re.compile(
CONNECTION_HOST_DOWN_REGEX = re.compile(
"Can't connect to MySQL server on '(?P<hostname>.*?)'."
)
TEST_CONNECTION_UNKNOWN_DATABASE_REGEX = re.compile(
"Unknown database '(?P<database>.*?)'."
)
CONNECTION_UNKNOWN_DATABASE_REGEX = re.compile("Unknown database '(?P<database>.*?)'.")
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,
),
}

View File

@ -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<username>.*?)" does not exist'
)
TEST_CONNECTION_INVALID_PASSWORD_REGEX = re.compile(
CONNECTION_INVALID_PASSWORD_REGEX = re.compile(
'password authentication failed for user "(?P<username>.*?)"'
)
TEST_CONNECTION_INVALID_HOSTNAME_REGEX = re.compile(
CONNECTION_INVALID_HOSTNAME_REGEX = re.compile(
'could not translate host name "(?P<hostname>.*?)" 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<hostname>.*?)" (\(.*?\) )?and accepting\s+TCP/IP '
r"connections on port (?P<port>.*?)\?"
)
TEST_CONNECTION_HOST_DOWN_REGEX = re.compile(
CONNECTION_HOST_DOWN_REGEX = re.compile(
r"could not connect to server: (?P<reason>.*?)\s+Is the server running on "
r'host "(?P<hostname>.*?)" (\(.*?\) )?and accepting\s+TCP/IP '
r"connections on port (?P<port>.*?)\?"
)
TEST_CONNECTION_UNKNOWN_DATABASE_REGEX = re.compile(
CONNECTION_UNKNOWN_DATABASE_REGEX = re.compile(
'database "(?P<database>.*?)" 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,
),
}

View File

@ -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<username>.*?)"'
)
TEST_CONNECTION_INVALID_HOSTNAME_REGEX = re.compile(
CONNECTION_INVALID_HOSTNAME_REGEX = re.compile(
'could not translate host name "(?P<hostname>.*?)" 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<hostname>.*?)" (\(.*?\) )?and accepting\s+TCP/IP '
r"connections on port (?P<port>.*?)\?"
)
TEST_CONNECTION_HOST_DOWN_REGEX = re.compile(
CONNECTION_HOST_DOWN_REGEX = re.compile(
r"could not connect to server: (?P<reason>.*?)\s+Is the server running on "
r'host "(?P<hostname>.*?)" (\(.*?\) )?and accepting\s+TCP/IP '
r"connections on port (?P<port>.*?)\?"
)
TEST_CONNECTION_UNKNOWN_DATABASE_REGEX = re.compile(
CONNECTION_UNKNOWN_DATABASE_REGEX = re.compile(
'database "(?P<database>.*?)" 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,
),
}

View File

@ -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": _(

View File

@ -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",

View File

@ -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",

View File

@ -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,

View File

@ -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,

View File

@ -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,