diff --git a/pmm_qa/client_container_ms_setup.sh b/pmm_qa/client_container_ms_setup.sh index b11fd42..7d37efb 100644 --- a/pmm_qa/client_container_ms_setup.sh +++ b/pmm_qa/client_container_ms_setup.sh @@ -48,7 +48,7 @@ dbdeployer unpack ${tar_ball_name} --sandbox-binary=~/ms${ms_version} --overwrit export db_version_sandbox=$(ls ~/ms${ms_version}) export SERVICE_RANDOM_NUMBER=$((1 + $RANDOM % 9999)) -if [[ $number_of_nodes == 1 ]];then +if [[ "$number_of_nodes" == 1 ]];then if [[ ! -z $group_replication ]]; then dbdeployer deploy --topology=group replication ${db_version_sandbox} --single-primary --sandbox-binary=~/ms${ms_version} --remote-access=% --bind-address=0.0.0.0 --force export db_sandbox=$(dbdeployer sandboxes | awk -F' ' '{print $1}') diff --git a/pmm_qa/client_container_ps_setup.sh b/pmm_qa/client_container_ps_setup.sh index 2c74470..b43550a 100644 --- a/pmm_qa/client_container_ps_setup.sh +++ b/pmm_qa/client_container_ps_setup.sh @@ -54,7 +54,7 @@ dbdeployer deploy single ${db_version_sandbox} --port=${PS_PORT} --sandbox-binar export db_sandbox=$(dbdeployer sandboxes | awk -F' ' '{print $1}') export SERVICE_RANDOM_NUMBER=$((1 + $RANDOM % 9999)) -if [[ $number_of_nodes == 1 ]];then +if [[ "$number_of_nodes" == 1 ]];then if [[ ! -z $group_replication ]]; then dbdeployer deploy --topology=group replication ${db_version_sandbox} --single-primary --sandbox-binary=~/ps${ps_version} --remote-access=% --bind-address=0.0.0.0 --force export db_sandbox=$(dbdeployer sandboxes | awk -F' ' '{print $1}') @@ -72,6 +72,7 @@ if [[ $number_of_nodes == 1 ]];then mysql -h 127.0.0.1 -u msandbox -pmsandbox --port $node_port -e "SET GLOBAL log_slow_admin_statements=ON;" mysql -h 127.0.0.1 -u msandbox -pmsandbox --port $node_port -e "SET GLOBAL log_slow_slave_statements=ON;" else + mysql -h 127.0.0.1 -u msandbox -pmsandbox --port $node_port -e "SET GLOBAL userstat=1;" mysql -h 127.0.0.1 -u msandbox -pmsandbox --port $node_port -e "SET GLOBAL innodb_monitor_enable=all;" mysql -h 127.0.0.1 -u msandbox -pmsandbox --port $node_port -e "UPDATE performance_schema.setup_consumers SET ENABLED = 'YES' WHERE NAME LIKE '%statements%';" if echo "$ps_version" | grep '5.7'; then @@ -92,8 +93,9 @@ if [[ $number_of_nodes == 1 ]];then mysql -h 127.0.0.1 -u msandbox -pmsandbox --port $node_port -e "SET GLOBAL log_slow_admin_statements=ON;" mysql -h 127.0.0.1 -u msandbox -pmsandbox --port $node_port -e "SET GLOBAL log_slow_slave_statements=ON;" else - mysql -h 127.0.0.1 -u msandbox -pmsandbox --port $node_port -e "SET GLOBAL innodb_monitor_enable=all;" - mysql -h 127.0.0.1 -u msandbox -pmsandbox --port $node_port -e "UPDATE performance_schema.setup_consumers SET ENABLED = 'YES' WHERE NAME LIKE '%statements%';" + mysql -h 127.0.0.1 -u msandbox -pmsandbox --port $node_port -e "SET GLOBAL userstat=1;" + mysql -h 127.0.0.1 -u msandbox -pmsandbox --port $node_port -e "SET GLOBAL innodb_monitor_enable=all;" + mysql -h 127.0.0.1 -u msandbox -pmsandbox --port $node_port -e "UPDATE performance_schema.setup_consumers SET ENABLED = 'YES' WHERE NAME LIKE '%statements%';" if echo "$ps_version" | grep '5.7'; then mysql -h 127.0.0.1 -u msandbox -pmsandbox --port $node_port -e "INSTALL PLUGIN QUERY_RESPONSE_TIME_AUDIT SONAME 'query_response_time.so';" mysql -h 127.0.0.1 -u msandbox -pmsandbox --port $node_port -e "INSTALL PLUGIN QUERY_RESPONSE_TIME SONAME 'query_response_time.so';" @@ -124,8 +126,9 @@ else mysql -h 127.0.0.1 -u msandbox -pmsandbox --port $node_port -e "SET GLOBAL log_slow_admin_statements=ON;" mysql -h 127.0.0.1 -u msandbox -pmsandbox --port $node_port -e "SET GLOBAL log_slow_slave_statements=ON;" else - mysql -h 127.0.0.1 -u msandbox -pmsandbox --port $node_port -e "SET GLOBAL innodb_monitor_enable=all;" - mysql -h 127.0.0.1 -u msandbox -pmsandbox --port $node_port -e "UPDATE performance_schema.setup_consumers SET ENABLED = 'YES' WHERE NAME LIKE '%statements%';" + mysql -h 127.0.0.1 -u msandbox -pmsandbox --port $node_port -e "SET GLOBAL userstat=1;" + mysql -h 127.0.0.1 -u msandbox -pmsandbox --port $node_port -e "SET GLOBAL innodb_monitor_enable=all;" + mysql -h 127.0.0.1 -u msandbox -pmsandbox --port $node_port -e "UPDATE performance_schema.setup_consumers SET ENABLED = 'YES' WHERE NAME LIKE '%statements%';" if echo "$ps_version" | grep '5.7'; then mysql -h 127.0.0.1 -u msandbox -pmsandbox --port $node_port -e "INSTALL PLUGIN QUERY_RESPONSE_TIME_AUDIT SONAME 'query_response_time.so';" mysql -h 127.0.0.1 -u msandbox -pmsandbox --port $node_port -e "INSTALL PLUGIN QUERY_RESPONSE_TIME SONAME 'query_response_time.so';" diff --git a/pmm_qa/ms_pmm_setup.yml b/pmm_qa/ms_pmm_setup.yml index 158a5a8..088e49b 100644 --- a/pmm_qa/ms_pmm_setup.yml +++ b/pmm_qa/ms_pmm_setup.yml @@ -15,7 +15,7 @@ admin_password: "{{ lookup('vars', 'extra_admin_password', default=lookup('env','ADMIN_PASSWORD') | default('admin', true) ) }}" pmm_qa_branch: "{{ lookup('vars', 'extra_pmm_qa_branch', default=lookup('env','PMM_QA_GIT_BRANCH') | default('main', true) ) }}" number_of_nodes: "{{ lookup('vars', 'extra_number_of_nodes', default=lookup('env','MS_NODES') | default('1', true) ) }}" - group_replication: "{{ lookup('vars', 'extra_group_replication', default=lookup('env','GROUP_REPLICATION')) }}" + group_replication: "{{ lookup('vars', 'extra_group_replication', default=lookup('env','GROUP_REPLICATION') | default('', true) ) }}" tasks: - name: cleanup container for client and DB setup diff --git a/pmm_qa/pmm-framework.py b/pmm_qa/pmm-framework.py index c82b166..44ae16d 100755 --- a/pmm_qa/pmm-framework.py +++ b/pmm_qa/pmm-framework.py @@ -53,7 +53,6 @@ } - def run_ansible_playbook(playbook_filename, env_vars, args): # Get Script Dir script_path = os.path.abspath(sys.argv[0]) @@ -130,17 +129,21 @@ def setup_ps(db_type, db_version=None, db_config=None, args=None): exit() # Check Setup Types - setup_type = '' - if get_value('SETUP_TYPE', db_type, args, db_config).lower() == "group_repilication" or "gr": - setup_type = '1' + setup_type = None + no_of_nodes = 1 + setup_type_value = get_value('SETUP_TYPE', db_type, args, db_config).lower() + if setup_type_value in ("group_replication", "gr"): + setup_type = 1 + elif setup_type_value in ("replication", "replica"): + setup_type = None + no_of_nodes = 2 # Gather Version details ps_version = os.getenv('PS_VERSION') or db_version or database_configs[db_type]["versions"][-1] - # Define environment variables for playbook env_vars = { - 'GROUP_REPLICATION': f'{setup_type}', - 'PS_NODES': '1' if isinstance(setup_type, str) and len(setup_type) == 0 else '3', + 'GROUP_REPLICATION': setup_type, + 'PS_NODES': no_of_nodes, 'PS_VERSION': ps_version, 'PMM_SERVER_IP': args.pmm_server_ip or container_name or '127.0.0.1', 'PS_CONTAINER': 'ps_pmm_' + str(ps_version), @@ -169,14 +172,20 @@ def setup_mysql(db_type, db_version=None, db_config=None, args=None): ms_version = os.getenv('MS_VERSION') or db_version or database_configs[db_type]["versions"][-1] # Check Setup Types - setup_type = '' - if get_value('SETUP_TYPE', db_type, args, db_config).lower() == "group_repilication" or "gr": - setup_type = '1' + # Check Setup Types + setup_type = None + no_of_nodes = 1 + setup_type_value = get_value('SETUP_TYPE', db_type, args, db_config).lower() + if setup_type_value in ("group_replication", "gr"): + setup_type = 1 + elif setup_type_value in ("replication", "replica"): + setup_type = None + no_of_nodes = 2 # Define environment variables for playbook env_vars = { - 'GROUP_REPLICATION': f'{setup_type}', - 'MS_NODES': '1' if isinstance(setup_type, str) and len(setup_type) == 0 else '3', + 'GROUP_REPLICATION': setup_type, + 'MS_NODES': no_of_nodes, 'MS_VERSION': ms_version, 'PMM_SERVER_IP': args.pmm_server_ip or container_name or '127.0.0.1', 'MS_CONTAINER': 'mysql_pmm_' + str(ms_version), @@ -283,7 +292,8 @@ def setup_external(db_type, db_version=None, db_config=None, args=None): # Gather Version details redis_version = os.getenv('REDIS_VERSION') or db_version or database_configs["EXTERNAL"]["REDIS"]["versions"][-1] - nodeprocess_version = os.getenv('NODE_PROCESS_VERSION') or db_version or database_configs["EXTERNAL"]["NODEPROCESS"]["versions"][-1] + nodeprocess_version = os.getenv('NODE_PROCESS_VERSION') or db_version or \ + database_configs["EXTERNAL"]["NODEPROCESS"]["versions"][-1] # Define environment variables for playbook env_vars = { diff --git a/pmm_qa/ps_pmm_setup.yml b/pmm_qa/ps_pmm_setup.yml index 01d322e..97e6311 100644 --- a/pmm_qa/ps_pmm_setup.yml +++ b/pmm_qa/ps_pmm_setup.yml @@ -15,7 +15,7 @@ admin_password: "{{ lookup('vars', 'extra_admin_password', default=lookup('env','ADMIN_PASSWORD') | default('admin', true) ) }}" pmm_qa_branch: "{{ lookup('vars', 'extra_pmm_qa_branch', default=lookup('env','PMM_QA_GIT_BRANCH') | default('main', true) ) }}" number_of_nodes: "{{ lookup('vars', 'extra_number_of_nodes', default=lookup('env','PS_NODES') | default('3', true) ) }}" - group_replication: "{{ lookup('vars', 'extra_group_replication', default=lookup('env','GROUP_REPLICATION')) }}" + group_replication: "{{ lookup('vars', 'extra_group_replication', default=lookup('env','GROUP_REPLICATION') | default('', true) ) }}" tasks: - name: cleanup container for client and DB setup