From 7297b21dcdf56709c4fa31bb76bb550756471d32 Mon Sep 17 00:00:00 2001 From: rafaelsideguide <150964962+rafaelsideguide@users.noreply.github.com> Date: Fri, 17 May 2024 18:32:44 -0300 Subject: [PATCH] Added load testing using artillery --- apps/test-suite/README.md | 16 ++++++++++ apps/test-suite/load-test.yml | 60 +++++++++++++++++++++++++++++++++++ apps/test-suite/package.json | 4 ++- 3 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 apps/test-suite/load-test.yml diff --git a/apps/test-suite/README.md b/apps/test-suite/README.md index 450a0e3..bb11c6f 100644 --- a/apps/test-suite/README.md +++ b/apps/test-suite/README.md @@ -16,6 +16,22 @@ npx playwright install npm run test ``` +## Running Load Tests with Artillery + +To run load tests using Artillery, follow these steps: + +1. Install Artillery globally if you haven't already: + +```bash +npm install -g artillery +``` + +2. Run the load test: + +```bash +artillery run load-test.yml +``` + ## Test Results The tests are designed to cover various aspects of the system, including: diff --git a/apps/test-suite/load-test.yml b/apps/test-suite/load-test.yml new file mode 100644 index 0000000..5b881ef --- /dev/null +++ b/apps/test-suite/load-test.yml @@ -0,0 +1,60 @@ +config: + target: "https://api.firecrawl.dev/v0" # <<< ADD HERE THE URL FOR THE STAGING ENVIRONMENT + phases: + - duration: 1 + arrivalRate: 5 + defaults: + headers: + Authorization: "Bearer {{ $env.TEST_API_KEY }}" +scenarios: + - name: Scrape a URL + flow: + - post: + url: "/scrape" + json: + url: "https://www.scrapethissite.com" + pageOptions: + onlyMainContent: true + capture: + - json: "$.data.markdown" + as: markdown_content + + # - name: Crawl a URL + # flow: + # - post: + # url: "/crawl" + # json: + # url: "https://mendable.ai" + # crawlerOptions: + # includes: [] + # excludes: ["blog/*"] + # limit: 100 + # pageOptions: + # onlyMainContent: true + # capture: + # - json: "$.jobId" + # as: job_id + # - get: + # url: "/crawl/status/{{ job_id }}" + # capture: + # - json: "$.status" + # as: crawl_status + # until: + # - condition: "equals" + # value: "completed" + # variable: "crawl_status" + # retry: + # count: 20 + # wait: 10 + + # - name: Search for a query + # flow: + # - post: + # url: "/search" + # json: + # query: "firecrawl" + # pageOptions: + # fetchPageContent: true + # capture: + # - json: "$.data[0].markdown" + # as: search_markdown_content \ No newline at end of file diff --git a/apps/test-suite/package.json b/apps/test-suite/package.json index 74ab7a6..6fb3c4e 100644 --- a/apps/test-suite/package.json +++ b/apps/test-suite/package.json @@ -3,7 +3,9 @@ "version": "1.0.0", "description": "", "scripts": { - "test": "npx jest --detectOpenHandles --forceExit --openHandlesTimeout=120000 --watchAll=false" + "test:suite": "npx jest --detectOpenHandles --forceExit --openHandlesTimeout=120000 --watchAll=false", + "test:load": "artillery run load-test.yml", + "fly:staging": "fly deploy -c fly.staging.toml" }, "author": "", "license": "ISC",