Skip to content

Commit

Permalink
Adds MySQL 8.4 3rd Party Integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanKurek committed Nov 7, 2024
1 parent a0a01df commit 0bbba5f
Show file tree
Hide file tree
Showing 11 changed files with 674 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ sudo mysql --defaults-extra-file=config-user -S /var/run/mysqld/mysql2.sock -Bse
sudo mysqldump --defaults-extra-file=config-user -S /var/run/mysqld/mysql2.sock --all-databases --source-data > /tmp/dbdump.sql

# Capture status to seed replica
raw_status=$(sudo mysql --defaults-extra-file=config-user -S /var/run/mysqld/mysql2.sock -Bse "SHOW MASTER STATUS;")
raw_status=$(sudo mysql --defaults-extra-file=config-user -S /var/run/mysqld/mysql2.sock -Bse "SHOW BINARY LOG STATUS;")
read -r logfile logpos <<< $raw_status

# Dump data from source into replica
Expand All @@ -46,4 +46,4 @@ sudo mysql --defaults-extra-file=config-user -Bse "SET GLOBAL long_query_time =
sudo mysql --defaults-extra-file=config-user -Bse "SET GLOBAL slow_query_log = 1"
sudo mysql --defaults-extra-file=config-user -Bse "SET GLOBAL general_log = 'ON'"

sudo mysql --defaults-extra-file=config-user -Bse "select table_catalog, table_schema, table_name from information_schema.tables"
sudo mysql --defaults-extra-file=config-user -Bse "select table_catalog, table_schema, table_name from information_schema.tables"
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,22 @@ minimum_supported_agent_version:
logging: 2.5.0
supported_operating_systems: linux
platforms_to_skip:
# MySQL is not currently supported on various distros.
# MySQL is not currently supported on various distros. - ml-images:common-gpu-debian-11-py310
- debian-cloud:debian-11
- debian-cloud:debian-12
- debian-cloud:debian-12-arm64
- rocky-linux-cloud:rocky-linux-8
- rocky-linux-cloud:rocky-linux-9
- rocky-linux-cloud:rocky-linux-9-arm64
- ubuntu-os-cloud:ubuntu-2004-lts
- ubuntu-os-cloud:ubuntu-2004-lts-arm64
- ubuntu-os-cloud:ubuntu-2204-lts
- ubuntu-os-cloud:ubuntu-2204-lts-arm64
- ubuntu-os-cloud:ubuntu-2404-lts-amd64
- ubuntu-os-cloud:ubuntu-2404-lts-arm64
- suse-cloud:sles-12
- suse-cloud:sles-15-arm64
supported_app_version: ["5.7", "8.0"]
supported_app_version: ["5.7", "8.0", "8.4"]
expected_metrics:
- type: workload.googleapis.com/mysql.buffer_pool_data_pages
value_type: INT64
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,40 @@ set -e
source /etc/os-release
SUSE_VERSION="${VERSION_ID%%.*}"

if [[ "${ID}" == opensuse-leap && "${VERSION_ID}" == 15.[01] ]]; then
if [[ "${VERSION_ID}" == 15.0 ]]; then
sudo zypper modifyrepo --disable openSUSE-Leap-Cloud-Tools
elif [[ "${VERSION_ID}" == 15.1 ]]; then
sudo zypper modifyrepo --disable openSUSE-Leap-devel-languages-python-aws
fi
sudo zypper -n refresh

sudo zypper -n install mariadb
else
mysql_repo_pkg_name=''
if [[ "${SUSE_VERSION}" == 12 ]]; then
mysql_repo_pkg_name=mysql80-community-release-sles12.rpm
elif [[ "${SUSE_VERSION}" == 15 ]]; then
mysql_repo_pkg_name=mysql80-community-release-sl15.rpm
fi

if [[ "${ID}" == sles ]]; then
# Installation followed in: https://dev.mysql.com/doc/mysql-sles-repo-quick-guide/en/
sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2023
sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
sudo zypper -n install https://dev.mysql.com/get/${mysql_repo_pkg_name}
sudo zypper -n install https://dev.mysql.com/get/mysql84-community-release-sl15.rpm
sudo zypper -n install mysql-community-server
fi

if [[ "${SUSE_VERSION}" == 12 ]]; then
sudo zypper -n install libmysqlclient18
elif [[ "${SUSE_VERSION}" == 15 ]]; then
if [[ "${SUSE_VERSION}" == 15 ]]; then
sudo zypper -n install libmariadb3
fi

## Default configuration
cat <<EOF | sudo tee /etc/my.cnf > /dev/null
[mysqld]
mysql_native_password=ON
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

log-error=/var/log/mysql/mysqld.log
pid-file=/var/run/mysql/mysqld.pid
EOF

sudo service mysql start

if [[ "${ID}" == opensuse-leap && "${VERSION_ID}" == 15.[01] ]]; then
# mariadb default root password is empty.
mysql -u root --skip-password -Bse "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Ss123%321'; FLUSH PRIVILEGES;"
else
password="$(sudo grep -oP '(?<=temporary password is generated for root@localhost: ).*$' /var/log/mysql/mysqld.log)"
password="$(sudo grep -oP '(?<=temporary password is generated for root@localhost: ).*$' /var/log/mysql/mysqld.log)"

cat <<EOF >config-user
[client]
user=root
password='$password'
cat <<EOF >config-user
[client]
user=root
password='$password'
EOF

mysql --defaults-extra-file=config-user -Bse "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Ss123%321'; FLUSH PRIVILEGES;" --connect-expired-password
fi
mysql --defaults-extra-file=config-user -Bse "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Ss123%321'; FLUSH PRIVILEGES;" --connect-expired-password

# default socket path is different from originally set default (from debian/ubuntu), so we need to create a symlink
sudo mkdir /var/run/mysqld/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ platforms_to_skip:
- ubuntu-os-cloud:ubuntu-2204-lts-arm64
- ubuntu-os-cloud:ubuntu-2404-lts-amd64
- ubuntu-os-cloud:ubuntu-2404-lts-arm64
supported_app_version: ["5.7", "8.0"]
supported_app_version: ["5.7", "8.0", "8.4"]
expected_metrics:
- type: workload.googleapis.com/mysql.buffer_pool_data_pages
value_type: INT64
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Configures Ops Agent to collect telemetry from the app and restart Ops Agent.

set -e

# Create a back up of the existing file so existing configurations are not lost.
sudo cp /etc/google-cloud-ops-agent/config.yaml /etc/google-cloud-ops-agent/config.yaml.bak

# Configure the Ops Agent.
sudo tee /etc/google-cloud-ops-agent/config.yaml > /dev/null << EOF
metrics:
receivers:
mysql:
type: mysql
username: root
password: Ss123%321
service:
pipelines:
mysql:
receivers:
- mysql
logging:
receivers:
mysql_error:
type: mysql_error
mysql_general:
type: mysql_general
mysql_slow:
type: mysql_slow
service:
pipelines:
mysql:
receivers:
- mysql_error
- mysql_general
- mysql_slow
EOF

sudo service google-cloud-ops-agent restart
sleep 60
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
set -e

cat <<EOF > config-user
[client]
user=root
password='Ss123%321'
EOF

# initialize and start replation source
sudo mysqld --defaults-group-suffix=2 --initialize
nohup sudo mysqld --defaults-group-suffix=2 2>/dev/null >/dev/null </dev/null &
# give it time to start, since we put it in the background
sleep 10

# grab root password for replication source
password=$(sudo grep -oP '(?<=temporary password is generated for root@localhost: ).*$' /var/log/mysql/error2.log)
cat <<EOF > config-user-2
[client]
user=root
password='$password'
EOF

sudo mysql --defaults-extra-file=config-user-2 -S /var/run/mysqld/mysql2.sock -Bse "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Ss123%321'; FLUSH PRIVILEGES;" --connect-expired-password

# Create replication user
sudo mysql --defaults-extra-file=config-user -S /var/run/mysqld/mysql2.sock -Bse "CREATE USER 'repl'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';"
sudo mysql --defaults-extra-file=config-user -S /var/run/mysqld/mysql2.sock -Bse "GRANT REPLICATION SLAVE ON *.* TO 'repl'@'localhost';"

# Dump data from replica source
sudo mysqldump --defaults-extra-file=config-user -S /var/run/mysqld/mysql2.sock --all-databases --source-data > /tmp/dbdump.sql

# Capture status to seed replica
raw_status=$(sudo mysql --defaults-extra-file=config-user -S /var/run/mysqld/mysql2.sock -Bse "SHOW MASTER STATUS;")
read -r logfile logpos <<< $raw_status

# Dump data from source into replica
sudo mysql --defaults-extra-file=config-user < /tmp/dbdump.sql

# Configure replication
sudo mysql --defaults-extra-file=config-user -Bse "STOP REPLICA;"
sudo mysql --defaults-extra-file=config-user -Bse "CHANGE REPLICATION SOURCE TO SOURCE_HOST='localhost', SOURCE_USER='repl', SOURCE_PORT=3307, SOURCE_PASSWORD='password', SOURCE_LOG_FILE='$logfile', SOURCE_LOG_POS=$logpos;"
sudo mysql --defaults-extra-file=config-user -Bse "START REPLICA;"

sudo mysql --defaults-extra-file=config-user -Bse "SET GLOBAL log_slow_extra = 'ON'"
sudo mysql --defaults-extra-file=config-user -Bse "SET GLOBAL long_query_time = 0"
sudo mysql --defaults-extra-file=config-user -Bse "SET GLOBAL slow_query_log = 1"
sudo mysql --defaults-extra-file=config-user -Bse "SET GLOBAL general_log = 'ON'"

sudo mysql --defaults-extra-file=config-user -Bse "select table_catalog, table_schema, table_name from information_schema.tables"
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
features:
- feature: receivers:mysql
module: metrics
key: "[0].enabled"
value: true
- feature: receivers:mysql_error
module: logging
key: "[0].enabled"
value: true
- feature: receivers:mysql_general
module: logging
key: "[1].enabled"
value: true
- feature: receivers:mysql_slow
module: logging
key: "[2].enabled"
value: true
Loading

0 comments on commit 0bbba5f

Please sign in to comment.