Skip to content

Commit 38f2206

Browse files
committed
Merge remote-tracking branch 'origin/B2B-1986' into B2B-2022
2 parents 090cbe8 + 63f6c85 commit 38f2206

File tree

1 file changed

+44
-7
lines changed
  • dev/tests/integration/framework/Magento/TestFramework/Db

1 file changed

+44
-7
lines changed

dev/tests/integration/framework/Magento/TestFramework/Db/Mysql.php

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ class Mysql extends \Magento\TestFramework\Db\AbstractDb
4747
/**
4848
* @var bool
4949
*/
50-
private $mysqlDumpVersionIs8;
50+
private $isMysqldumpVersion8;
51+
52+
/**
53+
* @var bool
54+
*/
55+
private $isUsingAuroraDb;
5156

5257
/**
5358
* {@inheritdoc}
@@ -116,17 +121,21 @@ public function isDbDumpExists()
116121
public function storeDbDump()
117122
{
118123
$this->ensureDefaultsExtraFile();
119-
$additionalArguments = '';
124+
$additionalArguments = [];
120125

121126
if ($this->isMysqlDumpVersion8()) {
122-
$additionalArguments = '--column-statistics=0';
127+
$additionalArguments[] = '--column-statistics=0';
128+
}
129+
130+
if ($this->isUsingAuroraDb()) {
131+
$additionalArguments[] = '--set-gtid-purged=OFF';
123132
}
124133

125134
$format = sprintf(
126135
'%s %s %s %s',
127136
'mysqldump --defaults-file=%s --host=%s --port=%s',
128137
'--no-tablespaces',
129-
$additionalArguments,
138+
implode(' ', $additionalArguments),
130139
'%s > %s'
131140
);
132141

@@ -194,14 +203,42 @@ private function ensureDefaultsExtraFile()
194203
*/
195204
private function isMysqlDumpVersion8(): bool
196205
{
197-
if (!$this->mysqlDumpVersionIs8) {
206+
if (!$this->isMysqldumpVersion8) {
198207
$version = $this->_shell->execute(
199208
'mysqldump --version'
200209
);
201210

202-
$this->mysqlDumpVersionIs8 = (bool) preg_match('/8\.0\./', $version);
211+
$this->isMysqldumpVersion8 = (bool) preg_match('/8\.0\./', $version);
212+
}
213+
214+
return $this->isMysqldumpVersion8;
215+
}
216+
217+
/**
218+
* Is the DB connection Aurora RDS?
219+
*
220+
* @return bool
221+
*/
222+
private function isUsingAuroraDb(): bool
223+
{
224+
if (!isset($this->isUsingAuroraDb)) {
225+
try {
226+
$this->_shell->execute(
227+
'mysql --defaults-file=%s --host=%s --port=%s %s --execute="SELECT AURORA_VERSION()"',
228+
[
229+
$this->_defaultsExtraFile,
230+
$this->_host,
231+
$this->_port,
232+
$this->_schema
233+
]
234+
);
235+
236+
$this->isUsingAuroraDb = true;
237+
} catch (LocalizedException $e) {
238+
$this->isUsingAuroraDb = false;
239+
}
203240
}
204241

205-
return $this->mysqlDumpVersionIs8;
242+
return $this->isUsingAuroraDb;
206243
}
207244
}

0 commit comments

Comments
 (0)