Skip to content

Commit a19181f

Browse files
Merge pull request #174 from magento-commerce/MCLOUD-13310
MCLOUD-13310 Prepare functional tests
2 parents b5d20b3 + 229ada3 commit a19181f

17 files changed

+661
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
namespace Magento\MagentoCloud\Test\Functional\Acceptance;
9+
10+
use CliTester;
11+
use Robo\Exception\TaskException;
12+
use Codeception\Example;
13+
use Magento\CloudDocker\Test\Functional\Codeception\Docker;
14+
15+
/**
16+
* This test runs on the latest version of PHP
17+
*
18+
* 1. Test successful deploy
19+
* 2. Test content presence
20+
* 3. Test config dump
21+
* 4. Test content presence
22+
*
23+
* @group php84
24+
*/
25+
class Acceptance84Cest extends AcceptanceCest
26+
{
27+
/**
28+
* @var string
29+
*/
30+
protected $magentoCloudTemplate = '2.4.8';
31+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
namespace Magento\MagentoCloud\Test\Functional\Acceptance;
9+
10+
/**
11+
* This test runs on the latest version of PHP
12+
* @group php84
13+
*/
14+
class AdminCredential84Cest extends AdminCredentialCest
15+
{
16+
/**
17+
* @var string
18+
*/
19+
protected $magentoCloudTemplate = '2.4.8';
20+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
namespace Magento\MagentoCloud\Test\Functional\Acceptance;
9+
10+
/**
11+
* Checks database backup functionality
12+
* @group php84
13+
*/
14+
class BackupDb84Cest extends BackupDbCest
15+
{
16+
/**
17+
* @return array
18+
*/
19+
protected function dataProviderMagentoCloudVersions(): array
20+
{
21+
return [
22+
['version' => '2.4.8'],
23+
];
24+
}
25+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
namespace Magento\MagentoCloud\Test\Functional\Acceptance;
9+
10+
/**
11+
* @group php84
12+
*/
13+
class Cron84Cest extends CronCest
14+
{
15+
/**
16+
* @return array
17+
*/
18+
protected function cronDataProvider(): array
19+
{
20+
return [
21+
[
22+
'version' => '2.4.8',
23+
'variables' => [
24+
'MAGENTO_CLOUD_VARIABLES' => [
25+
'ADMIN_EMAIL' => 'admin@example.com',
26+
'ADMIN_LOCALE' => 'fr_FR'
27+
],
28+
],
29+
],
30+
];
31+
}
32+
}
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
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+
namespace Magento\MagentoCloud\Test\Functional\Acceptance;
9+
10+
/**
11+
* Test for cron:unlock.
12+
*
13+
* @group php84
14+
*/
15+
class CronUnlock84Cest extends CronUnlockCest
16+
{
17+
/**
18+
* @var string
19+
*/
20+
protected $magentoCloudTemplate = '2.4.8';
21+
22+
/**
23+
* @param \CliTester $I
24+
* @throws \Robo\Exception\TaskException
25+
*/
26+
public function testCronUnlock(\CliTester $I): void
27+
{
28+
$I->generateDockerCompose(sprintf('--mode=production --expose-db-port=%s', $I->getExposedPort()));
29+
$I->runDockerComposeCommand('run build cloud-build');
30+
$I->startEnvironment();
31+
$I->runDockerComposeCommand('run deploy cloud-deploy');
32+
33+
$sampleData = $this->getSampleData();
34+
$scheduleIds = [];
35+
36+
foreach ($sampleData as $row) {
37+
$scheduleIds[] = $I->haveInDatabase('cron_schedule', $row);
38+
}
39+
$I->seeInDatabase('cron_schedule', ['status' => 'pending']);
40+
41+
foreach (array_slice($scheduleIds, 0, 3) as $scheduleId) {
42+
$this->updateScheduleInDb($I, $scheduleId, 'running');
43+
}
44+
$I->seeInDatabase('cron_schedule', ['status' => 'running']);
45+
46+
$I->assertTrue($I->runDockerComposeCommand('run deploy ece-command cron:unlock'));
47+
$I->seeInDatabase('cron_schedule', ['status' => 'error']);
48+
foreach (array_slice($scheduleIds, 0, 3) as $scheduleId) {
49+
$I->seeInDatabase('cron_schedule', ['schedule_id' => $scheduleId, 'status' => 'error']);
50+
}
51+
52+
foreach (array_slice($scheduleIds, 3, 3) as $scheduleId) {
53+
$this->updateScheduleInDb($I, $scheduleId, 'running');
54+
}
55+
$I->seeInDatabase('cron_schedule', ['status' => 'running']);
56+
57+
$I->assertTrue(
58+
$I->runDockerComposeCommand(
59+
sprintf(
60+
'run deploy ece-command cron:unlock --job-code=%s --job-code=%s',
61+
'catalog_product_frontend_actions_flush',
62+
'catalog_product_outdated_price_values_cleanup'
63+
)
64+
)
65+
);
66+
67+
$I->seeInDatabase('cron_schedule', ['schedule_id' => $scheduleIds[3], 'status' => 'error']);
68+
$I->seeInDatabase('cron_schedule', ['schedule_id' => $scheduleIds[4], 'status' => 'error']);
69+
$I->seeInDatabase('cron_schedule', ['schedule_id' => $scheduleIds[5], 'status' => 'running']);
70+
}
71+
72+
/**
73+
* @param \CLITester $I
74+
* @param $scheduleId
75+
* @param $status
76+
*/
77+
private function updateScheduleInDb(\CLITester $I, $scheduleId, $status): void
78+
{
79+
$I->updateInDatabase(
80+
'cron_schedule',
81+
[
82+
'status' => $status
83+
],
84+
[
85+
'schedule_id' => $scheduleId
86+
]
87+
);
88+
}
89+
90+
/**
91+
* @return array
92+
*/
93+
protected function getSampleData() : array
94+
{
95+
return [
96+
[
97+
'job_code' => 'update_last_visit_at',
98+
'status' => 'pending',
99+
'scheduled_at' => date('Y-m-d h:i:s', strtotime('+1 hours'))
100+
],
101+
[
102+
'job_code' => 'catalog_product_outdated_price_values_cleanup',
103+
'status' => 'pending',
104+
'scheduled_at' => date('Y-m-d h:i:s', strtotime('+2 hours'))
105+
],
106+
[
107+
'job_code' => 'sales_grid_order_async_insert',
108+
'status' => 'pending',
109+
'scheduled_at' => date('Y-m-d h:i:s', strtotime('+3 hours'))
110+
],
111+
[
112+
'job_code' => 'catalog_product_frontend_actions_flush',
113+
'status' => 'pending',
114+
'scheduled_at' => date('Y-m-d h:i:s', strtotime('+4 hours'))
115+
],
116+
[
117+
'job_code' => 'catalog_product_outdated_price_values_cleanup',
118+
'status' => 'pending',
119+
'scheduled_at' => date('Y-m-d h:i:s', strtotime('+5 hours'))
120+
],
121+
[
122+
'job_code' => 'sales_grid_order_async_insert',
123+
'status' => 'pending',
124+
'scheduled_at' => date('Y-m-d h:i:s', strtotime('+6 hours'))
125+
]
126+
];
127+
}
128+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
namespace Magento\MagentoCloud\Test\Functional\Acceptance;
9+
10+
/**
11+
* This test runs on the latest version of PHP
12+
*
13+
* @group php84
14+
*/
15+
class DataTypesOptionValidation84Cest extends DataTypesOptionValidationCest
16+
{
17+
/**
18+
* @var string
19+
*/
20+
protected $magentoCloudTemplate = '2.4.8';
21+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
namespace Magento\MagentoCloud\Test\Functional\Acceptance;
9+
10+
use Magento\CloudDocker\Test\Functional\Codeception\Docker;
11+
12+
/**
13+
* This test runs on the latest version of PHP
14+
*
15+
* @group php84
16+
*/
17+
class DatabaseConfiguration84Cest extends DatabaseConfigurationCest
18+
{
19+
/**
20+
* @var string
21+
*/
22+
protected $magentoCloudTemplate = '2.4.8';
23+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
namespace Magento\MagentoCloud\Test\Functional\Acceptance;
9+
10+
use Magento\MagentoCloud\App\Error;
11+
12+
/**
13+
* This test cover functionality of state-aware error codes.
14+
* Checks that failed scenario returns correct error code different to 1 or 255.
15+
* Checks that var/log/cloud.error.log file was created and contains correct data.
16+
* Checks that `ece-tools error:show` command returns correct errors info
17+
*
18+
* @group php84
19+
*/
20+
class ErrorCodes84Cest extends ErrorCodesCest
21+
{
22+
/**
23+
* @var string
24+
*/
25+
protected $magentoCloudTemplate = '2.4.8';
26+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
namespace Magento\MagentoCloud\Test\Functional\Acceptance;
9+
10+
use CliTester;
11+
12+
/**
13+
* This test runs on the latest version of PHP
14+
*
15+
* @group php84
16+
*/
17+
class ErrorMessage84Cest extends ErrorMessageCest
18+
{
19+
/**
20+
* @var string
21+
*/
22+
protected $magentoCloudTemplate = '2.4.8';
23+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
namespace Magento\MagentoCloud\Test\Functional\Acceptance;
9+
10+
/**
11+
* This test runs on the latest version of PHP
12+
*
13+
* @group php84
14+
*/
15+
class PostDeploy84Cest extends PostDeployCest
16+
{
17+
/**
18+
* @var string
19+
*/
20+
protected $magentoCloudTemplate = '2.4.8';
21+
}

0 commit comments

Comments
 (0)