N°6123 - Add tests and comments

This commit is contained in:
Stephen Abello
2023-07-07 09:29:08 +02:00
parent 264a8cd70a
commit 9afc22bd8f
2 changed files with 31 additions and 0 deletions

View File

@@ -523,6 +523,8 @@ EOF;
}
/**
* Define if we should force a transport option
*
* @param string $sHost
*
* @return string .
@@ -533,6 +535,8 @@ EOF;
{
$sTransportOptions = '';
/** N°6123 As we're using a --port option, if we use localhost as host,
* MariaDB > 10.6 will implicitly change its protocol from socket to tcp and throw a warning **/
if($sHost === 'localhost'){
$sTransportOptions = '--protocol=tcp';
}

View File

@@ -84,4 +84,31 @@ class DBBackupTest extends ItopTestCase
$this->assertStringStartsWith(' --ssl', $sCliArgsCapathCfg);
$this->assertStringEndsWith('--ssl-ca='.DBBackup::EscapeShellArg($sTestCa), $sCliArgsCapathCfg);
}
/**
* Host is localhost, we should be forced into tcp
*
* @return void
*/
public function testGetMysqlCliTransportOptionWithLocalhost()
{
$sHost= 'localhost';
$sTransport = DBBackup::GetMysqlCliTransportOption($sHost);
$this->assertStringStartsWith('--protocol=tcp', $sTransport);
$this->assertStringEndsWith('--protocol=tcp', $sTransport);
}
/**
* Host is not localhost, we shouldn't be forced into tcp
*
* @return void
*/
public function testGetMysqlCliTransportOptionWithoutLocalhost()
{
$sHost= '127.0.0.1';
$sTransport = DBBackup::GetMysqlCliTransportOption($sHost);
$this->assertEmpty($sTransport);
}
}