Skip to content

Commit ee0548e

Browse files
authored
Merge pull request #581 from magento-performance/ACPT-1688_2
ACPT-1688: Fix Static Tests failures on Application-Server branch
2 parents 3cf454d + dca3621 commit ee0548e

File tree

14 files changed

+65
-47
lines changed

14 files changed

+65
-47
lines changed

app/code/Magento/ApplicationPerformanceMonitor/Profiler/MetricType.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
*/
1313
class MetricType
1414
{
15-
public const Other = "Other";
16-
public const SecondsElapsedFloat = "SecondsElapsedFloat";
17-
public const UnixTimestampFloat = "UnixTimestampFloat";
18-
public const MemorySizeInt = "MemorySizeInt";
15+
public const OTHER = "Other";
16+
public const SECONDS_ELAPSED_FLOAT = "SecondsElapsedFloat";
17+
public const UNIX_TIMESTAMP_FLOAT = "UnixTimestampFloat";
18+
public const MEMORY_SIZE_INT = "MemorySizeInt";
1919
}

app/code/Magento/ApplicationPerformanceMonitor/Profiler/MetricsComparator.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,103 +32,103 @@ public function compareMetrics(Metrics $beforeMetrics, Metrics $afterMetrics, ?M
3232
{
3333
$metrics = [];
3434
$metrics['memoryUsageBefore'] = $this->metricFactory->create([
35-
'type' => MetricType::MemorySizeInt,
35+
'type' => MetricType::MEMORY_SIZE_INT,
3636
'name' => 'memoryUsageBefore',
3737
'value' => $beforeMetrics->getMemoryUsage(),
3838
'verbose' => true,
3939
]);
4040
$metrics['memoryUsageAfter'] = $this->metricFactory->create([
41-
'type' => MetricType::MemorySizeInt,
41+
'type' => MetricType::MEMORY_SIZE_INT,
4242
'name' => 'memoryUsageAfter',
4343
'value' => $afterMetrics->getMemoryUsage(),
4444
'verbose' => false,
4545
]);
4646
if ($previousAfterMetrics) {
4747
$metrics['memoryUsageAfterComparedToPrevious'] = $this->metricFactory->create([
48-
'type' => MetricType::MemorySizeInt,
48+
'type' => MetricType::MEMORY_SIZE_INT,
4949
'name' => 'memoryUsageAfterComparedToPrevious',
5050
'value' => $afterMetrics->getMemoryUsage() - $previousAfterMetrics->getMemoryUsage(),
5151
'verbose' => false,
5252
]);
5353
}
5454
$metrics['memoryUsageDelta'] = $this->metricFactory->create([
55-
'type' => MetricType::MemorySizeInt,
55+
'type' => MetricType::MEMORY_SIZE_INT,
5656
'name' => 'memoryUsageDelta',
5757
'value' => $afterMetrics->getMemoryUsage() - $beforeMetrics->getMemoryUsage(),
5858
'verbose' => false,
5959
]);
6060
$metrics['peakMemoryUsageBefore'] = $this->metricFactory->create([
61-
'type' => MetricType::MemorySizeInt,
61+
'type' => MetricType::MEMORY_SIZE_INT,
6262
'name' => 'peakMemoryUsageBefore',
6363
'value' => $beforeMetrics->getPeakMemoryUsage(),
6464
'verbose' => true,
6565
]);
6666
$metrics['peakMemoryUsageAfter'] = $this->metricFactory->create([
67-
'type' => MetricType::MemorySizeInt,
67+
'type' => MetricType::MEMORY_SIZE_INT,
6868
'name' => 'peakMemoryUsageAfter',
6969
'value' => $afterMetrics->getPeakMemoryUsage(),
7070
'verbose' => false,
7171
]);
7272
$metrics['peakMemoryUsageDelta'] = $this->metricFactory->create([
73-
'type' => MetricType::MemorySizeInt,
73+
'type' => MetricType::MEMORY_SIZE_INT,
7474
'name' => 'peakMemoryUsageDelta',
7575
'value' => $afterMetrics->getPeakMemoryUsage() - $beforeMetrics->getPeakMemoryUsage(),
7676
'verbose' => false,
7777
]);
7878
$metrics['wallTimeBefore'] = $this->metricFactory->create([
79-
'type' => MetricType::UnixTimestampFloat,
79+
'type' => MetricType::UNIX_TIMESTAMP_FLOAT,
8080
'name' => 'wallTimeBefore',
8181
'value' => $beforeMetrics->getMicrotime(),
8282
'verbose' => true,
8383
]);
8484
$metrics['wallTimeAfter'] = $this->metricFactory->create([
85-
'type' => MetricType::UnixTimestampFloat,
85+
'type' => MetricType::UNIX_TIMESTAMP_FLOAT,
8686
'name' => 'wallTimeAfter',
8787
'value' => $afterMetrics->getMicrotime(),
8888
'verbose' => true,
8989
]);
9090
$metrics['wallTimeElapsed'] = $this->metricFactory->create([
91-
'type' => MetricType::SecondsElapsedFloat,
91+
'type' => MetricType::SECONDS_ELAPSED_FLOAT,
9292
'name' => 'wallTimeElapsed',
9393
'value' => $afterMetrics->getMicrotime() - $beforeMetrics->getMicrotime(),
9494
'verbose' => false,
9595
]);
9696
$metrics['userTimeBefore'] = $this->metricFactory->create([
97-
'type' => MetricType::SecondsElapsedFloat,
97+
'type' => MetricType::SECONDS_ELAPSED_FLOAT,
9898
'name' => 'userTimeBefore',
9999
'value' => $beforeMetrics->getRusage()['ru_utime.tv_sec']
100100
+ 0.000001 * $beforeMetrics->getRusage()['ru_utime.tv_usec'],
101101
'verbose' => true,
102102
]);
103103
$metrics['userTimeAfter'] = $this->metricFactory->create([
104-
'type' => MetricType::SecondsElapsedFloat,
104+
'type' => MetricType::SECONDS_ELAPSED_FLOAT,
105105
'name' => 'userTimeAfter',
106106
'value' => $afterMetrics->getRusage()['ru_utime.tv_sec']
107107
+ 0.000001 * $afterMetrics->getRusage()['ru_utime.tv_usec'],
108108
'verbose' => true,
109109
]);
110110
$metrics['userTimeElapsed'] = $this->metricFactory->create([
111-
'type' => MetricType::SecondsElapsedFloat,
111+
'type' => MetricType::SECONDS_ELAPSED_FLOAT,
112112
'name' => 'userTimeElapsed',
113113
'value' => $metrics['userTimeAfter']->getValue() - $metrics['userTimeBefore']->getValue(),
114114
'verbose' => true,
115115
]);
116116
$metrics['systemTimeBefore'] = $this->metricFactory->create([
117-
'type' => MetricType::SecondsElapsedFloat,
117+
'type' => MetricType::SECONDS_ELAPSED_FLOAT,
118118
'name' => 'systemTimeBefore',
119119
'value' => $beforeMetrics->getRusage()['ru_stime.tv_sec']
120120
+ 0.000001 * $beforeMetrics->getRusage()['ru_stime.tv_usec'],
121121
'verbose' => true,
122122
]);
123123
$metrics['systemTimeAfter'] = $this->metricFactory->create([
124-
'type' => MetricType::SecondsElapsedFloat,
124+
'type' => MetricType::SECONDS_ELAPSED_FLOAT,
125125
'name' => 'systemTimeAfter',
126126
'value' => $afterMetrics->getRusage()['ru_stime.tv_sec']
127127
+ 0.000001 * $afterMetrics->getRusage()['ru_stime.tv_usec'],
128128
'verbose' => true,
129129
]);
130130
$metrics['systemTimeElapsed'] = $this->metricFactory->create([
131-
'type' => MetricType::SecondsElapsedFloat,
131+
'type' => MetricType::SECONDS_ELAPSED_FLOAT,
132132
'name' => 'systemTimeElapsed',
133133
'value' => $metrics['systemTimeAfter']->getValue() - $metrics['systemTimeBefore']->getValue(),
134134
'verbose' => true,

app/code/Magento/ApplicationPerformanceMonitor/Profiler/Output/LoggerOutput.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,13 @@ private function doOutputMetrics(array $metrics, bool $verbose)
8989
continue;
9090
}
9191
switch ($metric->getType()) {
92-
case MetricType::SecondsElapsedFloat:
92+
case MetricType::SECONDS_ELAPSED_FLOAT:
9393
$prettyMetrics[$metric->getName()] = $this->prettyElapsedTime($metric->getValue());
9494
break;
95-
case MetricType::UnixTimestampFloat:
95+
case MetricType::UNIX_TIMESTAMP_FLOAT:
9696
$prettyMetrics[$metric->getName()] = $this->prettyUnixTime($metric->getValue());
9797
break;
98-
case MetricType::MemorySizeInt:
98+
case MetricType::MEMORY_SIZE_INT:
9999
$prettyMetrics[$metric->getName()] = $this->prettyMemorySize($metric->getValue());
100100
break;
101101
default:

app/code/Magento/CatalogGraphQl/DataProvider/Product/RequestDataBuilder.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\CatalogGraphQl\DataProvider\Product;
79

810
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;

dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ResolverCache/MediaGalleryTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,7 @@ public function testCacheIsInvalidatedOnProductDeletion()
587587
* @param ProductInterface $product
588588
* @return void
589589
* @throws \Zend_Cache_Exception
590+
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
590591
*/
591592
private function assertCacheIdIsNotOrphanedInTagsForProduct(ProductInterface $product)
592593
{

dev/tests/integration/framework/Magento/TestFramework/ApplicationStateComparator/_files/state-skip-list.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
/* These classes are skipped completely during comparison. */
99
return [
1010
'*' => [
11+
// phpcs:disable Generic.Files.LineLength.TooLong
1112
// list of the latest failures started
1213
Magento\Sales\Api\Data\ShippingAssignmentInterfaceFactory::class => null,
1314
Magento\Sales\Model\Order\ShippingBuilderFactory::class => null,
@@ -358,8 +359,10 @@
358359
'QuoteRelationsComposite' => null,
359360
Magento\GraphQlCache\Model\Plugin\Auth\TokenIssuer::class => null,
360361
Magento\StoreGraphQl\Plugin\LocalizeEmail::class => null,
362+
// phpcs:enable Generic.Files.LineLength.TooLong
361363
],
362364
'*-fromConstructed' => [
365+
// phpcs:disable Generic.Files.LineLength.TooLong
363366
Magento\Sales\Model\ResourceModel\Grid::class => null,
364367
Magento\Sales\Model\ResourceModel\GridPool::class => null,
365368
Magento\Sales\Api\Data\OrderExtension::class => null,
@@ -714,6 +717,7 @@
714717
Magento\Staging\Model\Update\Flag::class => null,
715718
Magento\Catalog\Model\Category\Attribute\Source\Sortby::class => null,
716719
Magento\Config\App\Config\Source\EnvironmentConfigSource::class => null,
720+
// phpcs:enable Generic.Files.LineLength.TooLong
717721
],
718722
'' => [
719723
],

dev/tests/integration/testsuite/Magento/Framework/ObjectManager/ResetAfterRequestTest.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,15 @@ public function testResetAfterRequestClasses(string $className)
167167
}
168168
try {
169169
/** @var ResetAfterRequestInterface $object */
170-
$beforeProperties = $this->collector->getPropertiesFromObject($object, CompareType::CompareBetweenRequests);
170+
$beforeProperties = $this->collector->getPropertiesFromObject(
171+
$object,
172+
CompareType::COMPARE_BETWEEN_REQUESTS
173+
);
171174
$object->_resetState();
172-
$afterProperties = $this->collector->getPropertiesFromObject($object, CompareType::CompareBetweenRequests);
175+
$afterProperties = $this->collector->getPropertiesFromObject(
176+
$object,
177+
CompareType::COMPARE_BETWEEN_REQUESTS
178+
);
173179
$differences = [];
174180
foreach ($afterProperties as $propertyName => $propertyValue) {
175181
if ($propertyValue instanceof ObjectManagerInterface) {
@@ -193,7 +199,11 @@ public function testResetAfterRequestClasses(string $className)
193199
// TODO: Can we convert _regionModels to member variable,
194200
// or move to a dependency injected service class instead?
195201
}
196-
$result = $this->comparator->checkValues($beforeProperties[$propertyName] ?? null, $propertyValue, 3);
202+
$result = $this->comparator->checkValues(
203+
$beforeProperties[$propertyName] ?? null,
204+
$propertyValue,
205+
3
206+
);
197207
if ($result) {
198208
$differences[$propertyName] = $result;
199209
}

lib/internal/Magento/Framework/TestFramework/ApplicationStateComparator/Collector.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ public function __construct(
3333
SkipListAndFilterList $skipListAndFilterList
3434
) {
3535
$this->skipListFromConstructed =
36-
$skipListAndFilterList->getSkipList('', CompareType::CompareConstructedAgainstCurrent);
37-
$this->skipListBetweenRequests = $skipListAndFilterList->getSkipList('', CompareType::CompareBetweenRequests);
36+
$skipListAndFilterList->getSkipList('', CompareType::COMPARE_CONSTRUCTED_AGAINST_CURRENT);
37+
$this->skipListBetweenRequests = $skipListAndFilterList->getSkipList('', CompareType::COMPARE_BETWEEN_REQUESTS);
3838
}
3939

4040
/**
@@ -109,15 +109,15 @@ public function getSharedObjects(string $shouldResetState): array
109109
if (array_key_exists($serviceName, $sharedObjects)) {
110110
continue;
111111
}
112-
if (ShouldResetState::DoResetState == $shouldResetState &&
112+
if (ShouldResetState::DO_RESET_STATE == $shouldResetState &&
113113
($object instanceof ResetAfterRequestInterface)) {
114114
$object->_resetState();
115115
}
116116
if ($object instanceof \Magento\Framework\ObjectManagerInterface) {
117117
continue;
118118
}
119119
$sharedObjects[$serviceName] =
120-
$this->getPropertiesFromObject($object, CompareType::CompareBetweenRequests);
120+
$this->getPropertiesFromObject($object, CompareType::COMPARE_BETWEEN_REQUESTS);
121121
}
122122
return $sharedObjects;
123123
}
@@ -145,7 +145,7 @@ public function getPropertiesConstructedAndCurrent(): array
145145
$objects[] = new CollectedObjectConstructedAndCurrent(
146146
$object,
147147
$propertiesBefore,
148-
$this->getPropertiesFromObject($object, CompareType::CompareConstructedAgainstCurrent),
148+
$this->getPropertiesFromObject($object, CompareType::COMPARE_CONSTRUCTED_AGAINST_CURRENT),
149149
);
150150
}
151151
return $objects;
@@ -167,7 +167,7 @@ public function getPropertiesFromObject(
167167
int $recursionLevel = 0,
168168
): CollectedObject {
169169
$className = get_class($object);
170-
$skipList = $compareType == CompareType::CompareBetweenRequests ?
170+
$skipList = $compareType == CompareType::COMPARE_BETWEEN_REQUESTS ?
171171
$this->skipListBetweenRequests : $this->skipListFromConstructed ;
172172
if (array_key_exists($className, $skipList)) {
173173
return CollectedObject::getSkippedObject();

lib/internal/Magento/Framework/TestFramework/ApplicationStateComparator/Comparator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function __construct(
4141
public function rememberObjectsStateBefore(bool $firstRequest): void
4242
{
4343
if ($firstRequest) {
44-
$this->objectsStateBefore = $this->collector->getSharedObjects(ShouldResetState::DoNotResetState);
44+
$this->objectsStateBefore = $this->collector->getSharedObjects(ShouldResetState::DO_NOT_RESET_STATE);
4545
}
4646
}
4747

@@ -53,7 +53,7 @@ public function rememberObjectsStateBefore(bool $firstRequest): void
5353
*/
5454
public function rememberObjectsStateAfter(bool $firstRequest): void
5555
{
56-
$this->objectsStateAfter = $this->collector->getSharedObjects(ShouldResetState::DoResetState);
56+
$this->objectsStateAfter = $this->collector->getSharedObjects(ShouldResetState::DO_RESET_STATE);
5757
if ($firstRequest) {
5858
// on the end of first request add objects to init object state pool
5959
$this->objectsStateBefore = array_merge($this->objectsStateAfter, $this->objectsStateBefore);
@@ -71,7 +71,7 @@ public function rememberObjectsStateAfter(bool $firstRequest): void
7171
public function compareBetweenRequests(string $operationName): array
7272
{
7373
$compareResults = [];
74-
$skipList = $this->skipListAndFilterList->getSkipList($operationName, CompareType::CompareBetweenRequests);
74+
$skipList = $this->skipListAndFilterList->getSkipList($operationName, CompareType::COMPARE_BETWEEN_REQUESTS);
7575
foreach ($this->objectsStateAfter as $serviceName => $afterCollectedObject) {
7676
if (array_key_exists($serviceName, $skipList)) {
7777
continue;
@@ -101,7 +101,7 @@ public function compareConstructedAgainstCurrent(string $operationName): array
101101
{
102102
$compareResults = [];
103103
$skipList = $this->skipListAndFilterList
104-
->getSkipList($operationName, CompareType::CompareConstructedAgainstCurrent);
104+
->getSkipList($operationName, CompareType::COMPARE_CONSTRUCTED_AGAINST_CURRENT);
105105
foreach ($this->collector->getPropertiesConstructedAndCurrent() as $objectAndProperties) {
106106
$object = $objectAndProperties->getObject();
107107
$constructedObject = $objectAndProperties->getConstructedCollected();

lib/internal/Magento/Framework/TestFramework/ApplicationStateComparator/CompareType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
*/
1313
class CompareType
1414
{
15-
public const CompareBetweenRequests = "CompareBetweenRequests";
16-
public const CompareConstructedAgainstCurrent = "CompareConstructedAgainstCurrent";
15+
public const COMPARE_BETWEEN_REQUESTS = "CompareBetweenRequests";
16+
public const COMPARE_CONSTRUCTED_AGAINST_CURRENT = "CompareConstructedAgainstCurrent";
1717
}

0 commit comments

Comments
 (0)