Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial test in proxysql package testing job #743

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions playbooks/proxysql2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand Down
3 changes: 3 additions & 0 deletions playbooks/proxysql2_upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand Down
4 changes: 2 additions & 2 deletions tasks/test_prep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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) }}"
Expand Down
50 changes: 50 additions & 0 deletions test_proxysql_initial.sh
Original file line number Diff line number Diff line change
@@ -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
Comment on lines +35 to +37
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to this, could we also test the actual proxysql-initial.service ? by executing something like sudo systemctl start proxysql-initial?


# 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