How to generate data for performance testing in Magento 2?

In this article you will gain knowledge on how to generate data for performance testing.

Step 1

Log in to the Magento server as, or switch to, a user who has permissions to write to the Magento file system. One way you can achieve this is by switching to the Magento file system owner.

If you use the bash shell, you can also use the following syntax to switch to the Magento file system owner and enter the command given below at the same time:
su <Magento file system owner> -s /bin/bash -c <command>

If the Magento file system owner does not allow logins you can do the following:
sudo -u <Magento file system owner>  <command>

Step 2

To run Magento commands from any directory, add <your Magento install dir>/bin to your system PATH.

bash shell example for CentOS:

Run the data generator

Run the command as discussed in this section. 

Command options:
bin/magento setup:perf:generate-fixtures {path to profile}
Where <path to profile> specifies the absolute file system path to, and name of, a profile.

For Example:
bin/magento setup:perf:generate-fixtures /var/www/html/magento2/setup/performance-toolkit/profiles/ce/small.xml

Detailed information about fixtures

The following sections discuss additional details about the performance fixtures.

Admin users

Generates admin users. XML profile node:

<!-- Number of admin users -->
<admin_users>{int}</admin_users>

Attribute sets

Generates attribute sets with the specified configuration. XML profile node:

<!-- Number of product attribute sets -->
<product_attribute_sets>{int}</product_attribute_sets>

<!-- Number of attributes per set -->
<product_attribute_sets_attributes>{int}</product_attribute_sets_attributes>

<!-- Number of values per attribute -->
<product_attribute_sets_attributes_values>{int}</product_attribute_sets_attributes_values>

Bundle products

Generates bundle products. Generated bundle selections are not displayed individually in the catalog. Products will be uniformly distributed according to the categories and websites. If assign_entities_to_all_websites from the profile is set to 1, products will be assigned to all the websites. XML profile node:

<!-- Number of products -->
<bundle_products>{int}</bundle_products>

<!-- Number of options per each product -->
<bundle_products_options>{int}</bundle_products_options>

<!-- Number of simple products per each option -->
<bundle_products_variation>{int}</bundle_products_variation>

Cart price rules

Generates cart price rules. XML profile node:

<!-- Number of cart price rules -->
<cart_price_rules>{int}</cart_price_rules>

<!-- Number of conditions per rule -->
<cart_price_rules_floor>{int}</cart_price_rules_floor>

Catalog price rules

Generates catalog price rules. XML profile node:

<!-- Number of catalog price rules -->
<catalog_price_rules>{int}</catalog_price_rules>

Categories

Generates categories. If assign_entities_to_all_websites is set to 0, all categories are uniformly distributed as per the root categories; otherwise, all categories are assigned to one root category. XML profile node:

<!-- Number of categories to generate -->
<categories>{int}</categories>

<!-- Nesting level of categories -->
<categories_nesting_level>{int}</categories_nesting_level>

Configs

Sets values for config fields. XML profile node:

<!-- Config variables and values for change -->
<configs>
	<config>
		<path>{string}</path>
		<!-- e.g. admin/security/use_form_key -->
		<scope>{string}</scope>
		<!-- e.g. default -->
		<scopeId>{int}</scopeId>
		<value>{int|string}</value>
	</config>
	<!-- ... more entries ... -->
</configs>

Configurable products

Generates configurable products. Generated configurable options are not displayed individually in the catalog. Products are uniformly distributed as per the categories and websites. If assign_entities_to_all_websites is set to 1, products will be assigned to all websites.

Distribution per Default and pre-defined attribute sets:

<!-- Number of configurable products -->
<configurable_products>{int}</configurable_products>

Generate products based on an existing attribute set:

<configurable_products>
	<config>
		<!-- Existing attribute set name -->
		<attributeSet>{string}</attributeSet>
		<!-- Configurable sku pattern with %s -->
		<sku>{string}</sku>
		<!-- Number of configurable products -->
		<products>{int}</products>
		<!-- Category Name. Optional. By default category name from Categories fixture will be used -->
		<category>[{string}]</category>
		<!-- Type of Swatch attribute e.g. color|image -->
		<swatches>{string}</swatches>
	</config>
	<!-- ... more entries ... -->
</configurable_products>

Generate products based on a dynamically created attribute set with a specified amount of attributes and options:

<configurable_products>
	<config>
		<!-- Number of attributes in configurable product -->
		<attributes>{int}</attributes>
		<!-- Number of options per attribute -->
		<options>{int}</options>
		<!-- Configurable sku pattern with %s -->
		<sku>{string}</sku>
		<!-- Number of configurable products -->
		<products>{int}</products>
		<!-- Category Name. Optional. By default category name from Categories fixture will be used -->
		<category>[{string}]</category>
		<!-- Type of Swatch attribute e.g. color|image -->
		<swatches>{string}</swatches>
	</config>
	<!-- ... more entries ... -->
</configurable_products>

Generate products based on a dynamically created attribute set with a specified configuration per each attribute:

<configurable_products>
	<config>
		<attributes>
			<!-- Configuration for a first attribute -->
			<attribute>
				<!-- Amount of options per attribute -->
				<options>{int}</options>
				<!-- Type of Swatch attribute -->
				<swatches>{string}</swatches>
			</attribute>
			<!-- Configuration for the second attribute -->
			<attribute>
				<!-- Amount of options per attribute -->
				<options>{int}</options>
			</attribute>
		</attributes>
		<!-- Configurable sku pattern with %s -->
		<sku>{string}</sku>
		<!-- Number of configurable products -->
		<products>{int}</products>
		<!-- Category Name. Optional. By default, the category name from Categories fixture will be used -->
		<category>[{string}]</category>
	</config>
	<!-- ... more entries ... -->
</configurable_products>

Customers

Generates customers. Customers have a normal distribution on all the available websites. Each customer has the same data except customer email, customer group, and customer addresses. XML profile node:

<!-- Number of customers to generate -->
<customers>{int}</customers>

You can also use the following XML to change the customer configuration:

<customer-config>
    <!-- Number of addresses per each customer -->
    <addresses-count>{int}</addresses-count>
</customer-config>

Product images

Generates product images. The generation does not include the resizing of the images. XML profile node:

<product-images>
	<!-- Number of images to generate -->
	<images-count>{int}</images-count>
	<!-- Number of images to be assigned per each product -->
	<images-per-product>{int}</images-per-product>
</product-images>

Indexers state

Updates indexers’ state. XML profile node:

<indexer>
    <!-- Name of indexer (e.g. catalogrule_product) -->
    <id>{string}</id>
    <set_scheduled>{bool}</set_scheduled>
</indexer>

Orders

Generates orders with the configurable number of different types of order items. Optionally generates inactive quotes for generated orders. XML profile node:

<!-- It is necessary to enable quotes for orders -->
<order_quotes_enable>{bool}</order_quotes_enable>
<!-- Min number of simple products per each order -->
<order_simple_product_count_from>{int}</order_simple_product_count_from>
<!-- Max number of simple products per each order -->
<order_simple_product_count_to>{int}</order_simple_product_count_to>
<!-- Min number of configurable products per each order -->
<order_configurable_product_count_from>{int}</order_configurable_product_count_from>
<!-- Max number of configurable products per each order -->
<order_configurable_product_count_to>{int}</order_configurable_product_count_to>
<!-- Min number of big configurable products (with big amount of options) per each order -->
<order_big_configurable_product_count_from>{int}</order_big_configurable_product_count_from>
<!-- Max number of big configurable products (with big amount of options) per each order -->
<order_big_configurable_product_count_to>{int}</order_big_configurable_product_count_to>
<!-- Number of orders to generate -->
<orders>{int}</orders>

Simple products

Generates simple products. Products are distributed as per default and pre-defined attribute sets. If extra attribute sets are specified in profile as: <product_attribute_sets>{int}</product_attribute_sets>, products are also distributed as per the additional attribute sets.

Products are uniformly distributed per categories and websites. If assign_entities_to_all_websites is set to 1, products are assigned to all websites. XML profile node:

<!-- Number of simple products to generate -->
<simple_products>{int}</simple_products>

Websites

Generates websites. XML profile node:

<!-- Number of websites to be generated -->
<websites>{int}</websites>

Store groups

Generates store groups (referred to in the Magento Admin as stores). Store groups are distributed normally among websites. XML profile node:

<!-- Number of store groups to be generated -->
<store_groups>{int}</store_groups>

Store views

Generates store views. Store views are distributed normally among store groups. XML profile node:

<!-- Number of store views to be generated -->
<store_views>{int}</store_views>
<!-- 1 means that all stores will have the same root category, 0 means that all stores will have unique root category -->
<assign_entities_to_all_websites>{0|1}<assign_entities_to_all_websites/>

Tax rates

Generates tax rates. XML profile node:

<!-- Accepts name of   csv  file with tax rates (<path to magento folder>/setup/src/Magento/Setup/Fixtures/_files) -->
<tax_rates_file>{csv file name}</tax_rates_file>

Verify Output

Once the data generation command is completed.
You need to check the command output:

Generating profile with following params:
 |- 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: 0
 |--- 5 products for attribute set "Attribute Set 1"
 |--- 5 products for attribute set "Attribute Set 2"
 |--- 5 products for attribute set "Attribute Set 3"
 |--- 40 products for attribute set "Dynamic Attribute Set 1-24"
 |- Product images: 100, 3 per product
 |- Customers: 200
 |- Cart Price Rules: 20
 |- Catalog Price Rules: 20
 |- Catalog Target Rules: 5
 |- Orders: 80
Generating websites, stores and store views...  done in <time>
Generating categories...  done in <time>
Generating attribute sets...  done in <time>
Generating simple products...  done in <time>
... more ...

Check different modules like catalog, customer and verify whether the generated data is appropriate or not.

  • Share :