Skip to content

Commit

Permalink
fix load test after changing catalog response
Browse files Browse the repository at this point in the history
  • Loading branch information
jurabek committed Jul 14, 2024
1 parent 3d633ae commit 2e07d78
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
# Essentially just ignore the cache output (PR can't write to registry cache)
echo "cache-to=type=local,dest=/tmp/discard,ignore-error=true" >> $GITHUB_OUTPUT
else
echo "cache-to=type=registry,mode=max,ref=ghcr.io/chayxana/${{ inputs.service-name }}:build-cache" >> $GITHUB_OUTPUT
echo "cache-to=type=registry,mode=max,ref=ghcr.io/chayxana/${{ inputs.service-name }}:build-cache-${{ matrix.architecture }}" >> $GITHUB_OUTPUT
fi
if [[ "${{ github.ref }}" == "refs/heads/develop" ]]; then
Expand All @@ -85,7 +85,7 @@ jobs:
file: src/backend/services/${{ inputs.service-name }}/${{ inputs.docker-file }}
push: ${{ steps.build-metadata.outputs.push }}
tags: ${{ steps.metadata.outputs.tags }}
cache-from: type=registry,ref=ghcr.io/chayxana/${{ inputs.service-name }}:build-cache
cache-from: type=registry,ref=ghcr.io/chayxana/${{ inputs.service-name }}:build-cache-${{ matrix.architecture }}
cache-to: ${{ steps.build-metadata.outputs.cache-to }}
platforms: linux/${{ matrix.architecture }}

Expand Down
29 changes: 18 additions & 11 deletions src/backend/load-tests/scripts/checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,31 @@ export default function () {
}

const foods = getFoods.json();
const food = foods[Math.floor(Math.random() * foods.length)];

const getCartItems = (catalogItems) => {
const cartItems = [];
for (let i = 0; i < Math.floor(Math.random() * 10); i++) {
const item =
catalogItems[Math.floor(Math.random() * catalogItems.length)];
cartItems.push({
img: item.image,
item_id: item.id,
product_description: item.description,
product_name: item.name,
quantity: Math.floor(Math.random() * 20),
unit_price: item.price,
});
}
return cartItems;
};

const user_id = faker.string.uuid();

// create new cart
const createCart = http.post(
cartUrl + "/api/v1/cart",
JSON.stringify({
items: [
{
img: food.image,
item_id: food.id,
product_description: food.description,
product_name: food.name,
quantity: Math.floor(Math.random() * 20),
unit_price: food.price,
},
],
items: getCartItems(foods.catalog_items),
user_id,
})
);
Expand Down

0 comments on commit 2e07d78

Please sign in to comment.