Skip to content

Commit 5713757

Browse files
authored
ci: add previous MySQL versions to integration tests matrix
1 parent 0a195eb commit 5713757

File tree

4 files changed

+40
-11
lines changed

4 files changed

+40
-11
lines changed

.github/workflows/integration-tests.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ jobs:
1616
strategy:
1717
matrix:
1818
node: [18, 20, 22]
19-
name: Node ${{ matrix.node }} Integration Tests
19+
mysql: ["5", "lts"]
20+
name: Node ${{ matrix.node }} with MySQL ${{ matrix.mysql }} Integration Tests
2021
timeout-minutes: 5
2122

2223
services:
2324
mysql:
24-
image: mysql:8.0.33
25+
image: mysql:${{ matrix.mysql }}
2526
env:
2627
MYSQL_ROOT_PASSWORD: password
2728
MYSQL_DATABASE: serverless_mysql_test
@@ -61,7 +62,7 @@ jobs:
6162
MYSQL_PASSWORD: password
6263

6364
- name: Run all tests with coverage
64-
if: matrix.node == 22
65+
if: matrix.node == 22 && matrix.mysql == 'lts'
6566
run: npm run test-cov
6667
env:
6768
MYSQL_HOST: 127.0.0.1

CONTRIBUTING.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,20 +123,35 @@ This will generate an HTML coverage report in the `coverage` directory.
123123

124124
## Integration Test Environment
125125

126-
The integration tests use a MySQL 8.0 container with the following configuration:
126+
The integration tests support multiple MySQL versions in the CI environment to ensure compatibility across different database environments. The GitHub Actions workflow is configured to test against:
127+
128+
- MySQL 5 (latest in the 5.x series)
129+
- MySQL LTS (Long Term Support version)
130+
131+
For local development, the `docker-compose.yml` file includes a single MySQL service using the `mysql:lts` image to ensure we always test against the most recent Long Term Support version. The connection details are:
127132

128133
- Host: 127.0.0.1
129134
- Port: 3306
130135
- Database: serverless_mysql_test
131136
- User: root
132137
- Password: password
133138

139+
```bash
140+
# Start MySQL container
141+
docker compose up -d
142+
143+
# Run integration tests
144+
npm run test:integration
145+
146+
# Stop MySQL container when done
147+
docker compose down
148+
```
149+
134150
The MySQL container is configured with:
135-
- Native password authentication
136151
- 1000 max connections
137152
- Extended wait timeout (28800 seconds)
138153

139-
This is configured in the `docker-compose.yml` file and used by the GitHub Actions workflow for CI.
154+
The GitHub Actions workflow runs integration tests against both MySQL versions to ensure compatibility.
140155

141156
## Continuous Integration
142157

docker-compose.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
services:
22
mysql:
3-
image: mysql:8.0
3+
image: mysql:lts
44
container_name: serverless-mysql-test-db
55
environment:
66
MYSQL_ROOT_PASSWORD: password
@@ -13,7 +13,6 @@ services:
1313
ports:
1414
- "3306:3306"
1515
command: >
16-
--default-authentication-plugin=mysql_native_password
1716
--max_connections=1000
1817
--wait_timeout=28800
1918
healthcheck:

test/integration/change-user.spec.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,30 @@ describe('MySQL changeUser Integration Tests', function () {
7777

7878
it('should handle errors when changing to non-existent user', async function () {
7979
try {
80+
const nonExistentUser = 'non_existent_user_' + Date.now();
8081
await db.changeUser({
81-
user: 'non_existent_user_' + Date.now(),
82+
user: nonExistentUser,
8283
password: 'wrong_password'
8384
});
8485

8586
expect.fail('Should have thrown an error');
8687
} catch (error) {
8788
expect(error).to.be.an('error');
88-
expect(error).to.have.property('code');
89-
expect(error.message).to.include('Access denied for user', 'Error message should indicate access was denied');
89+
90+
// In MySQL 8.4+ (LTS), the mysql_native_password plugin is not loaded by default
91+
// In older MySQL versions, we get an access denied error
92+
expect(error.code).to.be.oneOf([
93+
'ER_ACCESS_DENIED_ERROR', // Older MySQL versions
94+
'ER_PLUGIN_IS_NOT_LOADED' // MySQL 8.4+ (LTS)
95+
]);
96+
97+
if (error.code === 'ER_PLUGIN_IS_NOT_LOADED') {
98+
expect(error.message).to.include('Plugin');
99+
expect(error.message).to.include('mysql_native_password');
100+
expect(error.message).to.include('not loaded');
101+
} else {
102+
expect(error.message).to.include('Access denied for user');
103+
}
90104
}
91105
});
92106

0 commit comments

Comments
 (0)