Skip to content

Commit 5995b40

Browse files
committed
MAGETWO-66343: [Performance] Anomaly increase in redis traffic
2 parents 441278b + 7201bc0 commit 5995b40

File tree

12 files changed

+170
-33
lines changed

12 files changed

+170
-33
lines changed

app/code/Magento/Deploy/Console/DeployStaticOptions.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ class DeployStaticOptions
126126
*/
127127
const LANGUAGES_ARGUMENT = 'languages';
128128

129+
/**
130+
* Static content version
131+
*/
132+
const CONTENT_VERSION = 'content-version';
133+
129134
/**
130135
* Deploy static command options list
131136
*
@@ -211,7 +216,14 @@ private function getBasicOptions()
211216
null,
212217
InputOption::VALUE_NONE,
213218
'Create symlinks for the files of those locales, which are passed for deployment, '
214-
. 'but have no customizations'
219+
. 'but have no customizations.'
220+
),
221+
new InputOption(
222+
self::CONTENT_VERSION,
223+
null,
224+
InputArgument::OPTIONAL,
225+
'Custom version of static content can be used if running deployment on multiple nodes '
226+
. 'to ensure that static content version is identical and caching works properly.'
215227
),
216228
new InputArgument(
217229
self::LANGUAGES_ARGUMENT,

app/code/Magento/Deploy/Service/DeployStaticContent.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ public function deploy(array $options)
9696
]
9797
);
9898

99-
$version = (new \DateTime())->getTimestamp();
99+
$version = !empty($options[Options::CONTENT_VERSION]) && is_string($options[Options::CONTENT_VERSION])
100+
? $options[Options::CONTENT_VERSION]
101+
: (new \DateTime())->getTimestamp();
100102
$this->versionStorage->save($version);
101103

102104
$packages = $deployStrategy->deploy($options);

app/code/Magento/Deploy/Test/Unit/Service/DeployStaticContentTest.php

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ protected function setUp()
9696
'',
9797
false
9898
);
99-
$this->versionStorage->expects($this->once())->method('save');
10099

101100
$this->service = new DeployStaticContent(
102101
$this->objectManager,
@@ -107,14 +106,13 @@ protected function setUp()
107106
);
108107
}
109108

110-
public function testDeploy()
109+
/**
110+
* @param array $options
111+
* @param string $expectedContentVersion
112+
* @dataProvider deployDataProvider
113+
*/
114+
public function testDeploy($options, $expectedContentVersion)
111115
{
112-
$options = [
113-
'strategy' => 'compact',
114-
'no-javascript' => false,
115-
'no-html-minify' => false
116-
];
117-
118116
$package = $this->getMock(Package::class, [], [], '', false);
119117
$package->expects($this->exactly(1))->method('isVirtual')->willReturn(false);
120118
$package->expects($this->exactly(3))->method('getArea')->willReturn('area');
@@ -125,7 +123,11 @@ public function testDeploy()
125123
'package' => $package
126124
];
127125

128-
$this->versionStorage->expects($this->once())->method('save');
126+
if ($expectedContentVersion) {
127+
$this->versionStorage->expects($this->once())->method('save')->with($expectedContentVersion);
128+
} else {
129+
$this->versionStorage->expects($this->once())->method('save');
130+
}
129131

130132
$queue = $this->getMockBuilder(Queue::class)
131133
->disableOriginalConstructor()
@@ -193,4 +195,27 @@ public function testDeploy()
193195
$this->service->deploy($options)
194196
);
195197
}
198+
199+
public function deployDataProvider()
200+
{
201+
return [
202+
[
203+
[
204+
'strategy' => 'compact',
205+
'no-javascript' => false,
206+
'no-html-minify' => false
207+
],
208+
null // content version value should not be asserted in this case
209+
],
210+
[
211+
[
212+
'strategy' => 'compact',
213+
'no-javascript' => false,
214+
'no-html-minify' => false,
215+
'content-version' => '123456',
216+
],
217+
'123456'
218+
]
219+
];
220+
}
196221
}

app/code/Magento/Eav/Model/EavCustomAttributeTypeLocator/SimpleType.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,14 @@ class SimpleType
2828
*/
2929
public function getType($attribute)
3030
{
31-
if (in_array($attribute->getAttributeCode(), $this->anyTypeAttributes)) {
31+
$arrayFrontendInputs = ['multiselect'];
32+
$frontendInput = $attribute->getFrontendInput();
33+
if (in_array($attribute->getAttributeCode(), $this->anyTypeAttributes)
34+
|| in_array($frontendInput, $arrayFrontendInputs)
35+
) {
3236
return TypeProcessor::NORMALIZED_ANY_TYPE;
3337
}
34-
$frontendInput = $attribute->getFrontendInput();
38+
3539
$backendType = $attribute->getBackendType();
3640
$backendTypeMap = [
3741
'static' => TypeProcessor::NORMALIZED_ANY_TYPE,
@@ -41,11 +45,6 @@ public function getType($attribute)
4145
'datetime' => TypeProcessor::NORMALIZED_STRING_TYPE,
4246
'decimal' => TypeProcessor::NORMALIZED_DOUBLE_TYPE,
4347
];
44-
$arrayFrontendInputs = ['multiselect'];
45-
$type = $backendTypeMap[$backendType];
46-
if (in_array($frontendInput, $arrayFrontendInputs)) {
47-
$type .= '[]';
48-
}
49-
return $type;
48+
return $backendTypeMap[$backendType];
5049
}
5150
}

app/code/Magento/Webapi/Controller/Soap/Request/Handler.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,11 @@ protected function _prepareResponseData($data, $serviceClassName, $serviceMethod
157157
} elseif (is_array($data)) {
158158
$dataType = substr($dataType, 0, -2);
159159
foreach ($data as $key => $value) {
160-
if ($value instanceof ExtensibleDataInterface || $value instanceof MetadataObjectInterface) {
160+
if ($value instanceof $dataType
161+
// the following two options are supported for backward compatibility
162+
|| $value instanceof ExtensibleDataInterface
163+
|| $value instanceof MetadataObjectInterface
164+
) {
161165
$result[] = $this->_dataObjectConverter
162166
->convertKeysToCamelCase($this->_dataObjectProcessor->buildOutputDataArray($value, $dataType));
163167
} else {

app/code/Magento/Webapi/Test/Unit/Controller/Soap/Request/HandlerTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ public function testCall()
104104
$this->_dataObjectConverter->expects($this->once())
105105
->method('convertStdObjectToArray')
106106
->will($this->returnValue(['field' => 1]));
107+
$this->_methodsMapProcessorMock->method('getMethodReturnType')->willReturn('string');
107108
$operationName = 'soapOperation';
108109
$className = \Magento\Framework\DataObject::class;
109110
$methodName = 'testMethod';

dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeOptionManagementInterfaceTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ class ProductAttributeOptionManagementInterfaceTest extends WebapiAbstract
1717

1818
public function testGetItems()
1919
{
20-
$this->_markTestAsRestOnly('Fix inconsistencies in WSDL and Data interfaces');
2120
$testAttributeCode = 'quantity_and_stock_status';
2221
$expectedOptions = [
2322
[
@@ -54,7 +53,6 @@ public function testGetItems()
5453
*/
5554
public function testAdd($optionData)
5655
{
57-
$this->_markTestAsRestOnly('Fix inconsistencies in WSDL and Data interfaces');
5856
$testAttributeCode = 'select_attribute';
5957
$serviceInfo = [
6058
'rest' => [
@@ -100,6 +98,7 @@ public function addDataProvider()
10098
AttributeOptionLabelInterface::STORE_ID => 1,
10199
],
102100
],
101+
AttributeOptionInterface::VALUE => ''
103102
];
104103

105104
return [
@@ -121,7 +120,6 @@ public function addDataProvider()
121120
*/
122121
public function testDelete()
123122
{
124-
$this->_markTestAsRestOnly('Fix inconsistencies in WSDL and Data interfaces');
125123
$attributeCode = 'select_attribute';
126124
//get option Id
127125
$optionList = $this->getAttributeOptions($attributeCode);

dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,4 +1296,86 @@ public function testUpdateStatus()
12961296
// Price should be updated
12971297
$this->assertEquals(200, $response['price']);
12981298
}
1299+
1300+
/**
1301+
* Test saving product with custom attribute of multiselect type
1302+
*
1303+
* 1. Create multi-select attribute
1304+
* 2. Create product and set 2 options out of 3 to multi-select attribute
1305+
* 3. Verify that 2 options are selected
1306+
* 4. Unselect all options
1307+
* 5. Verify that non options are selected
1308+
*
1309+
* @magentoApiDataFixture Magento/Catalog/_files/multiselect_attribute.php
1310+
*/
1311+
public function testUpdateMultiselectAttributes()
1312+
{
1313+
$multiselectAttributeCode = 'multiselect_attribute';
1314+
$multiselectOptions = $this->getAttributeOptions($multiselectAttributeCode);
1315+
$option1 = $multiselectOptions[1]['value'];
1316+
$option2 = $multiselectOptions[2]['value'];
1317+
1318+
$productData = $this->getSimpleProductData();
1319+
$productData['custom_attributes'] = [
1320+
['attribute_code' => $multiselectAttributeCode, 'value' => "{$option1},{$option2}"]
1321+
];
1322+
$this->saveProduct($productData, 'all');
1323+
1324+
$this->assertMultiselectValue(
1325+
$productData[ProductInterface::SKU],
1326+
$multiselectAttributeCode,
1327+
"{$option1},{$option2}"
1328+
);
1329+
1330+
$productData['custom_attributes'] = [
1331+
['attribute_code' => $multiselectAttributeCode, 'value' => ""]
1332+
];
1333+
$this->saveProduct($productData, 'all');
1334+
$this->assertMultiselectValue(
1335+
$productData[ProductInterface::SKU],
1336+
$multiselectAttributeCode,
1337+
""
1338+
);
1339+
}
1340+
1341+
/**
1342+
* @param string $attributeCode
1343+
* @return array|bool|float|int|string
1344+
*/
1345+
private function getAttributeOptions($attributeCode)
1346+
{
1347+
$serviceInfo = [
1348+
'rest' => [
1349+
'resourcePath' => '/V1/products/attributes/' . $attributeCode . '/options',
1350+
'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET,
1351+
],
1352+
'soap' => [
1353+
'service' => 'catalogProductAttributeOptionManagementV1',
1354+
'serviceVersion' => 'V1',
1355+
'operation' => 'catalogProductAttributeOptionManagementV1getItems',
1356+
],
1357+
];
1358+
1359+
return $this->_webApiCall($serviceInfo, ['attributeCode' => $attributeCode]);
1360+
}
1361+
1362+
/**
1363+
* @param string $productSku
1364+
* @param string $multiselectAttributeCode
1365+
* @param string $expectedMultiselectValue
1366+
*/
1367+
private function assertMultiselectValue($productSku, $multiselectAttributeCode, $expectedMultiselectValue)
1368+
{
1369+
$response = $this->getProduct($productSku, 'all');
1370+
$customAttributes = $response['custom_attributes'];
1371+
$this->assertNotEmpty($customAttributes);
1372+
$multiselectValue = null;
1373+
foreach ($customAttributes as $customAttribute) {
1374+
if ($customAttribute['attribute_code'] == $multiselectAttributeCode) {
1375+
$multiselectValue = $customAttribute['value'];
1376+
break;
1377+
}
1378+
}
1379+
$this->assertEquals($expectedMultiselectValue, $multiselectValue);
1380+
}
12991381
}

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/BlockGallery.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ class BlockGallery extends Section
2222
*/
2323
private $imageLoader = '.image.image-placeholder .file-row';
2424

25+
/**
26+
* Selector for first uploaded image.
27+
*
28+
* @var string
29+
*/
30+
private $baseImage = '.image.item.base-image';
31+
2532
/**
2633
* Selector for image upload input.
2734
*
@@ -43,6 +50,7 @@ public function setFieldsData(array $data, SimpleElement $element = null)
4350
$uploadElement = $element->find($this->imageUploadInput, Locator::SELECTOR_CSS, 'upload');
4451
$uploadElement->setValue($imageData['file']);
4552
$this->waitForElementNotVisible($this->imageLoader);
53+
$this->waitForElementVisible($this->baseImage);
4654
}
4755
return $this;
4856
}

dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,6 @@
549549
<data name="product/data/sku" xsi:type="string">simple_sku_%isolation%</data>
550550
<data name="product/data/price/value" xsi:type="string">10</data>
551551
<data name="product/data/weight" xsi:type="string">50</data>
552-
<data name="tag" xsi:type="string">severity:S1</data>
553552
<data name="product/data/quantity_and_stock_status/qty" xsi:type="string">100</data>
554553
<constraint name="Magento\Catalog\Test\Constraint\AssertProductSaveMessage" />
555554
<constraint name="Magento\Catalog\Test\Constraint\AssertProductHasImageInGrid" />

0 commit comments

Comments
 (0)