This repository contains the Trading Platform Simulator, a FastAPI application that supports WebSockets connections and related tests.
Before running the application and tests, ensure you have the following installed:
- Clone the repository:
git clone https://github.com/dancost/trading_platform_sim.git cd trading_platform_sim
- Clone the repository:
git clone https://github.com/dancost/trading_platform_sim.git cd trading_platform_sim
-
Ensure Docker is running.
-
Open a terminal (PowerShell) and navigate to the project directory:
cd trading_platform_sim
-
Define the environment variable for the desired test plan:
-
Smoke test plan:
$env:PYTEST_ARGS="-s -v -m smoke --html=test_results/report.html --self-contained-html --capture=sys"
-
Negative test plan:
$env:PYTEST_ARGS="-s -v -m negative --html=test_results/report.html --self-contained-html --capture=sys"
-
Websockets test plan:
$env:PYTEST_ARGS="-s -v -m ws --html=test_results/report.html --self-contained-html --capture=sys"
-
Performance test plan:
$env:PYTEST_ARGS="-s -v -m performance --html=test_results/report.html --self-contained-html --capture=sys"
-
Run all tests:
$env:PYTEST_ARGS="-s -v --html=test_results/report.html --self-contained-html --capture=sys"
-
-
Build and run the Docker containers:
docker-compose up --build
Tested on:
- Docker version 24.0.7
- docker-compose version 1.29.2
- Ubuntu 22.04.1
-
Ensure Docker is running.
-
Open a terminal and navigate to the project directory:
cd trading_platform_sim
-
Define the environment variable for the desired test plan:
-
Smoke test plan:
export PYTEST_ARGS="-s -v -m smoke --html=test_results/report.html --self-contained-html --capture=sys"
-
Negative test plan:
export PYTEST_ARGS="-s -v -m negative --html=test_results/report.html --self-contained-html --capture=sys"
-
Websockets test plan:
export PYTEST_ARGS="-s -v -m ws --html=test_results/report.html --self-contained-html --capture=sys"
-
Performance test plan:
export PYTEST_ARGS="-s -v -m performance --html=test_results/report.html --self-contained-html --capture=sys"
-
Run all tests:
export PYTEST_ARGS="-s -v --html=test_results/report.html --self-contained-html --capture=sys"
-
-
Build and run the Docker containers:
docker-compose up --build
Once the server is running, you can access the Swagger documentation at the following URL:
This documentation provides an interactive interface to explore the API endpoints and test them.
- an offline version of the openapi.yaml can also be found here
The test report will be generated and can be found at:
tests/test_results/report.html
- sample test report can be found in gitHub actions artifacts: https://github.com/dancost/trading_platform_sim/actions/runs/10057725081/artifacts/1730009804 (includes failing test case for demonstration purpose)