This repository was archived by the owner on Dec 19, 2019. It is now read-only.
This repository was archived by the owner on Dec 19, 2019. It is now read-only.
Investigate the changes in createEmptyCart for Customer #773
Closed
Description
Preconditions (*)
- Customer is registered
- Product in stock
Steps to reproduce (*)
- Generate Customer token
- Create an empty Cart and add product (or add a product to Cart)
- Use
createEmptyCart
> 499 times using this script:
#!/bin/bash
### The next line should look this graphql='http://gql-ce.io/graphql';
graphql='http://REPLACE/graphql';
# Create Token
function generateCustomerToken () {
local email=$(echo "[email protected]");
local password="123123qA";
if [[ -z "$2" ]]; then
local email_a=${email};
local password_a=${password};
else
local email_a="$1";
local password_a="$2";
fi
read -r -d '' query << 'QUERY'
mutation generateCustomerToken(
$email: String!
$password: String!
) {
generateCustomerToken(
email: $email
password: $password
) {
token
}
}
QUERY
read -r -d '' variables << VARIABLES
{
"email": "${email_a}",
"password": "${password_a}"
}
VARIABLES
query='{"query":"'${query//[[:space:]]/ }'"'${variables:+',"variables":'}${variables:+${variables//[[:space:]]/ }}};
query=${query//+([[:blank:]])/ };
local response=$(curl \
-X POST ${graphql} \
-H 'Content-Type: application/json' \
-d "$query"
);
customer_token=$(echo ${response} | jq -r '.data.generateCustomerToken.token');
}
function createEmptyCartForCustomer () {
read -r -d '' query << 'QUERY'
mutation {
createEmptyCart
}
QUERY
query='{"query":"'${query//[[:space:]]/ }'"'}
query=${query//+([[:blank:]])/ }
local response=$(curl \
-X POST ${graphql} \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $customer_token" \
-d "$query"
) && cart_id=$(echo ${response} | jq -r '.data.createEmptyCart');
}
generateCustomerToken
# 500 is a pager limit in phpstorm
for (( i = 1; i < 505; i++ )); do
createEmptyCartForCustomer;
done
echo "$cart_id";
- Prepare cart for placing order
- Place order
- Perform query to MySQL to count the number of occurrences, If your MySQL is not on Docker then it can be simplified
mysql -uroot -p123123q -h127.0.0.1 -e'SELECT quote_id, count(*) as NUMBER FROM gqlce.quote_id_mask GROUP BY quote_id';
My result is
+----------+--------+
| quote_id | NUMBER |
+----------+--------+
| 1 | 1 |
| 2 | 1 |
| 3 | 2770 |
+----------+--------+
But your's should look like:
+----------+--------+
| quote_id | NUMBER |
+----------+--------+
| 1 | 505 |
+----------+--------+
Expected result (*)
- Old behavior, the same
quote_masked_id
on every request for createEmptyCart if valid Customer token was used. Why waste memory? We have only 2,147,483,647 records available.
Actual result (*)
- Hige amount of records referencing the same quote.
- Haven't found the ticket about these changes.
Metadata
Metadata
Assignees
Labels
No labels