Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
165 commits
Select commit Hold shift + click to select a range
52372d6
add download support for Windows
Sebastian-Webster Jan 26, 2025
2ca801e
use all MySQL versions
Sebastian-Webster Jan 26, 2025
7a003eb
remove x in minOS
Sebastian-Webster Jan 26, 2025
cec459a
update base URL
Sebastian-Webster Jan 26, 2025
0ae6011
update messages and error handling
Sebastian-Webster Jan 26, 2025
a821783
fix typo
Sebastian-Webster Jan 26, 2025
16afb64
use 404 for temp link
Sebastian-Webster Jan 26, 2025
31e5f7a
add download log
Sebastian-Webster Jan 26, 2025
e3d2064
add ability to download DMR and RC MySQL versions
Sebastian-Webster Jan 26, 2025
9b42e04
temporarily remove 5.7.19 download
Sebastian-Webster Jan 26, 2025
eaad716
fix typo
Sebastian-Webster Jan 26, 2025
33c0ea0
reduce versions for regular test
Sebastian-Webster Jan 27, 2025
d823384
swap satisifes parameters
Sebastian-Webster Jan 27, 2025
7b1f220
change url
Sebastian-Webster Jan 27, 2025
1af1d6e
modify tests
Sebastian-Webster Jan 27, 2025
b489220
add version 9.0.1
Sebastian-Webster Jan 27, 2025
230b032
change test versions
Sebastian-Webster Jan 27, 2025
ddbe715
add version 9.0.1
Sebastian-Webster Jan 27, 2025
c772402
update test versions
Sebastian-Webster Jan 27, 2025
b2c9bf9
update test versions
Sebastian-Webster Jan 27, 2025
04198c9
change downloadBinaryOnce to true for versions test
Sebastian-Webster Jan 27, 2025
b12fe72
update base url
Sebastian-Webster Jan 27, 2025
cf40d1e
set downloadBinaryOnce to false
Sebastian-Webster Jan 27, 2025
1aa3b46
move all version tests to stress and shard stress tests
Sebastian-Webster Jan 27, 2025
ab924f1
add ci name to stress tests
Sebastian-Webster Jan 27, 2025
f179814
remove shards
Sebastian-Webster Jan 27, 2025
19832c1
replace unlink with rm (#185)
Sebastian-Webster Jan 27, 2025
736a7a4
add retrying MySQL download with different URL on 404 error
Sebastian-Webster Jan 27, 2025
70631d6
fix error in log
Sebastian-Webster Jan 27, 2025
569066c
set downloadBinaryOnce to false
Sebastian-Webster Jan 27, 2025
5c09f6e
add extra logs for downloadBinaryOnce false
Sebastian-Webster Jan 27, 2025
5c4bde7
add macOS download support
Sebastian-Webster Jan 27, 2025
9bfbbb6
change compression level
Sebastian-Webster Jan 28, 2025
850cbb4
remove 8.4.1 for download
Sebastian-Webster Jan 28, 2025
ab0c655
demote download try failure from error to warn
Sebastian-Webster Jan 28, 2025
1d3693b
remove warning
Sebastian-Webster Jan 28, 2025
2d41980
add version 5.7.19 back
Sebastian-Webster Jan 28, 2025
5ffb21c
remove 5.7.19 from download and update README about versions availabl…
Sebastian-Webster Jan 28, 2025
c9fe078
do OS, OS version, and arch checks before choosing a version to run
Sebastian-Webster Jan 28, 2025
c62dfcc
get min version for MySQL download from downloadable versions array
Sebastian-Webster Jan 28, 2025
70dabfa
add OSVersionKey log
Sebastian-Webster Jan 28, 2025
12479fc
remove 5.7.19 test
Sebastian-Webster Jan 28, 2025
3613dd6
add possibleVersion log
Sebastian-Webster Jan 28, 2025
95e4ead
fix runningMySQL versions that need >= macOS 10.14 throws an error
Sebastian-Webster Jan 28, 2025
e12e0e5
remove downloadBinaryOnce false for versions test
Sebastian-Webster Jan 28, 2025
d8a5b3b
add log for os version check
Sebastian-Webster Jan 28, 2025
495a0c6
add OSKey log
Sebastian-Webster Jan 28, 2025
c1f3de1
add possibleVersion log
Sebastian-Webster Jan 28, 2025
aae8cf9
update log
Sebastian-Webster Jan 28, 2025
986bf76
add selectedVersions log
Sebastian-Webster Jan 28, 2025
862219a
fix macOS tests failing for 5.7.x
Sebastian-Webster Jan 28, 2025
44518f3
removed macOS 13 test
Sebastian-Webster Jan 28, 2025
b3b406b
use x64 if on windows on arm otherwise use native arch for tests
Sebastian-Webster Jan 28, 2025
0043c0f
skip tests if the MySQL version does not support the CPU architecture
Sebastian-Webster Jan 28, 2025
9e7ad1d
check if binary is supported before running test
Sebastian-Webster Jan 28, 2025
3d9e4a4
detect open handles
Sebastian-Webster Jan 28, 2025
e770f5a
remove detectOpenHandles
Sebastian-Webster Jan 28, 2025
7ee4e43
use fileStream.end instead of fileStream.close
Sebastian-Webster Jan 28, 2025
664315a
move 404 retry to downloadBinary method
Sebastian-Webster Jan 29, 2025
4e64210
continue on 404 error
Sebastian-Webster Jan 29, 2025
f7d239d
add support for MySQL downloads on Linux
Sebastian-Webster Jan 29, 2025
5bafde0
fix Linux downloads not working
Sebastian-Webster Jan 29, 2025
f8abdd1
fix downloads not working for MySQL < 8.0.12 on linux
Sebastian-Webster Jan 29, 2025
fc2443c
add fedora 40 stress test
Sebastian-Webster Jan 29, 2025
0415b85
add container matrix
Sebastian-Webster Jan 29, 2025
3c0afe0
use all downloadable MySQL versions in versions test
Sebastian-Webster Jan 29, 2025
14fe759
free space for ubuntu and mac
Sebastian-Webster Jan 29, 2025
37b829b
fix typo
Sebastian-Webster Jan 29, 2025
84036f7
add free disk space to fedora
Sebastian-Webster Jan 29, 2025
a8d88be
delete the database if the run was successful
Sebastian-Webster Jan 29, 2025
24018cb
set downloadBinaryOnce to false
Sebastian-Webster Jan 29, 2025
04a40f3
add macos 13 tests
Sebastian-Webster Jan 29, 2025
2e95371
print available storage space in fedora
Sebastian-Webster Jan 29, 2025
2e1620c
move available storage step
Sebastian-Webster Jan 29, 2025
33e7355
add logs when deleting database in ci
Sebastian-Webster Jan 29, 2025
fa0c461
decrease versions temporarily
Sebastian-Webster Jan 29, 2025
c358680
increase versions
Sebastian-Webster Jan 29, 2025
8ad4001
increase versions
Sebastian-Webster Jan 29, 2025
ed1e4aa
increase versions
Sebastian-Webster Jan 29, 2025
e36a94a
increase versions
Sebastian-Webster Jan 29, 2025
c3c781c
add support for downloading MySQL 8.0.26 on Linux
Sebastian-Webster Jan 29, 2025
a7e93c3
increase versions
Sebastian-Webster Jan 29, 2025
5456909
install required package on fedora
Sebastian-Webster Jan 29, 2025
e1df467
change versions
Sebastian-Webster Jan 29, 2025
912c558
change versions
Sebastian-Webster Jan 29, 2025
27622c4
change versions
Sebastian-Webster Jan 29, 2025
ea3e531
change libaio copy path
Sebastian-Webster Jan 29, 2025
e8bab8f
remove free space steps
Sebastian-Webster Jan 29, 2025
861214d
make private folder if version is less than 8.0.18
Sebastian-Webster Jan 29, 2025
721e2bc
only put libaio in private folder if gte 8.0.18
Sebastian-Webster Jan 29, 2025
1f9c096
change location for libaio copy
Sebastian-Webster Jan 29, 2025
8004413
copy libaio into bin for all versions
Sebastian-Webster Jan 29, 2025
54e6d22
revert libaio copy path
Sebastian-Webster Jan 29, 2025
a2a693d
test all downloadable MySQL versions
Sebastian-Webster Jan 29, 2025
5973dde
change versions
Sebastian-Webster Jan 29, 2025
1c2783a
change versions
Sebastian-Webster Jan 29, 2025
6cb073e
add support for MySQL 8.0.0 - 8.0.4 on Linux
Sebastian-Webster Jan 29, 2025
0d8d08f
change libaio copy path for lt 8.0.4
Sebastian-Webster Jan 29, 2025
b387847
change libaio copy path for lt 8.0.4
Sebastian-Webster Jan 29, 2025
1bd4328
change libaio copy path for lt 8.0.4
Sebastian-Webster Jan 29, 2025
9cdef03
remove compression and add free space back
Sebastian-Webster Jan 29, 2025
8623a96
use all downloadable versions
Sebastian-Webster Jan 29, 2025
df3252e
test low 8.x versions
Sebastian-Webster Jan 30, 2025
bf45700
add 5.7.44
Sebastian-Webster Jan 30, 2025
c695b6f
change how username is changed
Sebastian-Webster Jan 30, 2025
e9156b9
change versions
Sebastian-Webster Jan 30, 2025
523d4c5
add successful database deletion back
Sebastian-Webster Jan 30, 2025
7cee796
test 5.7.x
Sebastian-Webster Jan 30, 2025
e49fb00
test 5.7.19
Sebastian-Webster Jan 30, 2025
38334be
test 8.x
Sebastian-Webster Jan 30, 2025
de564b9
test 5.7.19
Sebastian-Webster Jan 30, 2025
94e390c
test 8.x
Sebastian-Webster Jan 30, 2025
3f4d8d0
test 9.x
Sebastian-Webster Jan 30, 2025
2aacf47
use zip.extractAllToAsync
Sebastian-Webster Jan 31, 2025
69ae7f5
use 8.0.0 - 8.0.11 in tests
Sebastian-Webster Jan 31, 2025
474e358
add folder name log
Sebastian-Webster Jan 31, 2025
f1a0ab1
keep original permission
Sebastian-Webster Jan 31, 2025
18efb5a
lower timeout and versions
Sebastian-Webster Jan 31, 2025
49964ea
add temp message
Sebastian-Webster Jan 31, 2025
45bc5a2
change zip extraction params
Sebastian-Webster Jan 31, 2025
d3fbfa5
disallow MySQL < 8.0.4 downloads on Ubuntu >= 24.04
Sebastian-Webster Feb 1, 2025
bb9aa54
only check os-release on Linux
Sebastian-Webster Feb 1, 2025
2089640
filter any items not less than 8.0.4
Sebastian-Webster Feb 1, 2025
fe72de2
etcOSRelease
Sebastian-Webster Feb 1, 2025
5430888
use es2021
Sebastian-Webster Feb 1, 2025
b78f4ce
remove quotation marks in etcOSRelease string
Sebastian-Webster Feb 1, 2025
0f5b38d
add type safety to os release checker
Sebastian-Webster Feb 1, 2025
e3decf4
stop using semver lt for ubuntu version comparison
Sebastian-Webster Feb 1, 2025
7175638
change versions test to properly check what versions can run on the s…
Sebastian-Webster Feb 1, 2025
b166cb6
make getBinaryURL synchronous
Sebastian-Webster Feb 1, 2025
8d56db6
test all downloadable versions
Sebastian-Webster Feb 1, 2025
7dfaa60
split seperate versions into different jobs
Sebastian-Webster Feb 1, 2025
c95d5ea
change versions test
Sebastian-Webster Feb 1, 2025
58768b4
add version requirement to artifact name
Sebastian-Webster Feb 1, 2025
09920d8
use all versions for tests
Sebastian-Webster Feb 2, 2025
d818930
only run versions that fit the version requirement
Sebastian-Webster Feb 3, 2025
1bbadee
remove free space steps
Sebastian-Webster Feb 3, 2025
c1a6a53
correct version requirement names
Sebastian-Webster Feb 3, 2025
bbe0667
add dummy test
Sebastian-Webster Feb 3, 2025
a798212
add comment
Sebastian-Webster Feb 3, 2025
5f8261a
properly wait for zip extraction
Sebastian-Webster Feb 3, 2025
c693391
remove successful db deletion in version test
Sebastian-Webster Feb 3, 2025
87516c6
remove downloadBinaryOnce for version test
Sebastian-Webster Feb 3, 2025
09da8c3
fix subsequent database creations failing and change tests
Sebastian-Webster Feb 3, 2025
9a3f269
fix concurrency test bug
Sebastian-Webster Feb 3, 2025
c88ef54
lower concurrency test amount to 3 from 10
Sebastian-Webster Feb 3, 2025
ac24477
split tests up further
Sebastian-Webster Feb 3, 2025
056fc8b
change timeout for version tests
Sebastian-Webster Feb 4, 2025
d31df49
detect open handles
Sebastian-Webster Feb 4, 2025
1b5054a
remove unneccesary imports
Sebastian-Webster Feb 4, 2025
d7a1894
await lock release
Sebastian-Webster Feb 4, 2025
108c136
removed unneccesary code
Sebastian-Webster Feb 4, 2025
7807c1f
reogranise extractBinary function
Sebastian-Webster Feb 4, 2025
04ff083
end request on error
Sebastian-Webster Feb 4, 2025
d6c66c9
remove detectOpenHandles
Sebastian-Webster Feb 4, 2025
bbaab1a
merge main
Sebastian-Webster Feb 4, 2025
31c5d32
os compat tests will now only run versions test
Sebastian-Webster Feb 4, 2025
60a6a8c
use macos latest in ci test
Sebastian-Webster Feb 4, 2025
337bb4c
remove dashes in database path
Sebastian-Webster Feb 4, 2025
9b98a76
increase timeout to 10 minutes
Sebastian-Webster Feb 4, 2025
1f2d173
add user agent to download request
Sebastian-Webster Feb 4, 2025
797f77f
Merge branch 'main' into 183-allow-downloading-all-supported-mysql-ve…
Sebastian-Webster Feb 5, 2025
04a1555
do not run asynchronous tasks on exit from signal
Sebastian-Webster Feb 5, 2025
fda439b
destroy https request on non-200 status code
Sebastian-Webster Feb 8, 2025
ce4ab39
remove user agent
Sebastian-Webster Feb 9, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
ci:
runs-on: ubuntu-latest
runs-on: macos-latest

steps:
- name: Checkout
Expand Down
29 changes: 20 additions & 9 deletions .github/workflows/os-compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
fail-fast: false
matrix:
os: [macos-13, macos-14, macos-15, ubuntu-20.04, ubuntu-22.04, ubuntu-24.04, windows-2019, windows-2022]
#There is no 10.0.0 at the time of writing, but since greater than characters are not allowed in GitHub Actions artifacts names, 9.0.1 - 10.0.0 will be used instead of >9.0.0
version-requirement: ['5.7.19 - 5.7.24', '5.7.25 - 5.7.29', '5.7.30 - 5.7.34', '5.7.35 - 5.7.39', '5.7.40 - 5.7.44', '8.0.0 - 8.0.4', '8.0.4 - 8.0.13', '8.0.14 - 8.0.19', '8.0.20 - 8.0.24', '8.0.25 - 8.0.29', '8.0.30 - 8.0.34', '8.0.35 - 8.0.39', '8.0.40 - 8.3.0', '8.4.0 - 9.0.0', '9.0.1 - 10.0.0']

steps:
- name: Checkout
Expand All @@ -29,23 +31,25 @@ jobs:
run: npm ci

- name: Run tests
run: npm run test:ci
env:
VERSION_REQUIREMENT: ${{ matrix.version-requirement }}
run: npm run os-compat:ci

- name: Upload mysqlmsn directory (Windows)
if: ${{ failure() && runner.os == 'Windows' }}
uses: actions/upload-artifact@v4.3.5
with:
name: ${{ matrix.os }}
name: ${{ matrix.os }}-${{ matrix.version-requirement }}
path: "C:\\Users\\RUNNER~1\\mysqlmsn"
compression-level: 9
compression-level: 0

- name: Upload mysqlmsn directory (Not Windows)
if: ${{ failure() && runner.os != 'Windows' }}
uses: actions/upload-artifact@v4.3.5
with:
name: ${{ matrix.os }}
name: ${{ matrix.os }}-${{ matrix.version-requirement }}
path: /tmp/mysqlmsn
compression-level: 9
compression-level: 0

fedora-docker:
runs-on: ubuntu-latest
Expand All @@ -54,6 +58,8 @@ jobs:
fail-fast: false
matrix:
version: [40]
#There is no 10.0.0 at the time of writing, but since greater than characters are not allowed in GitHub Actions artifacts names, 9.0.1 - 10.0.0 will be used instead of >9.0.0
version-requirement: ['5.7.19 - 5.7.24', '5.7.25 - 5.7.29', '5.7.30 - 5.7.34', '5.7.35 - 5.7.39', '5.7.40 - 5.7.44', '8.0.0 - 8.0.4', '8.0.4 - 8.0.13', '8.0.14 - 8.0.19', '8.0.20 - 8.0.24', '8.0.25 - 8.0.29', '8.0.30 - 8.0.34', '8.0.35 - 8.0.39', '8.0.40 - 8.3.0', '8.4.0 - 9.0.0', '9.0.1 - 10.0.0']

container: fedora:${{ matrix.version }}

Expand All @@ -68,18 +74,23 @@ jobs:
check-latest: true

- name: Install required libraries
run: sudo dnf install libaio numactl -y
run: sudo dnf install libaio numactl libxcrypt-compat -y

- name: Install packages
run: npm ci

- name: Print available storage space
run: df -h

- name: Run tests
run: npm run test:ci
env:
VERSION_REQUIREMENT: ${{ matrix.version-requirement }}
run: npm run os-compat:ci

- name: Upload mysqlmsn directory
if: ${{ failure() }}
uses: actions/upload-artifact@v4.3.5
with:
name: docker-fedora-${{ matrix.version }}
name: docker-fedora-${{ matrix.version }}-${{ matrix.version-requirement }}
path: /tmp/mysqlmsn
compression-level: 9
compression-level: 0
71 changes: 0 additions & 71 deletions .github/workflows/stress.yml

This file was deleted.

2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ There are also automated tests which you can run by running the command:
npm test
```

Please do not run the `npm run test:ci` command to test your code locally. That command is meant to only be used in GitHub Actions.
Please do not run the `npm run test:ci` or `npm run stress:ci` command to test your code locally. That command is meant to only be used in GitHub Actions.

# Submitting the pull request

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ Requirements for Linux:

#### Currently supported MySQL versions

- Running MySQL versions already installed on the system: 5.7.19 and newer
- MySQL versions available to download through ```mysql-memory-server``` and run: 8.0.39 - 8.0.41, 8.1.0 - 8.3.0, 8.4.2 - 8.4.4, and 9.0.1 - 9.2.0
- ```mysql-memory-server``` can run MySQL versions 5.7.19 and newer
- ```mysql-memory-server``` can download MySQL versions 5.7.20 - 9.2.0

## Example Usage - Application Code

Expand Down
11 changes: 10 additions & 1 deletion ciSetup.js
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
process.env.useCIDBPath = true;
const { normalize } = require("path");

process.env.useCIDBPath = true;

const GitHubActionsTempFolder = process.platform === 'win32' ? 'C:\\Users\\RUNNER~1\\mysqlmsn' : '/tmp/mysqlmsn'

process.env.mysqlmsn_internal_DO_NOT_USE_databaseDirectoryPath = normalize(GitHubActionsTempFolder + '/dbs')
process.env.mysqlmsn_internal_DO_NOT_USE_binaryDirectoryPath = normalize(GitHubActionsTempFolder + '/binaries')

process.env.mysqlmsn_internal_DO_NOT_USE_deleteDBAfterStopped = false;
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
"memory database"
],
"scripts": {
"test": "jest --testPathIgnorePatterns=/stress-tests/ --verbose --colors",
"test:ci": "jest --testPathIgnorePatterns=/stress-tests/ --setupFilesAfterEnv ./ciSetup.js --verbose --colors",
"stress": "jest --runTestsByPath stress-tests/stress.test.ts --setupFilesAfterEnv ./ciSetup.js --verbose --colors"
"test": "jest --verbose --colors",
"test:ci": "jest --setupFilesAfterEnv ./ciSetup.js --verbose --colors --runTestsByPath tests/concurrency.test.ts",
"os-compat:ci": "jest --setupFilesAfterEnv ./ciSetup.js --verbose --colors --runTestsByPath tests/versions.test.ts"
},
"engines": {
"node": ">=16.6.0",
Expand Down
91 changes: 84 additions & 7 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import {normalize as normalizePath} from 'path'
import { tmpdir } from "os";
import { valid as validSemver, coerce as coerceSemver } from "semver";

export const MIN_SUPPORTED_MYSQL = '5.7.19';

export const DEFAULT_OPTIONS_GENERATOR: () => InternalServerOptions = () => ({
export const DEFAULT_OPTIONS: InternalServerOptions = {
version: undefined,
dbName: 'dbdata',
logLevel: 'ERROR',
Expand All @@ -21,9 +19,9 @@ export const DEFAULT_OPTIONS_GENERATOR: () => InternalServerOptions = () => ({
downloadRetries: 10,
initSQLString: '',
arch: process.arch
});
} as const;

export const DEFAULT_OPTIONS_KEYS = Object.freeze(Object.keys(DEFAULT_OPTIONS_GENERATOR()))
export const DEFAULT_OPTIONS_KEYS = Object.freeze(Object.keys(DEFAULT_OPTIONS))

export const LOG_LEVELS = {
'LOG': 0,
Expand All @@ -34,7 +32,7 @@ export const LOG_LEVELS = {
const internalOptions = {
deleteDBAfterStopped: 'true',
//mysqlmsn = MySQL Memory Server Node.js
dbPath: normalizePath(`${tmpdir()}/mysqlmsn/dbs/${randomUUID().replace(/-/g, '')}`),
databaseDirectoryPath: normalizePath(`${tmpdir()}/mysqlmsn/dbs`),
binaryDirectoryPath: `${tmpdir()}/mysqlmsn/binaries`,
cli: 'false'
}
Expand Down Expand Up @@ -115,4 +113,83 @@ export const OPTION_TYPE_CHECKS: OptionTypeChecks = {
errorMessage: `Option arch must be either of the following: ${allowedArches.join(', ')}`,
definedType: 'string'
}
} as const;
} as const;

export const MIN_SUPPORTED_MYSQL = '5.7.19';
export const downloadsBaseURL = 'https://cdn.mysql.com//Downloads/MySQL-'
export const archiveBaseURL = 'https://cdn.mysql.com/archives/mysql-'
// Versions 8.0.29, 8.0.38, 8.4.1, and 9.0.0 have been purposefully left out of this list as MySQL has removed them from the CDN due to critical issues.
export const DOWNLOADABLE_MYSQL_VERSIONS = [
'5.7.19', '5.7.20', '5.7.21', '5.7.22', '5.7.23', '5.7.24', '5.7.25', '5.7.26', '5.7.27', '5.7.28', '5.7.29', '5.7.30', '5.7.31', '5.7.32', '5.7.33', '5.7.34', '5.7.35', '5.7.36', '5.7.37', '5.7.38', '5.7.39', '5.7.40', '5.7.41', '5.7.42', '5.7.43', '5.7.44',

'8.0.0', '8.0.1', '8.0.2', '8.0.3', '8.0.4',

'8.0.11', '8.0.12', '8.0.13', '8.0.14', '8.0.15', '8.0.16', '8.0.17', '8.0.18', '8.0.19', '8.0.20', '8.0.21', '8.0.22', '8.0.23', '8.0.24', '8.0.25', '8.0.26', '8.0.27', '8.0.28', '8.0.30', '8.0.31', '8.0.32', '8.0.33', '8.0.34', '8.0.35', '8.0.36', '8.0.37', '8.0.39', '8.0.40', '8.0.41',

'8.1.0', '8.2.0', '8.3.0',

'8.4.0', '8.4.2', '8.4.3', '8.4.4',

'9.0.1', '9.1.0', '9.2.0'
] as const;
export const MYSQL_ARCH_SUPPORT = {
darwin: {
arm64: '8.0.26 - 9.2.0',
x64: '5.7.19 - 9.2.0'
},
linux: {
arm64: '8.0.31 - 9.2.0',
x64: '5.7.19 - 9.2.0'
},
win32: {
x64: '5.7.19 - 9.2.0'
}
} as const;
export const MYSQL_MIN_OS_SUPPORT = {
win32: {
x: '0.0.0' // No minimum version is documented as far as I can tell, so allow any minimum version
},
linux: {
x: '0.0.0'// No minimum version is documented as far as I can tell, so allow any minimum version
},
darwin: {
'5.7.19 - 5.7.23 || 8.0.1 - 8.0.3 || 8.0.11 - 8.0.12': '16.0.0',
'5.7.24 - 5.7.29 || 8.0.4 || 8.0.13 - 8.0.18': '17.0.0',
'5.7.30 - 5.7.31 || 8.0.19 - 8.0.22': '18.0.0',
//5.7.32 - 5.7.44 is not supported for macOS by MySQL. Those versions are not appearing in this list
'8.0.0': '13.0.0',
'8.0.23 - 8.0.27': '19.0.0',
'8.0.28 - 8.0.31': '20.0.0',
'8.0.32 - 8.0.34': '21.0.0',
'8.0.35 - 8.0.39 || 8.1.0 - 8.4.2': '22.0.0',
'8.0.40 - 8.0.41 || 8.4.3 - 9.2.0': '23.0.0'
}
} as const;
export const DMR_MYSQL_VERSIONS = '8.0.0 - 8.0.2';
export const RC_MYSQL_VERSIONS = '8.0.3 - 8.0.4';
export const MYSQL_MACOS_VERSIONS_IN_FILENAME = {
'5.7.19 - 5.7.20 || 8.0.1 - 8.0.3': 'macos10.12',
'5.7.21 - 5.7.23 || 8.0.4 - 8.0.12': 'macos10.13',
'5.7.24 - 5.7.31 || 8.0.13 - 8.0.18': 'macos10.14',
'8.0.0': 'osx10.11',
'8.0.19 - 8.0.23': 'macos10.15',
'8.0.24 - 8.0.28': 'macos11',
'8.0.30 - 8.0.31': 'macos12',
'8.0.32 - 8.0.35 || 8.1.0 - 8.2.0': 'macos13',
'8.0.36 - 8.0.40 || 8.3.0 - 8.4.3 || 9.0.1 - 9.1.0': 'macos14',
'8.0.41 || 8.4.4 || 9.2.0': 'macos15'
} as const;
export const MYSQL_LINUX_GLIBC_VERSIONS = {
'5.7.19 - 8.0.20': '2.12',
'8.0.21 - 9.2.0': '2.17'
} as const;
export const MYSQL_LINUX_MINIMAL_INSTALL_AVAILABLE = {
'5.7.19 - 8.0.15': 'no',
'8.0.16 - 8.0.20': 'no-glibc-tag',
'8.0.21 - 9.2.0': 'glibc-tag'
} as const;
export const MYSQL_LINUX_FILE_EXTENSIONS = {
'5.7.19 - 8.0.11': 'gz',
'8.0.12 - 9.2.0': 'xz'
} as const;
export const MYSQL_LINUX_MINIMAL_REBUILD_VERSIONS = '8.0.26';
29 changes: 6 additions & 23 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import Logger from './libraries/Logger'
import * as os from 'node:os'
import Executor from "./libraries/Executor"
import { satisfies, lt, coerce } from "semver"
import { BinaryInfo, ServerOptions } from '../types'
import { satisfies, lt } from "semver"
import { BinaryInfo, InternalServerOptions, ServerOptions } from '../types'
import getBinaryURL from './libraries/Version'
import MySQLVersions from './versions.json'
import { downloadBinary } from './libraries/Downloader'
import { MIN_SUPPORTED_MYSQL, DEFAULT_OPTIONS_KEYS, OPTION_TYPE_CHECKS, DEFAULT_OPTIONS_GENERATOR } from './constants'
import { MIN_SUPPORTED_MYSQL, DEFAULT_OPTIONS_KEYS, OPTION_TYPE_CHECKS, DEFAULT_OPTIONS } from './constants'

export async function createDB(opts?: ServerOptions) {
const suppliedOpts = opts || {};
const suppliedOptsKeys = Object.keys(suppliedOpts);

const options = DEFAULT_OPTIONS_GENERATOR();
const options: InternalServerOptions = {...DEFAULT_OPTIONS}

for (const opt of suppliedOptsKeys) {
if (!DEFAULT_OPTIONS_KEYS.includes(opt)) {
Expand Down Expand Up @@ -47,28 +45,13 @@ export async function createDB(opts?: ServerOptions) {
if (version === null || (options.version && !satisfies(version.version, options.version)) || unsupportedMySQLIsInstalled) {
let binaryInfo: BinaryInfo;
let binaryFilepath: string;
try {
binaryInfo = getBinaryURL(MySQLVersions, options.version, options)
logger.log('Using MySQL binary version:', binaryInfo.version, 'from URL:', binaryInfo.url)
} catch (e) {
if (options.version && lt(coerce(options.version), MIN_SUPPORTED_MYSQL)) {
//The difference between the throw here and the throw above is this throw is because the selected "version" is not supported.
//The throw above is because the system-installed MySQL is out of date and "ignoreUnsupportedSystemVersion" is not set to true.
throw `The selected version of MySQL (${options.version}) is not currently supported by this package. Please choose a different version to use.`
}

logger.error(e)
if (options.version) {
throw `A MySQL version ${options.version} binary could not be found that supports your OS (${os.platform()} | ${os.version()} | ${os.release()}) and CPU architecture (${os.arch()}). Please check you have the latest version of mysql-memory-server. If the latest version still doesn't support the version you want to use, feel free to make a pull request to add support!`
}
throw `A MySQL binary could not be found that supports your OS (${os.platform()} | ${os.version()} | ${os.release()}) and CPU architecture (${os.arch()}). Please check you have the latest version of mysql-memory-server. If the latest version still doesn't support your OS and CPU architecture, feel free to make a pull request to add support!`
}
binaryInfo = getBinaryURL(options.version, options.arch)

try {
binaryFilepath = await downloadBinary(binaryInfo, options, logger);
} catch (error) {
logger.error('Failed to download binary:', error)
throw `Failed to download binary. The error was: "${error}"`
throw `Failed to download binary. The error was: "${error}"`
}

logger.log('Running downloaded binary')
Expand Down
Loading