Skip to content

Commit 70d75d8

Browse files
committed
AC-12085:: Optimized mariadb test code and added dry run fixture file with suffix mariadb10427
1 parent d265e4c commit 70d75d8

File tree

4 files changed

+67
-20
lines changed

4 files changed

+67
-20
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
// @codingStandardsIgnoreFile
9+
return ['CREATE TABLE `reference_table` (
10+
`tinyint_ref` tinyint NOT NULL AUTO_INCREMENT ,
11+
`tinyint_without_padding` tinyint NOT NULL DEFAULT 0 ,
12+
`bigint_without_padding` bigint NOT NULL DEFAULT 0 ,
13+
`smallint_without_padding` smallint NOT NULL DEFAULT 0 ,
14+
`integer_without_padding` int NOT NULL DEFAULT 0 ,
15+
`smallint_with_big_padding` smallint NOT NULL DEFAULT 0 ,
16+
`smallint_without_default` smallint NULL ,
17+
`int_without_unsigned` int NULL ,
18+
`int_unsigned` int UNSIGNED NULL ,
19+
`bigint_default_nullable` bigint UNSIGNED NULL DEFAULT 1 ,
20+
`bigint_not_default_not_nullable` bigint UNSIGNED NOT NULL ,
21+
CONSTRAINT PRIMARY KEY (`tinyint_ref`)
22+
) ENGINE=innodb DEFAULT CHARSET=utf8mb3 DEFAULT COLLATE=utf8mb3_general_ci
23+
24+
CREATE TABLE `auto_increment_test` (
25+
`int_auto_increment_with_nullable` int UNSIGNED NOT NULL AUTO_INCREMENT ,
26+
`int_disabled_auto_increment` smallint UNSIGNED NULL DEFAULT 0 ,
27+
CONSTRAINT `AUTO_INCREMENT_TEST_INT_AUTO_INCREMENT_WITH_NULLABLE` UNIQUE KEY (`int_auto_increment_with_nullable`)
28+
) ENGINE=innodb DEFAULT CHARSET=utf8mb3 DEFAULT COLLATE=utf8mb3_general_ci
29+
30+
CREATE TABLE `test_table` (
31+
`smallint` smallint NOT NULL AUTO_INCREMENT ,
32+
`tinyint` tinyint NULL ,
33+
`bigint` bigint NULL DEFAULT 0 ,
34+
`float` float(12, 4) NULL DEFAULT 0 ,
35+
`double` decimal(14, 6) NULL DEFAULT 11111111.111111 ,
36+
`decimal` decimal(15, 4) NULL DEFAULT 0 ,
37+
`date` date NULL ,
38+
`timestamp` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
39+
`datetime` datetime NULL DEFAULT 0 ,
40+
`longtext` longtext NULL ,
41+
`mediumtext` mediumtext NULL ,
42+
`varchar` varchar(254) NULL ,
43+
`char` char(255) NULL ,
44+
`mediumblob` mediumblob NULL ,
45+
`blob` blob NULL ,
46+
`boolean` BOOLEAN NULL ,
47+
CONSTRAINT `TEST_TABLE_SMALLINT_BIGINT` UNIQUE KEY (`smallint`,`bigint`),
48+
CONSTRAINT `TEST_TABLE_TINYINT_REFERENCE_TABLE_TINYINT_REF` FOREIGN KEY (`tinyint`) REFERENCES `reference_table` (`tinyint_ref`) ON DELETE NO ACTION,
49+
INDEX `TEST_TABLE_TINYINT_BIGINT` (`tinyint`,`bigint`)
50+
) ENGINE=innodb DEFAULT CHARSET=utf8mb3 DEFAULT COLLATE=utf8mb3_general_ci
51+
52+
CREATE TABLE `patch_list` (
53+
`patch_id` int NOT NULL AUTO_INCREMENT COMMENT "Patch Auto Increment",
54+
`patch_name` varchar(1024) NOT NULL COMMENT "Patch Class Name",
55+
CONSTRAINT PRIMARY KEY (`patch_id`)
56+
) ENGINE=innodb DEFAULT CHARSET=utf8mb3 DEFAULT COLLATE=utf8mb3_general_ci COMMENT="List of data/schema patches"
57+
58+
'];

dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/DataProviderFromFile.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ class DataProviderFromFile
3131
SqlVersionProvider::MARIA_DB_10_6_VERSION => 'mariadb106',
3232
SqlVersionProvider::MYSQL_8_0_29_VERSION => 'mysql829',
3333
SqlVersionProvider::MARIA_DB_10_4_27_VERSION => 'mariadb10427',
34-
SqlVersionProvider::MARIA_DB_10_6_11_VERSION => 'mariadb10611',
35-
SqlVersionProvider::MARIA_DB_11_4_VERSION=>'mariadb114',
34+
SqlVersionProvider::MARIA_DB_10_6_11_VERSION => 'mariadb10611'
3635
];
3736

3837
/**

dev/tests/setup-integration/framework/Magento/TestFramework/TestCase/SetupTestCase.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,8 @@ private function getDbKey(): string
109109
$this->dbKey = DataProviderFromFile::POSSIBLE_SUFFIXES[SqlVersionProvider::MYSQL_8_0_29_VERSION];
110110
break;
111111
} elseif ($this->sqlVersionProvider->isMariaDbEngine()) {
112-
$currentVersion = $this->sqlVersionProvider->getMariaDbVersion();
113-
if($currentVersion === SqlVersionProvider::MARIA_DB_10_4_VERSION){
114-
$key = DataProviderFromFile::POSSIBLE_SUFFIXES[SqlVersionProvider::MARIA_DB_10_4_27_VERSION];
115-
} elseif ( in_array( $currentVersion,
116-
[SqlVersionProvider::MARIA_DB_10_6_VERSION,
117-
SqlVersionProvider::MARIA_DB_11_4_VERSION] )){
118-
$key = DataProviderFromFile::POSSIBLE_SUFFIXES[SqlVersionProvider::MARIA_DB_10_6_11_VERSION];
119-
} elseif (strpos($this->getDatabaseVersion(), (string)$possibleVersion) !== false) {
120-
$key = $suffix;
121-
}
122-
$this->dbKey = $key;
112+
$suffixKey = $this->sqlVersionProvider->getMariaDbSuffixKey();
113+
$this->dbKey = DataProviderFromFile::POSSIBLE_SUFFIXES[$suffixKey];;
123114
break;
124115
} elseif (strpos($this->getDatabaseVersion(), (string)$possibleVersion) !== false) {
125116
$this->dbKey = $suffix;

lib/internal/Magento/Framework/DB/Adapter/SqlVersionProvider.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ class SqlVersionProvider
2323

2424
public const MYSQL_5_7_VERSION = '5.7.';
2525

26-
public const MARIA_DB_10_VERSION = '10.';
27-
2826
public const MARIA_DB_10_4_VERSION = '10.4.';
2927

3028
public const MARIA_DB_10_6_VERSION = '10.6.';
@@ -153,23 +151,24 @@ public function isMysqlGte8029(): bool
153151
* @return string
154152
* @throws ConnectionException
155153
*/
156-
public function getMariaDbVersion(): string
154+
public function getMariaDbSuffixKey(): string
157155
{
158156
$sqlVersion = $this->getSqlVersion();
157+
$defaultSuffixKey = SqlVersionProvider::MARIA_DB_10_6_11_VERSION;
159158
$isMariaDB104 = str_contains($sqlVersion, SqlVersionProvider::MARIA_DB_10_4_VERSION);
160159
$isMariaDB106 = str_contains($sqlVersion, SqlVersionProvider::MARIA_DB_10_6_VERSION);
161160
$isMariaDB114 = str_contains($sqlVersion, SqlVersionProvider::MARIA_DB_11_4_VERSION);
162161
$sqlExactVersion = $this->fetchSqlVersion(ResourceConnection::DEFAULT_CONNECTION);
163162
if (version_compare($sqlExactVersion, '10.4.27', '>=')) {
164163
if($isMariaDB104){
165-
return SqlVersionProvider::MARIA_DB_10_4_VERSION;
164+
return SqlVersionProvider::MARIA_DB_10_4_27_VERSION;
166165
} elseif ($isMariaDB106){
167-
return SqlVersionProvider::MARIA_DB_10_6_VERSION;
166+
return SqlVersionProvider::MARIA_DB_10_6_11_VERSION;
168167
} elseif ($isMariaDB114){
169-
return SqlVersionProvider::MARIA_DB_11_4_VERSION;
168+
return SqlVersionProvider::MARIA_DB_10_6_11_VERSION;
170169
}
171170
}
172-
return '';
171+
return $defaultSuffixKey;
173172
}
174173

175174
/**

0 commit comments

Comments
 (0)