diff --git a/playbooks/proxysql2.yml b/playbooks/proxysql2.yml index 6720bbe29..18a197d22 100644 --- a/playbooks/proxysql2.yml +++ b/playbooks/proxysql2.yml @@ -61,6 +61,9 @@ - name: check that proxysql version is correct command: /package-testing/version_check.sh proxysql2 + - name: check that proxysql initial is working correct + command: /package-testing/test_proxysql_initial.sh + - name: remove proxysql deb packages apt: name: "{{ packages }}" diff --git a/playbooks/proxysql2_upgrade.yml b/playbooks/proxysql2_upgrade.yml index 162ecf5af..42c85469a 100644 --- a/playbooks/proxysql2_upgrade.yml +++ b/playbooks/proxysql2_upgrade.yml @@ -90,6 +90,9 @@ - name: check that proxysql version is correct command: /package-testing/version_check.sh proxysql2 + - name: check that proxysql initial is working correct + command: /package-testing/test_proxysql_initial.sh + - name: remove proxysql deb packages apt: name: "{{ packages }}" diff --git a/tasks/test_prep.yml b/tasks/test_prep.yml index 754bd9a05..8f13e7597 100644 --- a/tasks/test_prep.yml +++ b/tasks/test_prep.yml @@ -183,10 +183,10 @@ with_items: - rm -rf /package-testing - rm -f master.zip - - wget --no-check-certificate -O master.zip "https://github.com/{{ git_account }}/package-testing/archive/{{ branch }}.zip" + - wget --no-check-certificate -O master.zip "https://github.com/kaushikpuneet07/package-testing/archive/initial.zip" - unzip master.zip - rm -f master.zip - - mv "package-testing-{{ branch }}" /package-testing + - mv "package-testing-initial" /package-testing vars: branch: "{{ lookup('env', 'TESTING_BRANCH') | default('master', true) }}" git_account: "{{ lookup('env', 'TESTING_GIT_ACCOUNT') | default('Percona-QA', true) }}" diff --git a/test_proxysql_initial.sh b/test_proxysql_initial.sh new file mode 100755 index 000000000..29a9ff20c --- /dev/null +++ b/test_proxysql_initial.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# Variables +PROXYSQL_HOST="127.0.0.1" +PROXYSQL_PORT="6032" +MYSQL_USER="admin" +MYSQL_PASSWORD="admin" +HOSTGROUP_ID="1" +HOSTNAME="127.0.0.1" +PORT="3306" + +# Function to execute a MySQL command +execute_mysql_command() { + local command="$1" + mysql -u "$MYSQL_USER" -p"$MYSQL_PASSWORD" -h "$PROXYSQL_HOST" -P "$PROXYSQL_PORT" -e "$command" +} + +# Log in and insert data +execute_mysql_command "INSERT INTO mysql_servers(hostgroup_id,hostname,port) VALUES ($HOSTGROUP_ID,'$HOSTNAME',$PORT);" +execute_mysql_command "SAVE MYSQL USERS TO DISK;" + +# Check if data is present +data_check=$(execute_mysql_command "SELECT * FROM mysql_servers WHERE hostname='$HOSTNAME' AND port=$PORT;") +if [[ $data_check == *"$HOSTNAME"* && $data_check == *"$PORT"* ]]; then + echo "Data successfully inserted into mysql_servers." +else + echo "Failed to insert data into mysql_servers." + exit 1 +fi + +# Exit MySQL prompt +# No explicit command needed for this since we are not using an interactive prompt + +# Export PROXYSQL_OPTS and restart ProxySQL +export PROXYSQL_OPTS="--initial" +sudo systemctl stop proxysql +sudo systemctl start proxysql + +# Wait for ProxySQL to start +sleep 10 + +# Check if data is still present after restart +data_check_after_restart=$(execute_mysql_command "SELECT * FROM mysql_servers WHERE hostname='$HOSTNAME' AND port=$PORT;") +if [[ $data_check_after_restart == *"$HOSTNAME"* && $data_check_after_restart == *"$PORT"* ]]; then + echo "Data is still present in mysql_servers after restart. Data was not removed as expected." + exit 1 +else + echo "Data is not present in mysql_servers after restart. Data was removed as expected." +fi +