This directory contains a simple performance test for the URL Shortener API using k6.
- Install k6: https://k6.io/docs/getting-started/installation/
simple_test.js - Tests the URL shortening endpoint
Make sure the URL Shortener application is running (using Docker Compose or directly) before running tests.
k6 run performance_tests/simple_test.jsYou can run the test with an in-memory SQLite database to avoid affecting your production database:
poetry run python performance_tests/run_with_inmemory.pyThis script:
- Sets up an in-memory SQLite database
- Starts a server using this database
- Runs the simple_test.js with k6
- Cleans up automatically when done
To run the test with custom options:
k6 run --vus 20 --duration 60s performance_tests/simple_test.jsAfter running a test, k6 will display:
- Data sent/received: How much data was transferred
- Response time: Min, max, average, and median response times
- Request rate: Requests per second
- Success rate: Percentage of successful responses
- Checks: Results of any checks defined in the test
You can modify test parameters by:
- Editing the options in the test file
- Using command-line flags when running k6