Skip to content

Commit 0bbba5f

Browse files
committed
Adds MySQL 8.4 3rd Party Integration test
1 parent a0a01df commit 0bbba5f

File tree

11 files changed

+674
-37
lines changed

11 files changed

+674
-37
lines changed

integration_test/third_party_apps_test/applications/mysql/exercise

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ sudo mysql --defaults-extra-file=config-user -S /var/run/mysqld/mysql2.sock -Bse
3030
sudo mysqldump --defaults-extra-file=config-user -S /var/run/mysqld/mysql2.sock --all-databases --source-data > /tmp/dbdump.sql
3131

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

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

49-
sudo mysql --defaults-extra-file=config-user -Bse "select table_catalog, table_schema, table_name from information_schema.tables"
49+
sudo mysql --defaults-extra-file=config-user -Bse "select table_catalog, table_schema, table_name from information_schema.tables"

integration_test/third_party_apps_test/applications/mysql/metadata.yaml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,22 @@ minimum_supported_agent_version:
3232
logging: 2.5.0
3333
supported_operating_systems: linux
3434
platforms_to_skip:
35-
# MySQL is not currently supported on various distros.
35+
# MySQL is not currently supported on various distros. - ml-images:common-gpu-debian-11-py310
36+
- debian-cloud:debian-11
3637
- debian-cloud:debian-12
3738
- debian-cloud:debian-12-arm64
39+
- rocky-linux-cloud:rocky-linux-8
40+
- rocky-linux-cloud:rocky-linux-9
41+
- rocky-linux-cloud:rocky-linux-9-arm64
42+
- ubuntu-os-cloud:ubuntu-2004-lts
43+
- ubuntu-os-cloud:ubuntu-2004-lts-arm64
44+
- ubuntu-os-cloud:ubuntu-2204-lts
45+
- ubuntu-os-cloud:ubuntu-2204-lts-arm64
46+
- ubuntu-os-cloud:ubuntu-2404-lts-amd64
47+
- ubuntu-os-cloud:ubuntu-2404-lts-arm64
48+
- suse-cloud:sles-12
3849
- suse-cloud:sles-15-arm64
39-
supported_app_version: ["5.7", "8.0"]
50+
supported_app_version: ["5.7", "8.0", "8.4"]
4051
expected_metrics:
4152
- type: workload.googleapis.com/mysql.buffer_pool_data_pages
4253
value_type: INT64

integration_test/third_party_apps_test/applications/mysql/sles/install

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,40 @@ set -e
33
source /etc/os-release
44
SUSE_VERSION="${VERSION_ID%%.*}"
55

6-
if [[ "${ID}" == opensuse-leap && "${VERSION_ID}" == 15.[01] ]]; then
7-
if [[ "${VERSION_ID}" == 15.0 ]]; then
8-
sudo zypper modifyrepo --disable openSUSE-Leap-Cloud-Tools
9-
elif [[ "${VERSION_ID}" == 15.1 ]]; then
10-
sudo zypper modifyrepo --disable openSUSE-Leap-devel-languages-python-aws
11-
fi
12-
sudo zypper -n refresh
13-
14-
sudo zypper -n install mariadb
15-
else
16-
mysql_repo_pkg_name=''
17-
if [[ "${SUSE_VERSION}" == 12 ]]; then
18-
mysql_repo_pkg_name=mysql80-community-release-sles12.rpm
19-
elif [[ "${SUSE_VERSION}" == 15 ]]; then
20-
mysql_repo_pkg_name=mysql80-community-release-sl15.rpm
21-
fi
22-
6+
if [[ "${ID}" == sles ]]; then
237
# Installation followed in: https://dev.mysql.com/doc/mysql-sles-repo-quick-guide/en/
248
sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2023
259
sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
26-
sudo zypper -n install https://dev.mysql.com/get/${mysql_repo_pkg_name}
10+
sudo zypper -n install https://dev.mysql.com/get/mysql84-community-release-sl15.rpm
2711
sudo zypper -n install mysql-community-server
2812
fi
2913

30-
if [[ "${SUSE_VERSION}" == 12 ]]; then
31-
sudo zypper -n install libmysqlclient18
32-
elif [[ "${SUSE_VERSION}" == 15 ]]; then
14+
if [[ "${SUSE_VERSION}" == 15 ]]; then
3315
sudo zypper -n install libmariadb3
3416
fi
3517

18+
## Default configuration
19+
cat <<EOF | sudo tee /etc/my.cnf > /dev/null
20+
[mysqld]
21+
mysql_native_password=ON
22+
datadir=/var/lib/mysql
23+
socket=/var/lib/mysql/mysql.sock
24+
25+
log-error=/var/log/mysql/mysqld.log
26+
pid-file=/var/run/mysql/mysqld.pid
27+
EOF
28+
3629
sudo service mysql start
3730

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

44-
cat <<EOF >config-user
45-
[client]
46-
user=root
47-
password='$password'
33+
cat <<EOF >config-user
34+
[client]
35+
user=root
36+
password='$password'
4837
EOF
4938

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

5341
# default socket path is different from originally set default (from debian/ubuntu), so we need to create a symlink
5442
sudo mkdir /var/run/mysqld/

integration_test/third_party_apps_test/applications/mysql5.7/metadata.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ platforms_to_skip:
5656
- ubuntu-os-cloud:ubuntu-2204-lts-arm64
5757
- ubuntu-os-cloud:ubuntu-2404-lts-amd64
5858
- ubuntu-os-cloud:ubuntu-2404-lts-arm64
59-
supported_app_version: ["5.7", "8.0"]
59+
supported_app_version: ["5.7", "8.0", "8.4"]
6060
expected_metrics:
6161
- type: workload.googleapis.com/mysql.buffer_pool_data_pages
6262
value_type: INT64
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Configures Ops Agent to collect telemetry from the app and restart Ops Agent.
2+
3+
set -e
4+
5+
# Create a back up of the existing file so existing configurations are not lost.
6+
sudo cp /etc/google-cloud-ops-agent/config.yaml /etc/google-cloud-ops-agent/config.yaml.bak
7+
8+
# Configure the Ops Agent.
9+
sudo tee /etc/google-cloud-ops-agent/config.yaml > /dev/null << EOF
10+
metrics:
11+
receivers:
12+
mysql:
13+
type: mysql
14+
username: root
15+
password: Ss123%321
16+
service:
17+
pipelines:
18+
mysql:
19+
receivers:
20+
- mysql
21+
logging:
22+
receivers:
23+
mysql_error:
24+
type: mysql_error
25+
mysql_general:
26+
type: mysql_general
27+
mysql_slow:
28+
type: mysql_slow
29+
service:
30+
pipelines:
31+
mysql:
32+
receivers:
33+
- mysql_error
34+
- mysql_general
35+
- mysql_slow
36+
EOF
37+
38+
sudo service google-cloud-ops-agent restart
39+
sleep 60
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
set -e
2+
3+
cat <<EOF > config-user
4+
[client]
5+
user=root
6+
password='Ss123%321'
7+
EOF
8+
9+
# initialize and start replation source
10+
sudo mysqld --defaults-group-suffix=2 --initialize
11+
nohup sudo mysqld --defaults-group-suffix=2 2>/dev/null >/dev/null </dev/null &
12+
# give it time to start, since we put it in the background
13+
sleep 10
14+
15+
# grab root password for replication source
16+
password=$(sudo grep -oP '(?<=temporary password is generated for root@localhost: ).*$' /var/log/mysql/error2.log)
17+
cat <<EOF > config-user-2
18+
[client]
19+
user=root
20+
password='$password'
21+
EOF
22+
23+
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
24+
25+
# Create replication user
26+
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';"
27+
sudo mysql --defaults-extra-file=config-user -S /var/run/mysqld/mysql2.sock -Bse "GRANT REPLICATION SLAVE ON *.* TO 'repl'@'localhost';"
28+
29+
# Dump data from replica source
30+
sudo mysqldump --defaults-extra-file=config-user -S /var/run/mysqld/mysql2.sock --all-databases --source-data > /tmp/dbdump.sql
31+
32+
# Capture status to seed replica
33+
raw_status=$(sudo mysql --defaults-extra-file=config-user -S /var/run/mysqld/mysql2.sock -Bse "SHOW MASTER STATUS;")
34+
read -r logfile logpos <<< $raw_status
35+
36+
# Dump data from source into replica
37+
sudo mysql --defaults-extra-file=config-user < /tmp/dbdump.sql
38+
39+
# Configure replication
40+
sudo mysql --defaults-extra-file=config-user -Bse "STOP REPLICA;"
41+
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;"
42+
sudo mysql --defaults-extra-file=config-user -Bse "START REPLICA;"
43+
44+
sudo mysql --defaults-extra-file=config-user -Bse "SET GLOBAL log_slow_extra = 'ON'"
45+
sudo mysql --defaults-extra-file=config-user -Bse "SET GLOBAL long_query_time = 0"
46+
sudo mysql --defaults-extra-file=config-user -Bse "SET GLOBAL slow_query_log = 1"
47+
sudo mysql --defaults-extra-file=config-user -Bse "SET GLOBAL general_log = 'ON'"
48+
49+
sudo mysql --defaults-extra-file=config-user -Bse "select table_catalog, table_schema, table_name from information_schema.tables"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
features:
2+
- feature: receivers:mysql
3+
module: metrics
4+
key: "[0].enabled"
5+
value: true
6+
- feature: receivers:mysql_error
7+
module: logging
8+
key: "[0].enabled"
9+
value: true
10+
- feature: receivers:mysql_general
11+
module: logging
12+
key: "[1].enabled"
13+
value: true
14+
- feature: receivers:mysql_slow
15+
module: logging
16+
key: "[2].enabled"
17+
value: true

0 commit comments

Comments
 (0)