You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The port that MySQLX is listening on. If MySQL X is turned off, or ```options.xEnabled``` is set to "ON" and the X Plugin fails to initialise, this value will be -1.
82
82
-`dbName: string`
83
83
The database that was created on database initialization
84
84
-`username: string`
85
85
The name of the user to use to login to the database
86
86
-`socket: string`
87
87
If on Windows, this is the name of the named pipe that MySQL is listening on. If not on Windows, this is the path to the socket that MySQL is listening on.
88
88
-`xSocket: string`
89
-
If on Windows, this is the name of the named pipe that the MySQL X Plugin is listening on. If not on Windows, this is the path that the MySQL X Plugin is listening on.
An object with two properties. ```version``` is the version of MySQL used to create the database. ```versionIsInstalledOnSystem``` will be true if the MySQL version used is already installed on the system and false if the version had to be downloaded from MySQL's CDN.
89
+
If on Windows, this is the name of the named pipe that the MySQL X Plugin is listening on. If not on Windows, this is the path that the MySQL X Plugin is listening on. If MySQL X is turned off, or ```options.xEnabled``` is set to "ON" and the X Plugin fails to initialise, this value will be an empty string.
An object with three properties. ```version``` is the version of MySQL used to create the database. ```versionIsInstalledOnSystem``` will be true if the MySQL version used is already installed on the system and false if the version had to be downloaded from MySQL's CDN. ```xPluginIsEnabled``` will be true if ```options.xEnabled``` is set to "FORCE", will be false if ```options.xEnabled``` is set to "OFF", and if ```options.xEnabled``` is set to "ON", this value will be true if the plugin initialised successfully, otherwise this value will be false.
92
92
-`stop: () => Promise<void>`
93
93
The method to stop the database. The returned promise resolves when the database has successfully stopped.
94
94
@@ -189,3 +189,9 @@ The internal queries that are ran before the queries in ```initSQLString``` are
189
189
Default: process.arch
190
190
191
191
Description: The MySQL binary architecture to execute. MySQL does not offer server builds for Windows on ARM, so to get this package working on Windows on ARM, set the arch option to "x64" and Windows will emulate MySQL.
192
+
193
+
-`xEnabled: "OFF" | "ON" | "FORCE"`
194
+
195
+
Default: "FORCE"
196
+
197
+
Description: This option follows the convention set out by the [MySQL Documentation](https://dev.mysql.com/doc/refman/en/plugin-loading.html). If set to "OFF", the MySQL X Plugin will not initialise. If set to "ON", the MySQL X Plugin will try to initialise, but if the initialisation process fails, the MySQL Server will continue the startup process with the plugin disabled. If set to "FORCE", the MySQL Server will not start up without a successful initialisation of the plugin. With this option set to "FORCE", the server will either start up with the plugin enabled, or the server will fail to start up.
//<8.0.11 does not have MySQL X turned on by default so we will be installing the X Plugin in this if statement.
95
-
//MySQL 5.7.12 introduced the X plugin, but according to https://dev.mysql.com/doc/refman/5.7/en/document-store-setting-up.html, the database needs to be initialised with version 5.7.19.
96
-
//If the MySQL version is >=5.7.19 & <8.0.11 then install the X Plugin
//<8.0.11 does not have MySQL X turned on by default so we will be installing the X Plugin in this if statement.
100
+
//MySQL 5.7.12 introduced the X plugin, but according to https://dev.mysql.com/doc/refman/5.7/en/document-store-setting-up.html, the database needs to be initialised with version 5.7.19.
101
+
//If the MySQL version is >=5.7.19 & <8.0.11 then install the X Plugin
this.logger.error('MySQL X failed to start successfully and xEnabled is set to "FORCE". Error log is above this message. If this is happening continually and you can start the database without the X Plugin, you can set options.xEnabled to "ON" or "OFF" instead of "FORCE".')
233
+
constkilled=awaitthis.#killProcess(process)
234
+
if(!killed){
235
+
this.logger.error('Failed to kill MySQL process after MySQL X failing to initialise.')
236
+
}
237
+
returnreject('X Plugin failed to start and options.xEnabled is set to "FORCE".')
this.logger.log('Starting process was successful')
520
536
returnresolved
521
537
}catch(e){
@@ -526,7 +542,7 @@ class Executor {
526
542
}
527
543
retries++
528
544
if(retries<=options.portRetries){
529
-
this.logger.warn(`One or both of these ports are already in use: ${port} or ${mySQLXPort}. Now retrying... ${retries}/${options.portRetries} possible retries.`)
545
+
this.logger.warn(`Tried a port that is already in use. Now retrying... ${retries}/${options.portRetries} possible retries.`)
530
546
}else{
531
547
throw`The port has been retried ${options.portRetries} times and a free port could not be found.\nEither try again, or if this is a common issue, increase options.portRetries.`
throw'serverAddress is a string. Should be an object'
102
+
}
103
+
if(serverAddress===null){
104
+
throw'serverAddress is null. Should be an object.'
105
+
}
106
+
107
+
constoptions: ServerOptions={
108
+
arch,
109
+
logLevel: 'LOG',
110
+
xPort: serverAddress.port,// Use a port that is already in use to get X to fail
111
+
xEnabled: 'FORCE',
112
+
initSQLString: 'SELECT 2+2;'
113
+
}
114
+
115
+
letthrown: string|boolean=false;
116
+
117
+
try{
118
+
awaitcreateDB(options)
119
+
}catch(e){
120
+
thrown=e
121
+
}
122
+
123
+
awaitnewPromise(resolve=>{
124
+
server.on('close',resolve)
125
+
server.close()
126
+
})
127
+
128
+
expect(thrown).toBe('The port has been retried 10 times and a free port could not be found.\nEither try again, or if this is a common issue, increase options.portRetries.')
0 commit comments