Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 5017fda

Browse files
authored
Merge pull request #1857 from magento-performance/MAGETWO-85581
[Performance] MAGETWO-85581: Enable metrics validation and run benchmark in multithread mode for PAT
2 parents 169b3eb + cb0efb3 commit 5017fda

File tree

28 files changed

+24220
-23283
lines changed

28 files changed

+24220
-23283
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: 16 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,26 @@ 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+
try {
887+
if ($this->isBaseFilePlaceholder() == true) {
888+
$image = $this->imageAsset->getSourceFile();
889+
} else {
890+
$image = $this->imageAsset->getPath();
891+
}
892+
893+
$imageProperties = getimagesize($image);
894+
895+
return $imageProperties;
896+
} finally {
897+
if (empty($imageProperties)) {
898+
throw new NotLoadInfoImageException(__('Can\'t get information about the picture: %1', $image));
899+
}
889900
}
890-
return getimagesize($image);
891901
}
892902

893903
/**
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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+
class NotLoadInfoImageException extends \Exception
9+
{
10+
}

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/CatalogSearch/Model/ResourceModel/Fulltext/Collection.php

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection
6161
/**
6262
* @var string|null
6363
*/
64-
private $order = null;
64+
private $relevanceOrderDirection = null;
6565

6666
/**
6767
* @var string
@@ -361,9 +361,19 @@ protected function _renderFiltersBefore()
361361
[]
362362
);
363363

364-
if ($this->order && 'relevance' === $this->order['field']) {
365-
$this->getSelect()->order('search_result.'. TemporaryStorage::FIELD_SCORE . ' ' . $this->order['dir']);
364+
if ($this->relevanceOrderDirection) {
365+
$this->getSelect()->order(
366+
'search_result.'. TemporaryStorage::FIELD_SCORE . ' ' . $this->relevanceOrderDirection
367+
);
366368
}
369+
370+
/*
371+
* This order is required to force search results be the same
372+
* for the same requests and products with the same relevance
373+
* NOTE: this does not replace existing orders but ADDs one more
374+
*/
375+
$this->setOrder('entity_id');
376+
367377
return parent::_renderFiltersBefore();
368378
}
369379

@@ -385,10 +395,12 @@ protected function _renderFilters()
385395
*/
386396
public function setOrder($attribute, $dir = Select::SQL_DESC)
387397
{
388-
$this->order = ['field' => $attribute, 'dir' => $dir];
389-
if ($attribute !== 'relevance') {
398+
if ($attribute === 'relevance') {
399+
$this->relevanceOrderDirection = $dir;
400+
} else {
390401
parent::setOrder($attribute, $dir);
391402
}
403+
392404
return $this;
393405
}
394406

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,

dev/tests/integration/testsuite/Magento/CatalogSearch/Model/ResourceModel/Fulltext/CollectionTest.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,45 @@ public function testLoadWithFilterSearch($request, $filters, $expectedCount)
3131
$this->assertCount($expectedCount, $items);
3232
}
3333

34+
/**
35+
* @magentoDataFixture Magento/Framework/Search/_files/products_with_the_same_search_score.php
36+
*/
37+
public function testSearchResultsAreTheSameForSameRequests()
38+
{
39+
$howManySearchRequests = 3;
40+
$previousResult = null;
41+
42+
$objManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
43+
44+
foreach (range(1, $howManySearchRequests) as $i) {
45+
/** @var \Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection $fulltextCollection */
46+
$fulltextCollection = $objManager->create(
47+
\Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection::class,
48+
['searchRequestName' => 'quick_search_container']
49+
);
50+
51+
$fulltextCollection->addFieldToFilter('search_term', 'shorts');
52+
$fulltextCollection->setOrder('relevance');
53+
$fulltextCollection->load();
54+
$items = $fulltextCollection->getItems();
55+
$this->assertGreaterThan(
56+
0,
57+
count($items),
58+
sprintf("Search #%s result must not be empty", $i)
59+
);
60+
61+
if ($previousResult) {
62+
$this->assertEquals(
63+
$previousResult,
64+
array_keys($items),
65+
"Search result must be the same for the same requests"
66+
);
67+
}
68+
69+
$previousResult = array_keys($items);
70+
}
71+
}
72+
3473
public function filtersDataProviderSearch()
3574
{
3675
return [
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
use Magento\Catalog\Api\ProductRepositoryInterface;
8+
use Magento\Catalog\Model\Product;
9+
use Magento\Catalog\Model\Product\Attribute\Source\Status;
10+
use Magento\Catalog\Model\Product\Type;
11+
use Magento\Catalog\Model\Product\Visibility;
12+
use Magento\TestFramework\Helper\Bootstrap;
13+
14+
Bootstrap::getInstance()->reinitialize();
15+
16+
/** @var ProductRepositoryInterface $productRepository */
17+
$productRepository = Bootstrap::getObjectManager()
18+
->create(ProductRepositoryInterface::class);
19+
20+
$howManyProducts = 5;
21+
22+
foreach (range(1, $howManyProducts) as $productId) {
23+
$product = Bootstrap::getObjectManager()->create(Product::class);
24+
$product->setTypeId(Type::TYPE_SIMPLE)
25+
->setAttributeSetId(4)
26+
->setWebsiteIds([1])
27+
->setName('Cool short' . $productId)
28+
->setSku('cool_shorts_' . $productId)
29+
->setPrice(42)
30+
->setShortDescription("Some description about shorts")
31+
->setTaxClassId(0)
32+
->setDescription('Some description about <b>shorts</b>')
33+
->setVisibility(Visibility::VISIBILITY_BOTH)
34+
->setStatus(Status::STATUS_ENABLED)
35+
->setStockData(
36+
[
37+
'use_config_manage_stock' => 1,
38+
'qty' => 100,
39+
'is_qty_decimal' => 0,
40+
'is_in_stock' => 1,
41+
]
42+
);
43+
44+
$productRepository->save($product);
45+
}
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+
/** @var \Magento\Framework\Registry $registry */
7+
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
8+
$registry = $objectManager->get(\Magento\Framework\Registry::class);
9+
10+
$registry->unregister('isSecureArea');
11+
$registry->register('isSecureArea', true);
12+
13+
/** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $collection */
14+
$collection = $objectManager->create(\Magento\Catalog\Model\ResourceModel\Product\Collection::class);
15+
$collection->addAttributeToSelect('id')->load();
16+
if ($collection->count() > 0) {
17+
$collection->delete();
18+
}
19+
20+
$registry->unregister('isSecureArea');
21+
$registry->register('isSecureArea', false);

dev/tests/integration/testsuite/Magento/Setup/Fixtures/FixtureModelTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function testFixtureGeneration()
118118

119119
foreach ($this->entityAsserts as $entityAssert) {
120120
try {
121-
$entityAssert->assert();
121+
$this->assertTrue($entityAssert->assert());
122122
} catch (\AssertionError $assertionError) {
123123
$this->assertTrue(false, $assertionError->getMessage());
124124
}

dev/tests/integration/testsuite/Magento/Setup/Fixtures/FixturesAsserts/BundleProductsAssert.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function __construct(
4848
/**
4949
* Asserts that generated bundled products are valid
5050
*
51-
* @return void
51+
* @return bool
5252
* @throws \Magento\Framework\Exception\NoSuchEntityException
5353
* @throws \AssertionError
5454
*/
@@ -74,5 +74,7 @@ public function assert()
7474
throw new \AssertionError('Bundle option product links amount is wrong');
7575
}
7676
}
77+
78+
return true;
7779
}
7880
}

dev/tests/integration/testsuite/Magento/Setup/Fixtures/FixturesAsserts/ConfigurableProductsAssert.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function __construct(
4646
/**
4747
* Asserts that generated configurable products are valid
4848
*
49-
* @return void
49+
* @return bool
5050
* @throws \Magento\Framework\Exception\NoSuchEntityException
5151
* @throws \Magento\Framework\Exception\InputException
5252
* @throws \AssertionError
@@ -86,5 +86,7 @@ public function assert()
8686
throw new \AssertionError('Configurable option values amount is wrong');
8787
}
8888
}
89+
90+
return true;
8991
}
9092
}

dev/tests/integration/testsuite/Magento/Setup/Fixtures/FixturesAsserts/ImagesAssert.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public function __construct(
7070
/**
7171
* Performs assertions over images
7272
*
73+
* @return bool
7374
* @throws \AssertionError
7475
*/
7576
public function assert()
@@ -82,6 +83,8 @@ public function assert()
8283
$this->assertProductMediaAttributes($product);
8384
$this->assertProductImageExistsInFS($product);
8485
}
86+
87+
return true;
8588
}
8689

8790
/**

dev/tests/integration/testsuite/Magento/Setup/Fixtures/FixturesAsserts/SimpleProductsAssert.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function __construct(
4343
/**
4444
* Asserts that generated simple products are valid
4545
*
46-
* @return void
46+
* @return bool
4747
* @throws \Magento\Framework\Exception\NoSuchEntityException
4848
* @throws \AssertionError
4949
*/
@@ -52,5 +52,7 @@ public function assert()
5252
$product = $this->productRepository->get(sprintf(SimpleProductsFixture::SKU_PATTERN, 1));
5353
$this->productAssert->assertProductsCount(SimpleProductsFixture::SKU_PATTERN, 2);
5454
$this->productAssert->assertProductType('simple', $product);
55+
56+
return true;
5557
}
5658
}

dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/exception_hierarchy.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
\Magento\Framework\DB\Adapter\DuplicateException
1010
\Magento\Framework\DB\DataConverter\DataConversionException
1111
\Magento\Framework\DB\FieldDataConversionException
12+
\Magento\Catalog\Model\Product\Image\NotLoadInfoImageException

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)