mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-30 11:30:37 +00:00
test_runner: pass password to pgbench via PGPASSWORD (#2468)
This commit is contained in:
committed by
GitHub
parent
bc3ba23e0a
commit
ebab89ebd2
@@ -1,6 +1,5 @@
|
||||
import logging
|
||||
import logging.config
|
||||
import re
|
||||
|
||||
"""
|
||||
This file configures logging to use in python tests.
|
||||
@@ -30,17 +29,6 @@ LOGGING = {
|
||||
}
|
||||
|
||||
|
||||
class PasswordFilter(logging.Filter):
|
||||
"""Filter out password from logs."""
|
||||
|
||||
# Good enough to filter our passwords produced by PgProtocol.connstr
|
||||
FILTER = re.compile(r"(\s*)password=[^\s]+(\s*)")
|
||||
|
||||
def filter(self, record: logging.LogRecord) -> bool:
|
||||
record.msg = self.FILTER.sub(r"\1password=<hidden>\2", str(record.msg))
|
||||
return True
|
||||
|
||||
|
||||
def getLogger(name="root") -> logging.Logger:
|
||||
"""Method to get logger for tests.
|
||||
|
||||
@@ -50,6 +38,5 @@ def getLogger(name="root") -> logging.Logger:
|
||||
|
||||
# default logger for tests
|
||||
log = getLogger()
|
||||
log.addFilter(PasswordFilter())
|
||||
|
||||
logging.config.dictConfig(LOGGING)
|
||||
|
||||
@@ -283,10 +283,15 @@ class PgProtocol:
|
||||
return str(make_dsn(**self.conn_options(**kwargs)))
|
||||
|
||||
def conn_options(self, **kwargs):
|
||||
"""
|
||||
Construct a dictionary of connection options from default values and extra parameters.
|
||||
An option can be dropped from the returning dictionary by None-valued extra parameter.
|
||||
"""
|
||||
result = self.default_options.copy()
|
||||
if "dsn" in kwargs:
|
||||
result.update(parse_dsn(kwargs["dsn"]))
|
||||
result.update(kwargs)
|
||||
result = {k: v for k, v in result.items() if v is not None}
|
||||
|
||||
# Individual statement timeout in seconds. 2 minutes should be
|
||||
# enough for our tests, but if you need a longer, you can
|
||||
|
||||
Reference in New Issue
Block a user