
Magento 2 – performance testing
e-Commerce systems maintained on the Magento2 engine often have very extensive product bases, customers and orders, which are difficult (mostly due to the size of the data) to be maintained at various instances, eg development or testing. In addition, there are also issues related to the security of personal data (GDPR). We can eliminate these problems by using sample data available with the Magento engine on the development and test environments.
Addition of sample data (products, customers, sales) to a running Magento2 instance
To power our existing engine based on Magento2 with sample data it is enough to clone a data repository:
git clone <https://github.com/magento/magento2-sample-data.git>
and run a script
php -f <sample-data_clone_dir>/dev/tools/build-sample-data.php -- --ce-source="<path_to_your_magento_instance>"
inputting a path to an instance of our Magento2.
More sample test data
A packet with sample data for magento was created mainly for the best presentation of a new tool (we get a shop that is actually ready for sale – we only have completely different products than ours). For the needs of developers such a package may turn out to be insufficient, which is why there is another way to generate test data: generate-fixtures and Magento2 Performance Toolkit.
Link: https://devdocs.magento.com/guides/v2.2/config-guide/cli/config-cli-subcommands-perf-data.html
In order to generate sample data, just run the command:
php bin/magento setup:performance:generate-fixtures \
setup/performance-toolkit/profiles/ce/small.xml
A series of test objects will be generated in the database: Generating profile with following params:
Generating profile with following params:
|- Admin Users: 50
|- Websites: 1
|- Store Groups Count: 1
|- Store Views Count: 1
|- Categories: 30
|- Attribute Sets (Default): 3
|- Attribute Sets (Extra): 10
|- Simple products: 800
|- Configurable products: 16
|- Product images: 100, 3 per product
|- Customers: 200
|- Cart Price Rules: 20
|- Catalog Price Rules: 20
|- Orders: 80
Config Changes... done in 00:00:00
Generating admin users... done in 00:00:00
Generating websites, stores and store views... done in 00:00:00
Generating categories... done in 00:00:01
Generating attribute sets... done in 00:00:04
Generating simple products... done in 00:00:04
Generating configurable EAV variations... done in 00:00:00
Generating bundle products... done in 00:00:00
Generating configurable products... done in 00:00:01
Generating images... done in 00:00:02
Generating customer groups... done in 00:00:00
Generating customers... done in 00:00:03
Generating cart price rules... done in 00:00:00
Generating catalog price rules... done in 00:00:00
Generating tax rates... done in 00:00:00
Generating tax rules... done in 00:00:00
Generating orders... done in 00:00:00
As a standard, we have several profiles, differing in the number of individual items generated
Parametr | Small profile | Medium profile | Medium multi-site profile | Large profile | Extra large profile |
---|---|---|---|---|---|
websites | 1 | 3 | 25 | 5 | 5 |
store_groups | 1 | 3 | 25 | 5 | 5 |
store_views | 1 | 3 | 50 | 5 | 5 |
simple_products | 800 | 24000 | 4000 | 300000 | 600000 |
configurable_products | 16 with 24 options | 640 with 24 options | 800 with 24 options & 79 with 200 options | 8,000 with 24 options | 16,000 with 24 options |
product_images | 100 images / 3 images per product | 1000 images / 3 images per product | 1000 images / 3 images per product | 2000 images / 3 images per product | 2000 images / 3 images per product |
categories | 30 | 300 | 100 | 3000 | 6000 |
categories_nesting_level | 3 | 3 | 3 | 5 | 5 |
catalog_price_rules | 20 | 20 | 20 | 20 | 20 |
catalog_target_rules | 5 | 5 | 5 | 5 | 5 |
cart_price_rules | 20 | 20 | 20 | 20 | 20 |
cart_price_rules_floor | 2 | 2 | 2 | 2 | 2 |
customers | 200 | 2000 | 2000 | 5000 | 10000 |
tax rates | 130 | 40000 | 40000 | 40000 | 40000 |
orders | 80 | 50000 | 50000 | 100000 | 150000 |
Source: https://devdocs.magento.com/guides/v2.2/config-guide/cli/config-cli-subcommands-perf-data.html
Such generated data can serve to build an environment for automated testing (from zero), for performance testing (we can easily write our own profile, which will reflect data present on the production base) or even for daily work with the system.