Skip to content

Commit cd47596

Browse files
Merge branch 'develop' into 1.0-forward
2 parents 7527aa6 + 11eb2d9 commit cd47596

26 files changed

+914
-518
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44
/composer.phar
55
/composer.lock
66
/auth.json
7+
/codeception.yml
8+
/_workdir

.travis.yml

Lines changed: 61 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,68 @@ dist: xenial
33
git:
44
depth: false
55

6+
addons:
7+
hosts:
8+
- magento2.docker
9+
10+
services:
11+
- docker
12+
613
language: php
7-
php:
8-
- '7.0'
9-
- '7.1'
10-
- '7.2'
11-
- '7.3'
1214

13-
install: composer update
15+
stages:
16+
- static-unit
17+
- test
18+
19+
jobs:
20+
include:
21+
- stage: static-unit
22+
script: ./tests/travis/static-unit.sh;
23+
php: '7.0'
24+
env:
25+
- TEST_SUITE=static-unit
26+
- script: ./tests/travis/static-unit.sh;
27+
php: '7.1'
28+
env:
29+
- TEST_SUITE=static-unit
30+
- script: ./tests/travis/static-unit.sh;
31+
php: '7.2'
32+
env:
33+
- TEST_SUITE=static-unit
34+
- script: ./tests/travis/static-unit.sh;
35+
php: '7.3'
36+
env:
37+
- TEST_SUITE=static-unit
38+
- stage: test
39+
php: '7.1'
40+
env:
41+
- TEST_SUITE=functional-ee
42+
- php: '7.2'
43+
env:
44+
- TEST_SUITE=functional-ee
45+
- php: '7.3'
46+
env:
47+
- TEST_SUITE=functional-ee
48+
- php: '7.1'
49+
env:
50+
- TEST_SUITE=functional-ce
51+
- php: '7.2'
52+
env:
53+
- TEST_SUITE=functional-ce
54+
- php: '7.3'
55+
env:
56+
- TEST_SUITE=functional-ce
57+
58+
install:
59+
- composer config http-basic.repo.magento.com ${REPO_USERNAME_CE} ${REPO_PASSWORD_CE}
60+
- composer config github-oauth.github.com ${GITHUB_TOKEN}
61+
- if [ -n "${MCD_VERSION}" ] && [ $TRAVIS_PHP_VERSION != "7.0" ]; then composer config repositories.mcd git [email protected]:magento/magento-cloud-docker.git && composer require "magento/magento-cloud-docker:${MCD_VERSION}" --no-update; fi;
62+
- composer update -n --no-suggest
63+
64+
before_script:
65+
- sudo sysctl -w vm.max_map_count=262144
66+
- if [ $TEST_SUITE == "functional-ce" ]; then cp codeception.dist.yml codeception.yml && sed -i "s/REPO_USERNAME/REPO_USERNAME_CE/" codeception.yml && sed -i "s/REPO_PASSWORD/REPO_PASSWORD_CE/" codeception.yml; fi;
1467

1568
script:
16-
- ./vendor/bin/phpcs ./src --standard=./tests/static/phpcs-ruleset.xml -p -n
17-
- ./vendor/bin/phpmd ./src xml ./tests/static/phpmd-ruleset.xml
18-
- ./vendor/bin/phpunit --configuration ./tests/unit
69+
- if [ $TRAVIS_SECURE_ENV_VARS == "true" ] && [ $TEST_SUITE == "functional-ee" ]; then ./tests/travis/functional-ee.sh; fi;
70+
- if [ $TEST_SUITE == "functional-ce" ]; then ./tests/travis/functional-ce.sh; fi;

codeception.dist.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
paths:
2+
tests: src/Test/Functional
3+
output: tests/functional/_output
4+
data: tests/functional/_data
5+
support: vendor/magento/magento-cloud-docker/tests/functional/_support
6+
actor_suffix: Tester
7+
settings:
8+
colors: true
9+
extensions:
10+
enabled:
11+
- Codeception\Extension\RunFailed
12+
- Codeception\Extension\FailedInfo
13+
params:
14+
- vendor/magento/magento-cloud-docker/tests/functional/configuration.dist.yml
15+
- env
16+
modules:
17+
config:
18+
Magento\CloudDocker\Test\Functional\Codeception\TestInfrastructure:
19+
template_repo: "https://github.com/magento/magento-cloud.git"
20+
mcd_repo: "https://github.com/magento/magento-cloud-docker.git"
21+
mcc_repo: "https://github.com/magento/magento-cloud-components.git"
22+
mcp_repo: "https://github.com/magento/magento-cloud-patches.git"
23+
composer_magento_username: "%REPO_USERNAME%"
24+
composer_magento_password: "%REPO_PASSWORD%"
25+
composer_github_token: "%GITHUB_TOKEN%"
26+
printOutput: false
27+
Magento\CloudDocker\Test\Functional\Codeception\Docker:
28+
system_magento_dir: "%Magento.docker.settings.system.magento_dir%"
29+
printOutput: false
30+
PhpBrowser:
31+
url: "%Magento.docker.settings.env.url.base%"
32+
Magento\CloudDocker\Test\Functional\Codeception\MagentoDb:
33+
dsn: "mysql:host=%Magento.docker.settings.db.host%;port=%Magento.docker.settings.db.port%;dbname=%Magento.docker.settings.db.path%"
34+
user: "%Magento.docker.settings.db.username%"
35+
password: "%Magento.docker.settings.db.password%"
36+
exposed_port: "%Magento.docker.settings.db.port%"
37+
reconnect: true

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
"symfony/process": "^2.1||^4.1"
1616
},
1717
"require-dev": {
18+
"codeception/codeception": "^2.5.3",
19+
"consolidation/robo": "^1.2",
1820
"phpmd/phpmd": "@stable",
1921
"phpunit/phpunit": "^6.2",
2022
"squizlabs/php_codesniffer": "^3.0"
@@ -24,7 +26,8 @@
2426
],
2527
"autoload": {
2628
"psr-4": {
27-
"Magento\\CloudPatches\\": "src/"
29+
"Magento\\CloudPatches\\": "src/",
30+
"Magento\\CloudPatches\\Test\\Functional\\": "tests/functional/"
2831
}
2932
},
3033
"scripts": {

patches.json

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,19 +107,14 @@
107107
"Unlock locale editing when SCD on demand is enabled": {
108108
"2.2.0 - 2.2.5": "MAGECLOUD-2159__unlock_locale_editing_when_scd_on_demand__2.2.0.patch"
109109
},
110-
"Allow DB dumps done with the support module to complete": {
111-
"2.2.0 - 2.2.5": "MAGECLOUD-2033__prevent_deadlock_during_db_dump__2.2.0.patch"
112-
},
113110
"Write Logs for Failed Process of Generating Factories in Extensions": {
114111
"2.2.0 - 2.2.5": "MAGECLOUD-2209__write_logs_for_failed_process_of_generating_factories_in_extensions__2.2.0.patch"
115112
},
116113
"Fix Problems with Consumer Runners on Cloud Clusters": {
117-
"2.2.0 - 2.2.3": "MAGECLOUD-2464__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.0.patch",
118-
"2.2.4": "MAGECLOUD-2464__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.4.patch",
119-
"2.2.5": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.5.patch",
120-
"2.2.6": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.6.patch",
121-
"2.2.7": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.7.patch",
122-
"2.2.8 - 2.2.9": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.8.patch",
114+
"2.2.5": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.5_ce.patch",
115+
"2.2.6": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.6_ce.patch",
116+
"2.2.7": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.7_ce.patch",
117+
"2.2.8 - 2.2.9": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.8_ce.patch",
123118
"2.3.0": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.3.0.patch",
124119
">=2.3.1 <2.3.3": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.3.1.patch"
125120
},
@@ -186,7 +181,6 @@
186181
">=2.3.0 <2.3.3": "MAGECLOUD-3806__error_code_fix_for_setup_upgrade__2.3.0.patch"
187182
},
188183
"Re-work consumers to terminate as soon as there is nothing left to process": {
189-
"2.2.0 - 2.3.1": "MAGECLOUD-4071__terminate_consumers_if_the_queue_is_empty__2.2.0.patch",
190184
">=2.3.2 <2.3.4": "MAGECLOUD-4071__terminate_consumers_if_the_queue_is_empty__2.3.2.patch"
191185
},
192186
"Backward Compatibility of new Mail Interfaces": {
@@ -303,6 +297,20 @@
303297
"2.3.2": "PB-320__fix_pagebuilder_module__2.3.2.patch",
304298
">=2.3.2-p1 <2.3.3": "PB-322__fix_pagebuilder_module__2.3.2-p1.patch",
305299
"2.3.3": "PB-323__fix_pagebuilder_module__2.3.3.patch"
300+
},
301+
"Allow DB dumps done with the support module to complete": {
302+
"2.2.0 - 2.2.5": "MAGECLOUD-2033__prevent_deadlock_during_db_dump__2.2.0.patch"
303+
},
304+
"Fix Problems with Consumer Runners on Cloud Clusters": {
305+
"2.2.0 - 2.2.3": "MAGECLOUD-2464__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.0.patch",
306+
"2.2.4": "MAGECLOUD-2464__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.4.patch",
307+
"2.2.5": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.5_ee.patch",
308+
"2.2.6": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.6_ee.patch",
309+
"2.2.7": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.7_ee.patch",
310+
"2.2.8 - 2.2.9": "MAGECLOUD-3913__fix_problems_with_consumer_runners_on_cloud_clusters__2.2.8_ee.patch"
311+
},
312+
"Re-work consumers to terminate as soon as there is nothing left to process": {
313+
">=2.2.0 <2.3.2": "MAGECLOUD-4071__terminate_consumers_if_the_queue_is_empty__2.2.0.patch"
306314
}
307315
}
308316
}
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
diff -Nuar a/vendor/magento/framework/Lock/Backend/Database.php b/vendor/magento/framework/Lock/Backend/Database.php
2+
--- a/vendor/magento/framework/Lock/Backend/Database.php
3+
+++ b/vendor/magento/framework/Lock/Backend/Database.php
4+
@@ -3,8 +3,8 @@
5+
* Copyright © Magento, Inc. All rights reserved.
6+
* See COPYING.txt for license details.
7+
*/
8+
-
9+
declare(strict_types=1);
10+
+
11+
namespace Magento\Framework\Lock\Backend;
12+
13+
use Magento\Framework\App\DeploymentConfig;
14+
@@ -14,20 +14,44 @@ use Magento\Framework\Exception\AlreadyExistsException;
15+
use Magento\Framework\Exception\InputException;
16+
use Magento\Framework\Phrase;
17+
18+
+/**
19+
+ * Implementation of the lock manager on the basis of MySQL.
20+
+ */
21+
class Database implements \Magento\Framework\Lock\LockManagerInterface
22+
{
23+
- /** @var ResourceConnection */
24+
+ /**
25+
+ * Max time for lock is 1 week
26+
+ *
27+
+ * MariaDB does not support negative timeout value to get infinite timeout,
28+
+ * so we set 1 week for lock timeout
29+
+ */
30+
+ const MAX_LOCK_TIME = 604800;
31+
+
32+
+ /**
33+
+ * @var ResourceConnection
34+
+ */
35+
private $resource;
36+
37+
- /** @var DeploymentConfig */
38+
+ /**
39+
+ * @var DeploymentConfig
40+
+ */
41+
private $deploymentConfig;
42+
43+
- /** @var string Lock prefix */
44+
+ /**
45+
+ * @var string Lock prefix
46+
+ */
47+
private $prefix;
48+
49+
- /** @var string|false Holds current lock name if set, otherwise false */
50+
+ /**
51+
+ * @var string|false Holds current lock name if set, otherwise false
52+
+ */
53+
private $currentLock = false;
54+
55+
+ /**
56+
+ * @param ResourceConnection $resource
57+
+ * @param DeploymentConfig $deploymentConfig
58+
+ * @param string|null $prefix
59+
+ */
60+
public function __construct(
61+
ResourceConnection $resource,
62+
DeploymentConfig $deploymentConfig,
63+
@@ -46,9 +70,13 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface
64+
* @return bool
65+
* @throws InputException
66+
* @throws AlreadyExistsException
67+
+ * @throws \Zend_Db_Statement_Exception
68+
*/
69+
public function lock(string $name, int $timeout = -1): bool
70+
{
71+
+ if (!$this->deploymentConfig->isDbAvailable()) {
72+
+ return true;
73+
+ };
74+
$name = $this->addPrefix($name);
75+
76+
/**
77+
@@ -59,7 +87,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface
78+
if ($this->currentLock) {
79+
throw new AlreadyExistsException(
80+
new Phrase(
81+
- 'Current connection is already holding lock for $1, only single lock allowed',
82+
+ 'Current connection is already holding lock for %1, only single lock allowed',
83+
[$this->currentLock]
84+
)
85+
);
86+
@@ -67,7 +95,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface
87+
88+
$result = (bool)$this->resource->getConnection()->query(
89+
"SELECT GET_LOCK(?, ?);",
90+
- [(string)$name, (int)$timeout]
91+
+ [$name, $timeout < 0 ? self::MAX_LOCK_TIME : $timeout]
92+
)->fetchColumn();
93+
94+
if ($result === true) {
95+
@@ -83,9 +111,14 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface
96+
* @param string $name lock name
97+
* @return bool
98+
* @throws InputException
99+
+ * @throws \Zend_Db_Statement_Exception
100+
*/
101+
public function unlock(string $name): bool
102+
{
103+
+ if (!$this->deploymentConfig->isDbAvailable()) {
104+
+ return true;
105+
+ };
106+
+
107+
$name = $this->addPrefix($name);
108+
109+
$result = (bool)$this->resource->getConnection()->query(
110+
@@ -106,14 +139,19 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface
111+
* @param string $name lock name
112+
* @return bool
113+
* @throws InputException
114+
+ * @throws \Zend_Db_Statement_Exception
115+
*/
116+
public function isLocked(string $name): bool
117+
{
118+
+ if (!$this->deploymentConfig->isDbAvailable()) {
119+
+ return false;
120+
+ };
121+
+
122+
$name = $this->addPrefix($name);
123+
124+
return (bool)$this->resource->getConnection()->query(
125+
"SELECT IS_USED_LOCK(?);",
126+
- [(string)$name]
127+
+ [$name]
128+
)->fetchColumn();
129+
}
130+
131+
@@ -123,7 +161,7 @@ class Database implements \Magento\Framework\Lock\LockManagerInterface
132+
* Limited to 64 characters in MySQL.
133+
*
134+
* @param string $name
135+
- * @return string $name
136+
+ * @return string
137+
* @throws InputException
138+
*/
139+
private function addPrefix(string $name): string

0 commit comments

Comments
 (0)