Skip to content

Commit 717ef0a

Browse files
authored
Merge pull request #156 from grillazz/152-implement-acyncpg-coon-pool-poc
add performance tests with locust
2 parents 253f775 + f3db7aa commit 717ef0a

File tree

8 files changed

+677
-13
lines changed

8 files changed

+677
-13
lines changed

.github/workflows/build-and-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,6 @@ jobs:
6060
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
6161
run: poetry install --no-interaction --no-root
6262
- name: Test Code
63-
run: poetry run pytest
63+
run: poetry run pytest tests/
6464
- name: Lint Code
6565
run: poetry run ruff .

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ docker-create-db-migration: ## Create new alembic database migration aka databa
2727

2828
.PHONY: docker-test
2929
docker-test: ## Run project tests
30-
docker-compose -f docker-compose.yml -f docker-compose.test.yml run --rm app pytest
30+
docker-compose -f docker-compose.yml -f docker-compose.test.yml run --rm app pytest tests
3131

3232
.PHONY: docker-test-snapshot
3333
docker-test-snapshot: ## Run project tests with inline snapshot

app/api/stuff.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from fastapi import APIRouter, Depends, HTTPException, status, Request
2-
from fastapi.exceptions import ResponseValidationError
32
from sqlalchemy.exc import SQLAlchemyError
43
from sqlalchemy.ext.asyncio import AsyncSession
54

app/models/stuff.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import uuid
22

3-
from fastapi import HTTPException, status
43
from sqlalchemy import String, select, ForeignKey
54
from sqlalchemy.dialects.postgresql import UUID
65
from sqlalchemy.ext.asyncio import AsyncSession

performance/__init__.py

Whitespace-only changes.

performance/locustfile.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from locust import HttpUser, task, between
2+
3+
4+
class Stuff(HttpUser):
5+
wait_time = between(1, 3)
6+
7+
@task
8+
def find_stuff(self):
9+
self.client.get("/v1/stuff/string")
10+
11+
@task
12+
def find_stuff_with_pool(self):
13+
self.client.get("/v1/stuff/pool/string")

poetry.lock

Lines changed: 659 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "fastapi-sqlalchemy-asyncpg"
3-
version = "0.0.12"
3+
version = "0.0.13"
44
description = ""
55
authors = ["Jakub Miazek <the@grillazz.com>"]
66
packages = []
@@ -32,18 +32,16 @@ inline-snapshot = "^0.9.0"
3232
dirty-equals = "^0.7.1.post0"
3333
polyfactory = "^2.15.0"
3434

35-
[tool.poetry.dev-dependencies]
35+
[tool.poetry.group.dev.dependencies]
3636
devtools = { extras = ["pygments"], version = "*" }
3737
safety = "*"
3838
pyupgrade = "*"
3939
ipython = "8.24.0"
4040
ruff = "0.4.3"
4141
psycopg2-binary = "*"
4242
sqlacodegen = "3.0.0rc5"
43-
44-
45-
[tool.poetry.group.dev.dependencies]
4643
tryceratops = "^2.3.2"
44+
locust = "^2.27.0"
4745

4846
[build-system]
4947
requires = ["poetry-core>=1.0.0"]

0 commit comments

Comments
 (0)