Skip to content

Commit

Permalink
Merge pull request #156 from grillazz/152-implement-acyncpg-coon-pool…
Browse files Browse the repository at this point in the history
…-poc

add performance tests with locust
  • Loading branch information
grillazz committed May 12, 2024
2 parents 253f775 + f3db7aa commit 717ef0a
Show file tree
Hide file tree
Showing 8 changed files with 677 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ jobs:
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
- name: Test Code
run: poetry run pytest
run: poetry run pytest tests/
- name: Lint Code
run: poetry run ruff .
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ docker-create-db-migration: ## Create new alembic database migration aka databa

.PHONY: docker-test
docker-test: ## Run project tests
docker-compose -f docker-compose.yml -f docker-compose.test.yml run --rm app pytest
docker-compose -f docker-compose.yml -f docker-compose.test.yml run --rm app pytest tests

.PHONY: docker-test-snapshot
docker-test-snapshot: ## Run project tests with inline snapshot
Expand Down
1 change: 0 additions & 1 deletion app/api/stuff.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from fastapi import APIRouter, Depends, HTTPException, status, Request
from fastapi.exceptions import ResponseValidationError
from sqlalchemy.exc import SQLAlchemyError
from sqlalchemy.ext.asyncio import AsyncSession

Expand Down
1 change: 0 additions & 1 deletion app/models/stuff.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import uuid

from fastapi import HTTPException, status
from sqlalchemy import String, select, ForeignKey
from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.ext.asyncio import AsyncSession
Expand Down
Empty file added performance/__init__.py
Empty file.
13 changes: 13 additions & 0 deletions performance/locustfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from locust import HttpUser, task, between


class Stuff(HttpUser):
wait_time = between(1, 3)

@task
def find_stuff(self):
self.client.get("/v1/stuff/string")

@task
def find_stuff_with_pool(self):
self.client.get("/v1/stuff/pool/string")
663 changes: 659 additions & 4 deletions poetry.lock

Large diffs are not rendered by default.

8 changes: 3 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "fastapi-sqlalchemy-asyncpg"
version = "0.0.12"
version = "0.0.13"
description = ""
authors = ["Jakub Miazek <the@grillazz.com>"]
packages = []
Expand Down Expand Up @@ -32,18 +32,16 @@ inline-snapshot = "^0.9.0"
dirty-equals = "^0.7.1.post0"
polyfactory = "^2.15.0"

[tool.poetry.dev-dependencies]
[tool.poetry.group.dev.dependencies]
devtools = { extras = ["pygments"], version = "*" }
safety = "*"
pyupgrade = "*"
ipython = "8.24.0"
ruff = "0.4.3"
psycopg2-binary = "*"
sqlacodegen = "3.0.0rc5"


[tool.poetry.group.dev.dependencies]
tryceratops = "^2.3.2"
locust = "^2.27.0"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down

0 comments on commit 717ef0a

Please sign in to comment.