├── LICENSE ├── README.md ├── composer.json ├── config ├── configure-redis.php ├── media.set ├── media.sh ├── media │ ├── 001.jpg │ ├── 002.jpg │ ├── 003.jpg │ ├── 004.jpg │ ├── 005.jpg │ ├── 006.jpg │ ├── 007.jpg │ ├── 008.jpg │ ├── 009.jpg │ ├── 010.jpg │ ├── 011.jpg │ ├── 012.jpg │ ├── 013.jpg │ ├── 014.jpg │ ├── 015.jpg │ ├── 016.jpg │ ├── 017.jpg │ ├── 018.jpg │ ├── 019.jpg │ ├── 020.jpg │ ├── 021.jpg │ ├── 022.jpg │ ├── 023.jpg │ ├── 024.jpg │ └── 025.jpg └── varnish.vcl ├── db ├── clean-data-2.1.0.sql.gz ├── clean-data.sql.gz ├── data-2.1.0.sql.gz ├── data-2.1.1.sql.gz ├── data-2.1.2.sql.gz ├── data-2.1.3.sql.gz ├── data-2.1.4.sql.gz ├── data-2.1.5.sql.gz ├── data-fix-2.0.2.sql ├── data-large-2.1.0.sql.gz ├── data-large-2.1.1.sql.gz ├── data-large-2.1.2.sql.gz ├── data-large-2.1.3.sql.gz ├── data-large-2.1.4.sql.gz ├── data-large-2.1.5.sql.gz ├── data-large.sql.gz ├── data-original-2.1.0.sql.gz ├── data-original-2.1.1.sql.gz ├── data-original-2.1.2.sql.gz ├── data-original-2.1.3.sql.gz ├── data-original-2.1.4.sql.gz ├── data-original-2.1.5.sql.gz ├── data-original.sql.gz └── data.sql.gz ├── distrupt.sh ├── fix-image-resize.sh ├── fix-performance.sh ├── improvement └── EcomDev │ ├── AjaxReviewFix │ ├── etc │ │ └── module.xml │ ├── registration.php │ └── view │ │ └── frontend │ │ ├── layout │ │ └── catalog_product_view.xml │ │ ├── templates │ │ └── review.phtml │ │ └── web │ │ └── js │ │ └── process-reviews.js │ ├── ImageResizeFix │ ├── Model │ │ ├── Model │ │ │ └── Product │ │ │ │ └── Image │ │ │ │ └── Cache.php │ │ └── ProductRepository.php │ ├── etc │ │ ├── di.xml │ │ └── module.xml │ └── registration.php │ └── PageCacheFix │ ├── Model │ └── Observer │ │ └── ProcessLayoutRenderElement.php │ ├── etc │ ├── di.xml │ ├── events.xml │ └── module.xml │ └── registration.php ├── optimize-composer.sh ├── optimize.sh ├── prepare.sh ├── prewarmed.sh ├── resize-images.sh └── setup.sh /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Ivan Chepurnyi 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Magento 2.x Instance Bootstrap for load test 2 | 3 | Bootstrap for load testing 4 | 5 | 6 | ## Setup 7 | 8 | It is designed for byte hypernode instance, if you have a different setup it might not work. 9 | 10 | You can try it out on your local machine by using the following vagrant box: 11 | https://github.com/EcomDev/fast-hypernode 12 | 13 | ## Installation 14 | 15 | 1. Clone repository on hypernode instance 16 | 2. Run `setup.sh` with desired database name, domain and Magento version 17 | 3. Before running each load test cycle run `prepare.sh` with database name as an argument 18 | 19 | 20 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ecomdev/magento-2-performance-bootstrap", 3 | "description": "Magento 2.0 performance bootstrap test", 4 | "license": "MIT", 5 | "minimum-stability":"dev" 6 | } 7 | -------------------------------------------------------------------------------- /config/configure-redis.php: -------------------------------------------------------------------------------- 1 | array ( 5 | 'frontend' => 6 | array ( 7 | 'default' => 8 | array ( 9 | 'backend' => 'Cm_Cache_Backend_Redis', 10 | 'backend_options' => 11 | array ( 12 | 'server' => '127.0.0.1', 13 | 'port' => '6379', 14 | 'persistent' => '', 15 | 'database' => '0', 16 | 'force_standalone' => '0', 17 | 'connect_retries' => '1', 18 | 'read_timeout' => '10', 19 | 'automatic_cleaning_factor' => '0', 20 | 'compress_data' => '1', 21 | 'compress_tags' => '1', 22 | 'compress_threshold' => '20480', 23 | 'compression_lib' => 'gzip', 24 | ), 25 | ), 26 | 'page_cache' => 27 | array ( 28 | 'backend' => 'Cm_Cache_Backend_Redis', 29 | 'backend_options' => 30 | array ( 31 | 'server' => '127.0.0.1', 32 | 'port' => '6379', 33 | 'persistent' => '', 34 | 'database' => '1', 35 | 'force_standalone' => '0', 36 | 'connect_retries' => '1', 37 | 'read_timeout' => '10', 38 | 'automatic_cleaning_factor' => '0', 39 | 'compress_data' => '0', 40 | 'compress_tags' => '1', 41 | 'compress_threshold' => '20480', 42 | 'compression_lib' => 'gzip', 43 | ), 44 | ), 45 | ), 46 | ) 47 | ); 48 | 49 | $existingConfiguration = include $_SERVER['LOCAL_XML']; 50 | 51 | $configuration = var_export($existingConfiguration + $cacheConfiguration, true); 52 | 53 | file_put_contents($_SERVER['LOCAL_XML'], sprintf(' 0s && (bereq.method == "GET" || bereq.method == "HEAD")) { 97 | unset beresp.http.set-cookie; 98 | if (bereq.url !~ "\.(ico|css|js|jpg|jpeg|png|gif|tiff|bmp|gz|tgz|bz2|tbz|mp3|ogg|svg|swf|woff|woff2|eot|ttf|otf)(\?|$)") { 99 | set beresp.http.Pragma = "no-cache"; 100 | set beresp.http.Expires = "-1"; 101 | set beresp.http.Cache-Control = "no-store, no-cache, must-revalidate, max-age=0"; 102 | set beresp.grace = 1m; 103 | } 104 | } 105 | return (deliver); 106 | } 107 | 108 | sub vcl_deliver { 109 | if (resp.http.X-Magento-Debug) { 110 | if (resp.http.x-varnish ~ " ") { 111 | set resp.http.X-Magento-Cache-Debug = "HIT"; 112 | } else { 113 | set resp.http.X-Magento-Cache-Debug = "MISS"; 114 | } 115 | } else { 116 | unset resp.http.Age; 117 | } 118 | 119 | unset resp.http.X-Magento-Debug; 120 | unset resp.http.X-Magento-Tags; 121 | unset resp.http.X-Powered-By; 122 | unset resp.http.Server; 123 | unset resp.http.X-Varnish; 124 | unset resp.http.Via; 125 | unset resp.http.Link; 126 | } 127 | -------------------------------------------------------------------------------- /db/clean-data-2.1.0.sql.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IvanChepurnyi/load-test-magento2-bootstrap/8dc4b620b9c709ebc5c44f1fb6162afbcc9ecfb3/db/clean-data-2.1.0.sql.gz -------------------------------------------------------------------------------- /db/clean-data.sql.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IvanChepurnyi/load-test-magento2-bootstrap/8dc4b620b9c709ebc5c44f1fb6162afbcc9ecfb3/db/clean-data.sql.gz -------------------------------------------------------------------------------- /db/data-2.1.0.sql.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IvanChepurnyi/load-test-magento2-bootstrap/8dc4b620b9c709ebc5c44f1fb6162afbcc9ecfb3/db/data-2.1.0.sql.gz -------------------------------------------------------------------------------- /db/data-2.1.1.sql.gz: -------------------------------------------------------------------------------- 1 | data-2.1.0.sql.gz -------------------------------------------------------------------------------- /db/data-2.1.2.sql.gz: -------------------------------------------------------------------------------- 1 | data-2.1.0.sql.gz -------------------------------------------------------------------------------- /db/data-2.1.3.sql.gz: -------------------------------------------------------------------------------- 1 | data-2.1.0.sql.gz -------------------------------------------------------------------------------- /db/data-2.1.4.sql.gz: -------------------------------------------------------------------------------- 1 | data-2.1.0.sql.gz -------------------------------------------------------------------------------- /db/data-2.1.5.sql.gz: -------------------------------------------------------------------------------- 1 | data-2.1.0.sql.gz -------------------------------------------------------------------------------- /db/data-fix-2.0.2.sql: -------------------------------------------------------------------------------- 1 | update setup_module set schema_version = "2.0.1", data_version="2.0.1" where module='Magento_Quote' and schema_version = "2.0.2"; 2 | update setup_module set schema_version = "2.0.0", data_version="2.0.0" where module='Magento_Integration' and schema_version = "2.0.1"; 3 | -------------------------------------------------------------------------------- /db/data-large-2.1.0.sql.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IvanChepurnyi/load-test-magento2-bootstrap/8dc4b620b9c709ebc5c44f1fb6162afbcc9ecfb3/db/data-large-2.1.0.sql.gz -------------------------------------------------------------------------------- /db/data-large-2.1.1.sql.gz: -------------------------------------------------------------------------------- 1 | data-large-2.1.0.sql.gz -------------------------------------------------------------------------------- /db/data-large-2.1.2.sql.gz: -------------------------------------------------------------------------------- 1 | data-large-2.1.0.sql.gz -------------------------------------------------------------------------------- /db/data-large-2.1.3.sql.gz: -------------------------------------------------------------------------------- 1 | data-large-2.1.0.sql.gz -------------------------------------------------------------------------------- /db/data-large-2.1.4.sql.gz: -------------------------------------------------------------------------------- 1 | data-large-2.1.0.sql.gz -------------------------------------------------------------------------------- /db/data-large-2.1.5.sql.gz: -------------------------------------------------------------------------------- 1 | data-large-2.1.0.sql.gz -------------------------------------------------------------------------------- /db/data-large.sql.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IvanChepurnyi/load-test-magento2-bootstrap/8dc4b620b9c709ebc5c44f1fb6162afbcc9ecfb3/db/data-large.sql.gz -------------------------------------------------------------------------------- /db/data-original-2.1.0.sql.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IvanChepurnyi/load-test-magento2-bootstrap/8dc4b620b9c709ebc5c44f1fb6162afbcc9ecfb3/db/data-original-2.1.0.sql.gz -------------------------------------------------------------------------------- /db/data-original-2.1.1.sql.gz: -------------------------------------------------------------------------------- 1 | data-original-2.1.0.sql.gz -------------------------------------------------------------------------------- /db/data-original-2.1.2.sql.gz: -------------------------------------------------------------------------------- 1 | data-original-2.1.0.sql.gz -------------------------------------------------------------------------------- /db/data-original-2.1.3.sql.gz: -------------------------------------------------------------------------------- 1 | data-original-2.1.0.sql.gz -------------------------------------------------------------------------------- /db/data-original-2.1.4.sql.gz: -------------------------------------------------------------------------------- 1 | data-original-2.1.0.sql.gz -------------------------------------------------------------------------------- /db/data-original-2.1.5.sql.gz: -------------------------------------------------------------------------------- 1 | data-original-2.1.0.sql.gz -------------------------------------------------------------------------------- /db/data-original.sql.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IvanChepurnyi/load-test-magento2-bootstrap/8dc4b620b9c709ebc5c44f1fb6162afbcc9ecfb3/db/data-original.sql.gz -------------------------------------------------------------------------------- /db/data.sql.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IvanChepurnyi/load-test-magento2-bootstrap/8dc4b620b9c709ebc5c44f1fb6162afbcc9ecfb3/db/data.sql.gz -------------------------------------------------------------------------------- /distrupt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | dir=$(dirname $(readlink -f $0)) 4 | 5 | cd $dir/magento 6 | 7 | # Category product relation indexer 8 | bin/magento indexer:reindex catalog_category_product 9 | bin/magento indexer:reindex catalog_product_category 10 | 11 | # Stock inventory indexer 12 | bin/magento indexer:reindex cataloginventory_stock 13 | 14 | # Price indexer 15 | bin/magento indexer:reindex catalog_product_price 16 | 17 | # Catalog product attribute indexer 18 | bin/magento indexer:reindex catalog_product_attribute 19 | 20 | # Catalog product flat indexer 21 | bin/magento indexer:reindex catalog_product_flat 22 | 23 | -------------------------------------------------------------------------------- /fix-image-resize.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | dir=$(dirname $(readlink -f $0)) 4 | 5 | cd $dir/magento 6 | 7 | mkdir -p app/code/EcomDev/ 8 | 9 | cp -r $dir/improvement/EcomDev/ImageResizeFix app/code/EcomDev/ 10 | 11 | rm -rf var/di var/generation var/cache 12 | composer dump-autoload 13 | bin/magento setup:upgrade 14 | bin/magento setup:di:compile 15 | bin/magento setup:static-content:deploy 16 | composer dump-autoload 17 | 18 | -------------------------------------------------------------------------------- /fix-performance.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | dir=$(dirname $(readlink -f $0)) 4 | 5 | cd $dir/magento 6 | 7 | mkdir -p app/code/EcomDev/ 8 | 9 | cp -r $dir/improvement/EcomDev/AjaxReviewFix app/code/EcomDev/ 10 | cp -r $dir/improvement/EcomDev/PageCacheFix app/code/EcomDev/ 11 | 12 | rm -rf var/di var/generation var/cache 13 | composer dump-autoload 14 | 15 | bin/magento setup:upgrade 16 | 17 | bin/magento setup:di:compile 18 | bin/magento setup:static-content:deploy 19 | 20 | composer dump-autoload 21 | -------------------------------------------------------------------------------- /improvement/EcomDev/AjaxReviewFix/etc/module.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /improvement/EcomDev/AjaxReviewFix/registration.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | 17 | \Magento\Framework\Component\ComponentRegistrar::register( 18 | \Magento\Framework\Component\ComponentRegistrar::MODULE, 19 | 'EcomDev_AjaxReviewFix', 20 | __DIR__ 21 | ); 22 | -------------------------------------------------------------------------------- /improvement/EcomDev/AjaxReviewFix/view/frontend/layout/catalog_product_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | a[href="#reviews"] 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /improvement/EcomDev/AjaxReviewFix/view/frontend/templates/review.phtml: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | ?> 17 |
18 | getChildHtml(); ?> 19 | 20 | 33 | -------------------------------------------------------------------------------- /improvement/EcomDev/AjaxReviewFix/view/frontend/web/js/process-reviews.js: -------------------------------------------------------------------------------- 1 | define([ 2 | 'jquery' 3 | ], function ($) { 4 | 'use strict'; 5 | 6 | function processReviews(url, fromPages) { 7 | $.ajax({ 8 | url: url, 9 | dataType: 'html', 10 | cache: true 11 | }).done(function (data) { 12 | $('#product-review-container').html(data); 13 | $('[data-role="product-review"] .pages a').each(function (index, element) { 14 | $(element).click(function (event) { 15 | processReviews($(element).attr('href'), true); 16 | event.preventDefault(); 17 | }); 18 | }); 19 | }).complete(function () { 20 | if (fromPages == true) { 21 | $('html, body').animate({ 22 | scrollTop: $('#reviews').offset().top - 50 23 | }, 300); 24 | } 25 | }); 26 | } 27 | 28 | return function (config, element) { 29 | $(function () { 30 | $(config.reviewLoadHandleSelector).click(function () { 31 | processReviews(config.productReviewUrl); 32 | }); 33 | 34 | $('.product-info-main .reviews-actions a').click(function (event) { 35 | event.preventDefault(); 36 | var acnchor = $(this).attr('href').replace(/^.*?(#|$)/, ''); 37 | $(".product.data.items [data-role='content']").each(function(index){ 38 | if (this.id == 'reviews') { 39 | $('.product.data.items').tabs('activate', index); 40 | $('html, body').animate({ 41 | scrollTop: $('#' + acnchor).offset().top - 50 42 | }, 300); 43 | } 44 | }); 45 | }); 46 | }); 47 | }; 48 | }); 49 | -------------------------------------------------------------------------------- /improvement/EcomDev/ImageResizeFix/Model/Model/Product/Image/Cache.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | 17 | namespace EcomDev\ImageResizeFix\Model\Model\Product\Image; 18 | 19 | 20 | use Magento\Catalog\Helper\Image as ImageHelper; 21 | use Magento\Framework\App\Area; 22 | use Magento\Framework\View\ConfigInterface; 23 | use Magento\Framework\View\DesignInterface; 24 | use Magento\Theme\Model\ResourceModel\Theme\Collection as ThemeCollection; 25 | 26 | class Cache extends \Magento\Catalog\Model\Product\Image\Cache 27 | { 28 | /** 29 | * Design instance for registering current theme 30 | * 31 | * @var DesignInterface 32 | */ 33 | private $design; 34 | 35 | /** 36 | * Pass design instance for proper configuration 37 | * 38 | * @param ConfigInterface $viewConfig 39 | * @param ThemeCollection $themeCollection 40 | * @param ImageHelper $imageHelper 41 | * @param DesignInterface $design 42 | */ 43 | public function __construct( 44 | ConfigInterface $viewConfig, 45 | ThemeCollection $themeCollection, 46 | ImageHelper $imageHelper, 47 | DesignInterface $design 48 | ) { 49 | parent::__construct($viewConfig, $themeCollection, $imageHelper); 50 | $this->design = $design; 51 | } 52 | 53 | /** 54 | * Return list of media image attribute variations 55 | * 56 | * Fixed with proper design theme setup 57 | * 58 | * @return array 59 | */ 60 | protected function getData() 61 | { 62 | if (!$this->data) { 63 | /** @var \Magento\Theme\Model\Theme $theme */ 64 | foreach ($this->themeCollection->loadRegisteredThemes() as $theme) { 65 | // Add missing design theme set 66 | $this->design->setDesignTheme($theme, Area::AREA_FRONTEND); 67 | 68 | $config = $this->viewConfig->getViewConfig([ 69 | 'area' => Area::AREA_FRONTEND, 70 | 'themeModel' => $theme, 71 | ]); 72 | 73 | $images = $config->getMediaEntities('Magento_Catalog', ImageHelper::MEDIA_TYPE_CONFIG_NODE); 74 | 75 | foreach ($images as $imageId => $imageData) { 76 | $this->data[$theme->getCode() . $imageId] = array_merge(['id' => $imageId], $imageData); 77 | } 78 | } 79 | } 80 | 81 | return $this->data; 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /improvement/EcomDev/ImageResizeFix/Model/ProductRepository.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | 17 | namespace EcomDev\ImageResizeFix\Model; 18 | 19 | class ProductRepository extends \Magento\Catalog\Model\ProductRepository 20 | { 21 | /** 22 | * Overridden to reduce memory usage for image resize command 23 | * 24 | * @param int $productId 25 | * @param bool $editMode 26 | * @param null $storeId 27 | * @param bool $forceReload 28 | * 29 | * @return \Magento\Catalog\Api\Data\ProductInterface|mixed 30 | * @throws \Magento\Framework\Exception\NoSuchEntityException 31 | */ 32 | public function getById($productId, $editMode = false, $storeId = null, $forceReload = false) 33 | { 34 | $result = parent::getById($productId, $editMode, $storeId, $forceReload); 35 | 36 | // Clean up memory, as we don't want to reference again product on the next resize 37 | $this->instances = []; 38 | $this->instancesById = []; 39 | 40 | return $result; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /improvement/EcomDev/ImageResizeFix/etc/di.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | EcomDev\ImageResizeFix\Model\ProductRepository 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /improvement/EcomDev/ImageResizeFix/etc/module.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /improvement/EcomDev/ImageResizeFix/registration.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | 17 | \Magento\Framework\Component\ComponentRegistrar::register( 18 | \Magento\Framework\Component\ComponentRegistrar::MODULE, 19 | 'EcomDev_ImageResizeFix', 20 | __DIR__ 21 | ); 22 | -------------------------------------------------------------------------------- /improvement/EcomDev/PageCacheFix/Model/Observer/ProcessLayoutRenderElement.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | 17 | namespace EcomDev\PageCacheFix\Model\Observer; 18 | 19 | 20 | class ProcessLayoutRenderElement extends \Magento\PageCache\Observer\ProcessLayoutRenderElement 21 | { 22 | /** 23 | * Ignored layout handle patterns for ESI include 24 | * 25 | * @var string[] 26 | */ 27 | private $ignoredHandlePatterns; 28 | 29 | /** 30 | * Add ignored handle patterns to request 31 | * 32 | * @param \Magento\PageCache\Model\Config $config 33 | * @param string[] $ignoredHandlePatterns 34 | */ 35 | public function __construct(\Magento\PageCache\Model\Config $config, array $ignoredHandlePatterns = []) 36 | { 37 | parent::__construct($config); 38 | $this->ignoredHandlePatterns = $ignoredHandlePatterns; 39 | } 40 | 41 | /** 42 | * Replaces output of block with ESI tag + filters layout handles passed to esi controller 43 | * 44 | * @param \Magento\Framework\View\Element\AbstractBlock $block 45 | * @param \Magento\Framework\View\Layout $layout 46 | * 47 | * @return string 48 | */ 49 | protected function _wrapEsi( 50 | \Magento\Framework\View\Element\AbstractBlock $block, 51 | \Magento\Framework\View\Layout $layout 52 | ) { 53 | $url = $block->getUrl( 54 | 'page_cache/block/esi', 55 | [ 56 | 'blocks' => json_encode([$block->getNameInLayout()]), 57 | 'handles' => json_encode($this->filterLayoutHanldes($layout->getUpdate()->getHandles())) 58 | ] 59 | ); 60 | return sprintf('', $url); 61 | } 62 | 63 | /** 64 | * Filters layout handles for ESI include by using ignored pattern matching 65 | * 66 | * @param string[] $layoutHandles 67 | * @return string[] 68 | */ 69 | private function filterLayoutHanldes($layoutHandles) 70 | { 71 | foreach ($this->ignoredHandlePatterns as $pattern) { 72 | $layoutHandles = array_filter($layoutHandles, function ($handle) use ($pattern) { 73 | return preg_match($pattern, $handle) === 0; 74 | }); 75 | } 76 | 77 | return $layoutHandles; 78 | } 79 | 80 | 81 | } 82 | -------------------------------------------------------------------------------- /improvement/EcomDev/PageCacheFix/etc/di.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | /^catalog.*?_id_/ 23 | /^catalog_category_view_type/ 24 | /^catalog_category_view_type/ 25 | /^catalog_product_view_type/ 26 | /^catalog_product_view_sku/ 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /improvement/EcomDev/PageCacheFix/etc/events.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /improvement/EcomDev/PageCacheFix/etc/module.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /improvement/EcomDev/PageCacheFix/registration.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | 17 | \Magento\Framework\Component\ComponentRegistrar::register( 18 | \Magento\Framework\Component\ComponentRegistrar::MODULE, 19 | 'EcomDev_PageCacheFix', 20 | __DIR__ 21 | ); 22 | -------------------------------------------------------------------------------- /optimize-composer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | dir=$(dirname $(readlink -f $0)) 4 | 5 | cd $dir/magento 6 | 7 | read -d '' script << PHP 8 | /tmp/$phpscript 23 | 24 | php -f /tmp/$phpscript 25 | rm /tmp/$phpscript 26 | 27 | composer config optimize-autoloader true 28 | composer dump-autoload 29 | -------------------------------------------------------------------------------- /optimize.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | dir=$(dirname $(readlink -f $0)) 4 | path=$(basename $dir) 5 | 6 | cd $dir/magento/ 7 | 8 | rm -rf var/di var/generation var/cache 9 | composer dump-autoload 10 | 11 | # Disable modules that are config disabled by default in Magento 1.x, but enabled by default in 2.x 12 | bin/magento module:disable Magento_Swatches 13 | 14 | # Disable modules that we don't need for a load test scenario, 15 | # in Magento 1.x it was not possible out of the box 16 | bin/magento module:disable Magento_Ups 17 | bin/magento module:disable Magento_Usps 18 | bin/magento module:disable Magento_Dhl 19 | bin/magento module:disable Magento_Braintree 20 | bin/magento module:disable Magento_Paypal 21 | bin/magento module:disable Magento_Authorizenet 22 | 23 | bin/magento cache:flush 24 | bin/magento setup:upgrade 25 | bin/magento setup:di:compile 26 | bin/magento setup:static-content:deploy 27 | 28 | composer dump-autoload 29 | -------------------------------------------------------------------------------- /prepare.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | dir=$(dirname $(readlink -f $0)) 4 | path=$(basename $dir) 5 | database=$1 6 | 7 | if [[ $database == "" ]] 8 | then 9 | echo "Please provide a database name as a first argument" 10 | exit 1 11 | fi 12 | 13 | cd $dir/magento 14 | 15 | # Clean up existing orders, to not affect our load test 16 | echo " 17 | SET foreign_key_checks=0; 18 | TRUNCATE downloadable_link_purchased; 19 | TRUNCATE paypal_billing_agreement_order; 20 | TRUNCATE sales_creditmemo; 21 | TRUNCATE sales_invoice; 22 | TRUNCATE sales_order_address; 23 | TRUNCATE sales_order_item; 24 | TRUNCATE sales_order_payment; 25 | TRUNCATE sales_order_status_history; 26 | TRUNCATE sales_payment_transaction; 27 | TRUNCATE sales_shipment; 28 | TRUNCATE sales_order; 29 | TRUNCATE quote_address; 30 | TRUNCATE quote_id_mask; 31 | TRUNCATE quote_item; 32 | TRUNCATE quote_payment; 33 | TRUNCATE quote; 34 | " | mysql $database 35 | 36 | # Clear caches for not affecting our load tests 37 | n98-magerun2 cache:flush 38 | varnishadm "ban req.url ~ /" 39 | rm -rf pub/media/catalog/product/cache 40 | -------------------------------------------------------------------------------- /prewarmed.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | dir=$(dirname $(readlink -f $0)) 4 | path=$(basename $dir) 5 | 6 | cd $dir/magento 7 | 8 | # Clear caches for not affecting our load tests 9 | mysql -e 'RESET QUERY CACHE;' 10 | n98-magerun2 cache:flush 11 | varnishadm "ban req.url ~ /" 12 | -------------------------------------------------------------------------------- /resize-images.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | dir=$(dirname $(readlink -f $0)) 4 | 5 | bash $dir/fix-image-resize.sh 6 | 7 | cd $dir/magento 8 | 9 | bin/magento catalog:images:resize 10 | -------------------------------------------------------------------------------- /setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | dir=$(dirname $(readlink -f $0)) 4 | path=$(basename $dir) 5 | database=$1 6 | domain=$2 7 | version=$3 8 | databaseVersion=$4 9 | 10 | function usage() 11 | { 12 | echo "Usage: ./setup.sh database-name domain-name [magento-version] [database-variation]"; 13 | echo " database-name Name of the database which to use for installment"; 14 | echo " domain-name Domain name of the test system"; 15 | echo " magento-version Magento version to install, by default: latest"; 16 | echo " database-variation Special variation of database to install: original, large"; 17 | exit 1 18 | } 19 | 20 | if [[ $database == "" ]] 21 | then 22 | echo "Please provide a database name as a first argument" 23 | usage 24 | fi 25 | 26 | if [[ $domain == "" ]] 27 | then 28 | echo "Please provide a domain name as a second argument" 29 | usage 30 | fi 31 | 32 | 33 | if [[ $version == "" ]] 34 | then 35 | version="latest" 36 | fi 37 | 38 | if [[ $databaseVersion == "" ]] 39 | then 40 | databaseVersion="" 41 | fi 42 | 43 | 44 | # Import database 45 | MYSQLPASSWORD=$(awk -F "=" '/password/ {print $2}' ${HOME}/.my.cnf | sed -e 's/^[ \t]*//') 46 | MYSQLUSER=$(awk -F "=" '/user/ {print $2}' ${HOME}/.my.cnf | sed -e 's/^[ \t]*//') 47 | MYSQLHOST=$(awk -F "=" '/host/ {print $2}' ${HOME}/.my.cnf | sed -e 's/^[ \t]*//') 48 | 49 | dbfile=$dir/db/data.sql.gz 50 | 51 | if [ -f $dir/db/data-$databaseVersion-$version.sql.gz ] 52 | then 53 | dbfile=$dir/db/data-$databaseVersion-$version.sql.gz 54 | elif [ -f $dir/db/data-$version.sql.gz ] 55 | then 56 | dbfile=$dir/db/data-$version.sql.gz 57 | elif [ -f $dir/db/data-$databaseVersion.sql.gz ] 58 | then 59 | dbfile=$dir/db/data-$databaseVersion.sql.gz 60 | fi 61 | 62 | baseDbFile=$(basename $dbfile) 63 | 64 | # Install magento configure it 65 | mkdir $dir/magento 66 | cd $dir/magento 67 | 68 | wget -qO- https://magento.mirror.hypernode.com/releases/magento-$version.tar.gz | tar xfz - 69 | chmod +x bin/magento 70 | 71 | function cache_magento() { 72 | cache_path=$HOME/cache/$path-$version 73 | mkdir -p $cache_path 74 | mysqldump $database | gzip -c > $cache_path/$baseDbFile 75 | } 76 | 77 | function try_restore_from_cache() { 78 | cache_path=$HOME/cache/$path-$version 79 | if [ ! -d $HOME/cache ] 80 | then 81 | setup_magento 82 | elif [ -f $cache_path/$baseDbFile ] 83 | then 84 | mysql -e "drop database if exists $database; create database $database;" 85 | gunzip < $cache_path/$baseDbFile | mysql $database 86 | bin/magento setup:install --db-host="$MYSQLHOST" --db-name="$database" --db-user="$MYSQLUSER" \ 87 | --db-password="$MYSQLPASSWORD" --admin-firstname=Admin --admin-lastname=User \ 88 | --admin-user=admin --admin-password=Password123 --admin-email=test@example.com \ 89 | --base-url="http://$domain/" --language=en_US --timezone=Europe/Amsterdam \ 90 | --currency=USD --use-rewrites=1 91 | 92 | if [[ $NO_REDIS == "" ]] 93 | then 94 | # Enable redis cache in Magento 2 95 | LOCAL_XML=$dir/magento/app/etc/env.php php $dir/config/configure-redis.php 96 | fi 97 | 98 | bin/magento cache:flush 99 | bin/magento cache:enable 100 | else 101 | setup_magento 102 | cache_magento 103 | fi 104 | } 105 | 106 | function setup_magento() { 107 | echo "Importing $dbfile" 108 | mysql -e "drop database if exists $database; create database $database;" 109 | gunzip < $dbfile | mysql $database 110 | 111 | fixFile=$dir/db/data-fix-$version.sql 112 | 113 | if [ -f $fixFile ] 114 | then 115 | echo "Fixing setup_module table for $version, as structure didn't change but module setup version did" 116 | mysql $database < $fixFile 117 | fi 118 | 119 | bin/magento setup:install --db-host="$MYSQLHOST" --db-name="$database" --db-user="$MYSQLUSER" \ 120 | --db-password="$MYSQLPASSWORD" --admin-firstname=Admin --admin-lastname=User \ 121 | --admin-user=admin --admin-password=Password123 --admin-email=test@example.com \ 122 | --base-url="http://$domain/" --language=en_US --timezone=Europe/Amsterdam \ 123 | --currency=USD --use-rewrites=1 124 | 125 | # Enable redis cache in Magento 2 126 | if [[ $NO_REDIS == "" ]] 127 | then 128 | LOCAL_XML=$dir/magento/app/etc/env.php php $dir/config/configure-redis.php 129 | fi 130 | 131 | n98-magerun2 config:set web/unsecure/base_url http://$domain/ 132 | n98-magerun2 config:set web/secure/base_url http://$domain/ 133 | n98-magerun2 config:set catalog/frontend/flat_catalog_category 1 134 | n98-magerun2 config:set catalog/frontend/flat_catalog_product 1 135 | # Make same category product per page positions as in Magento 1.0 136 | n98-magerun2 config:set catalog/frontend/grid_per_page_values "12,24,36" 137 | n98-magerun2 config:set catalog/frontend/grid_per_page "12" 138 | n98-magerun2 config:set system/full_page_cache/caching_application 2 139 | n98-magerun2 config:set system/full_page_cache/ttl 86400 140 | n98-magerun2 config:set dev/grid/async_indexing 1 141 | n98-magerun2 config:set sales_email/general/async_sending 1 142 | 143 | bin/magento cache:flush 144 | bin/magento indexer:reindex cataloginventory_stock 145 | bin/magento indexer:reindex 146 | bin/magento cache:enable 147 | } 148 | 149 | try_restore_from_cache 150 | 151 | bin/magento deploy:mode:set production 152 | bin/magento cache:flush 153 | 154 | $dir/optimize-composer.sh 155 | 156 | cd $dir 157 | 158 | [ ! -d ../public ] || rm ../public/*.txt 159 | [ ! -d ../public ] || rmdir ../public 160 | 161 | if [[ $NO_VARNISH == "" ]] 162 | then 163 | varnishadm vcl.load m2benchmark $dir/config/varnish.vcl 164 | varnishadm vcl.use m2benchmark 165 | fi 166 | 167 | 168 | if [[ $NO_IMAGES == "" ]] 169 | then 170 | bash $dir/config/media.sh $dir/magento/pub $dir/config/media.set $dir/config/media 171 | fi 172 | 173 | ln -fsn $path/magento/pub ../public 174 | --------------------------------------------------------------------------------