Skip to content

Commit 8116880

Browse files
committed
MAGETWO-85581: Enable metrics validation and run benchmark in multithread mode for PAT
1 parent eeed63e commit 8116880

File tree

18 files changed

+24084
-23270
lines changed

18 files changed

+24084
-23270
lines changed

app/code/Magento/Catalog/Block/Product/ImageBuilder.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Catalog\Block\Product;
77

88
use Magento\Catalog\Helper\ImageFactory as HelperFactory;
9+
use Magento\Catalog\Model\Product\Image\NotLoadInfoImageException;
910

1011
class ImageBuilder
1112
{
@@ -129,7 +130,11 @@ public function create()
129130
? 'Magento_Catalog::product/image.phtml'
130131
: 'Magento_Catalog::product/image_with_borders.phtml';
131132

132-
$imagesize = $helper->getResizedImageInfo();
133+
try {
134+
$imagesize = $helper->getResizedImageInfo();
135+
} catch (NotLoadInfoImageException $exception) {
136+
$imagesize = [$helper->getWidth(), $helper->getHeight()];
137+
}
133138

134139
$data = [
135140
'data' => [
@@ -140,8 +145,8 @@ public function create()
140145
'label' => $helper->getLabel(),
141146
'ratio' => $this->getRatio($helper),
142147
'custom_attributes' => $this->getCustomAttributes(),
143-
'resized_image_width' => !empty($imagesize[0]) ? $imagesize[0] : $helper->getWidth(),
144-
'resized_image_height' => !empty($imagesize[1]) ? $imagesize[1] : $helper->getHeight(),
148+
'resized_image_width' => $imagesize[0],
149+
'resized_image_height' => $imagesize[1],
145150
],
146151
];
147152

app/code/Magento/Catalog/Model/Product/Image.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\Catalog\Model\Product;
77

8+
use Magento\Catalog\Model\Product\Image\NotLoadInfoImageException;
89
use Magento\Framework\App\Filesystem\DirectoryList;
910
use Magento\Framework\App\ObjectManager;
1011
use Magento\Framework\Image as MagentoImage;
@@ -877,17 +878,27 @@ protected function _fileExists($filename)
877878

878879
/**
879880
* Return resized product image information
880-
*
881881
* @return array
882+
* @throws NotLoadInfoImageException
882883
*/
883884
public function getResizedImageInfo()
884885
{
885-
if ($this->isBaseFilePlaceholder() == true) {
886-
$image = $this->imageAsset->getSourceFile();
887-
} else {
888-
$image = $this->imageAsset->getPath();
886+
$errorMessage = 'Can\'t get information about the picture: ';
887+
try {
888+
if ($this->isBaseFilePlaceholder() == true) {
889+
$image = $this->imageAsset->getSourceFile();
890+
} else {
891+
$image = $this->imageAsset->getPath();
892+
}
893+
894+
$imageProperties = getimagesize($image);
895+
896+
return $imageProperties;
897+
} finally {
898+
if (empty($imageProperties)) {
899+
throw new NotLoadInfoImageException(__($errorMessage . $image));
900+
}
889901
}
890-
return getimagesize($image);
891902
}
892903

893904
/**
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Catalog\Model\Product\Image;
7+
8+
use Magento\Framework\Exception\LocalizedException;
9+
10+
/**
11+
* @api
12+
* @since 102.0.0
13+
*/
14+
class NotLoadInfoImageException extends LocalizedException
15+
{
16+
}

app/code/Magento/Catalog/Ui/DataProvider/Product/Listing/Collector/Image.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Catalog\Api\Data\ProductRender\ImageInterfaceFactory;
1212
use Magento\Catalog\Api\Data\ProductRenderInterface;
1313
use Magento\Catalog\Helper\ImageFactory;
14+
use Magento\Catalog\Model\Product\Image\NotLoadInfoImageException;
1415
use Magento\Catalog\Ui\DataProvider\Product\ProductRenderCollectorInterface;
1516
use Magento\Framework\App\State;
1617
use Magento\Framework\View\DesignInterface;
@@ -102,7 +103,12 @@ public function collect(ProductInterface $product, ProductRenderInterface $produ
102103
[$this, "emulateImageCreating"],
103104
[$product, $imageCode, (int) $productRender->getStoreId(), $image]
104105
);
105-
$resizedInfo = $helper->getResizedImageInfo();
106+
107+
try {
108+
$resizedInfo = $helper->getResizedImageInfo();
109+
} catch (NotLoadInfoImageException $exception) {
110+
$resizedInfo = [$helper->getWidth(), $helper->getHeight()];
111+
}
106112

107113
$image->setCode($imageCode);
108114
$image->setHeight($helper->getHeight());

app/code/Magento/Wishlist/CustomerData/Wishlist.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\Wishlist\CustomerData;
77

8+
use Magento\Catalog\Model\Product\Image\NotLoadInfoImageException;
89
use Magento\Customer\CustomerData\SectionSourceInterface;
910

1011
/**
@@ -154,15 +155,19 @@ protected function getImageData($product)
154155
? 'Magento_Catalog/product/image'
155156
: 'Magento_Catalog/product/image_with_borders';
156157

157-
$imagesize = $helper->getResizedImageInfo();
158+
try {
159+
$imagesize = $helper->getResizedImageInfo();
160+
} catch (NotLoadInfoImageException $exception) {
161+
$imagesize = [$helper->getWidth(), $helper->getHeight()];
162+
}
158163

159164
$width = $helper->getFrame()
160165
? $helper->getWidth()
161-
: (!empty($imagesize[0]) ? $imagesize[0] : $helper->getWidth());
166+
: $imagesize[0];
162167

163168
$height = $helper->getFrame()
164169
? $helper->getHeight()
165-
: (!empty($imagesize[1]) ? $imagesize[1] : $helper->getHeight());
170+
: $imagesize[1];
166171

167172
return [
168173
'template' => $template,

setup/performance-toolkit/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ The following parameters can be passed to the `benchmark.jmx` scenario:
6262
| admin_user | admin | Admin backend user. |
6363
| admin_password | 123123q | Admin backend password. |
6464
| customer_password | 123123q | Storefront customer password. |
65-
| customers_page_size | 20 | Page size for customers grid in Magento Admin. |
65+
| customers_page_size | 50 | Page size for customers grid in Magento Admin. |
6666
| files_folder | ./files/ | Path to various files that are used in scenario (`setup/performance-toolkit/files`). |
6767
| loops | 1 | Number of loops to run. |
6868
| frontendPoolUsers | 1 | Total number of Frontend threads. |

0 commit comments

Comments
 (0)