From 9ce916fc2bd7f99a4838c0fc468c884992a077b2 Mon Sep 17 00:00:00 2001 From: James Sumners Date: Mon, 17 Jun 2024 09:24:49 -0400 Subject: [PATCH] chore: Updated mysql tests to use MySQL 8.3 --- docker-compose.yml | 13 +++++++++---- docker/Readme.md | 21 +++++++++++++++++++++ docker/mysql/my.cnf | 7 +++++++ test/versioned/mysql/helpers.js | 5 ++++- 4 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 docker/Readme.md create mode 100644 docker/mysql/my.cnf diff --git a/docker-compose.yml b/docker-compose.yml index 99e5b8e27b..18036638ea 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -85,10 +85,15 @@ services: mysql: container_name: nr_node_mysql - # The `mysql:5` image does not have a `linux/arm64` build. - # We cannot use the latest mysql image because our tests fail. - platform: linux/amd64 - image: mysql:5 + platform: ${DOCKER_PLATFORM:-linux/amd64} + # We cannot use an image later than 8.3 because they have fully removed + # the configuration option we need in order to switch back to the native + # authentication method. We must use the native authentication method + # because the `mysql` package does not support the `caching_sha2_password` + # authentication method. + image: mysql:8.3 + volumes: + - "./docker/mysql:/etc/mysql/conf.d" ports: - "3306:3306" environment: diff --git a/docker/Readme.md b/docker/Readme.md new file mode 100644 index 0000000000..72b45b2e5d --- /dev/null +++ b/docker/Readme.md @@ -0,0 +1,21 @@ +This directory contains resources for Docker containers that are used in +our versioned tests. A typical case would be to mount a directory as a volume. +For example: + +```yaml + mysql: + container_name: nr_node_mysql + platform: ${DOCKER_PLATFORM:-linux/amd64} + image: mysql:8.3 + volumes: + - "./docker/mysql:/etc/mysql/conf.d" + ports: + - "3306:3306" + environment: + MYSQL_ALLOW_EMPTY_PASSWORD: 1 + healthcheck: + test: ["CMD", "mysql" ,"-h", "mysql", "-P", "3306", "-u", "root", "-e", "SELECT 1"] + interval: 1s + timeout: 10s + retries: 30 +``` diff --git a/docker/mysql/my.cnf b/docker/mysql/my.cnf new file mode 100644 index 0000000000..699f3d3908 --- /dev/null +++ b/docker/mysql/my.cnf @@ -0,0 +1,7 @@ +[mysqld] +# Without changing the verbosity to 1, we will get a warning about the +# authentication method deprecation _every second_. +log_error_verbosity=1 + +# Switch us back to the pre-8.0 authentication method. +default-authentication-plugin=mysql_native_password diff --git a/test/versioned/mysql/helpers.js b/test/versioned/mysql/helpers.js index 7e7ffd8430..cf51c9899f 100644 --- a/test/versioned/mysql/helpers.js +++ b/test/versioned/mysql/helpers.js @@ -38,6 +38,8 @@ async function createDb(mysql, user, db) { await runCommand(client, `CREATE USER ${user}`) await runCommand(client, `GRANT ALL ON *.* TO ${user}`) await runCommand(client, `CREATE DATABASE IF NOT EXISTS ${db}`) + await runCommand(client, `FLUSH PRIVILEGES`) + await runCommand(client, `FLUSH TABLES`) client.end() } @@ -52,7 +54,8 @@ async function createTable(mysql, user, db, table) { await runCommand( client, [ - `CREATE TABLE IF NOT EXISTS ${table} (`, + `CREATE TABLE IF NOT EXISTS ${table} + (`, ' `id` INTEGER(10) PRIMARY KEY AUTO_INCREMENT,', ' `test_value` VARCHAR(255)', ')'