Add PGAPPNAME env. variable to arbitrary configs

pull/5657/head
Onder Kalaci 2022-01-27 10:39:56 +01:00
parent b26eeaecd3
commit 303540e494
3 changed files with 15 additions and 3 deletions

View File

@ -66,7 +66,7 @@ def coordinator_should_haveshards(pg_path, port):
utils.psql(pg_path, port, command)
def start_databases(pg_path, rel_data_path, node_name_to_ports, logfile_prefix):
def start_databases(pg_path, rel_data_path, node_name_to_ports, logfile_prefix, env_variables):
for node_name in node_name_to_ports.keys():
abs_data_path = os.path.abspath(os.path.join(rel_data_path, node_name))
node_port = node_name_to_ports[node_name]
@ -82,7 +82,13 @@ def start_databases(pg_path, rel_data_path, node_name_to_ports, logfile_prefix):
"--log",
os.path.join(abs_data_path, logfile_name(logfile_prefix, node_name)),
]
# set the application name if requires
if env_variables != {}:
os.environ.update(env_variables)
subprocess.run(command, check=True)
atexit.register(
stop_databases,
pg_path,
@ -127,6 +133,7 @@ def run_pg_regress_without_exit(
extra_tests,
)
copy_binary_path = os.path.join(input_dir, "copy_modified_wrapper")
exit_code |= subprocess.call(copy_binary_path)
return exit_code
@ -241,7 +248,7 @@ def initialize_citus_cluster(bindir, datadir, settings, config):
initialize_db_for_cluster(
bindir, datadir, settings, config.node_name_to_ports.keys()
)
start_databases(bindir, datadir, config.node_name_to_ports, config.name)
start_databases(bindir, datadir, config.node_name_to_ports, config.name, config.env_variables)
create_citus_extension(bindir, config.node_name_to_ports.values())
add_workers(bindir, config.worker_ports, config.coordinator_port())
if config.is_mx:

View File

@ -110,6 +110,7 @@ class CitusBaseClusterConfig(object, metaclass=NewInitCaller):
}
self.new_settings = {}
self.add_coordinator_to_metadata = False
self.env_variables = {}
def post_init(self):
self._init_node_name_ports()
@ -271,6 +272,10 @@ class CitusUnusualExecutorConfig(CitusMXBaseClusterConfig):
"citus.local_table_join_policy": "prefer-distributed",
}
# this setting does not necessarily need to be here
# could go any other test
self.env_variables = {'PGAPPNAME' : 'test_app'}
class CitusSmallCopyBuffersConfig(CitusMXBaseClusterConfig):
def __init__(self, arguments):

View File

@ -112,7 +112,7 @@ def main(config):
config.node_name_to_ports.keys(),
)
common.start_databases(
config.new_bindir, config.new_datadir, config.node_name_to_ports, config.name
config.new_bindir, config.new_datadir, config.node_name_to_ports, config.name, {}
)
citus_finish_pg_upgrade(config.new_bindir, config.node_name_to_ports.values())