Skip to content

Commit

Permalink
Updates fixe for PS, MS for Replication and GR (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
saikumar-vs authored Apr 19, 2024
1 parent 2a1e7ac commit 5b96368
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 21 deletions.
2 changes: 1 addition & 1 deletion pmm_qa/client_container_ms_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}')
Expand Down
13 changes: 8 additions & 5 deletions pmm_qa/client_container_ps_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}')
Expand All @@ -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
Expand All @@ -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';"
Expand Down Expand Up @@ -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';"
Expand Down
2 changes: 1 addition & 1 deletion pmm_qa/ms_pmm_setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
36 changes: 23 additions & 13 deletions pmm_qa/pmm-framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
}



def run_ansible_playbook(playbook_filename, env_vars, args):
# Get Script Dir
script_path = os.path.abspath(sys.argv[0])
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion pmm_qa/ps_pmm_setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5b96368

Please sign in to comment.