core: revert django update (#5236)
* Revert "core: bump django from 4.1.7 to 4.2 (#5151)"
This reverts commit 18a4eac527
.
* run unittests with postgres 11 and 12
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
---------
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
parent
200d6d6adf
commit
f84a10b59b
|
@ -1,6 +1,11 @@
|
||||||
name: 'Setup authentik testing environment'
|
name: 'Setup authentik testing environment'
|
||||||
description: 'Setup authentik testing environment'
|
description: 'Setup authentik testing environment'
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
postgresql_tag:
|
||||||
|
description: "Optional postgresql image tag"
|
||||||
|
default: "12"
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: "composite"
|
using: "composite"
|
||||||
steps:
|
steps:
|
||||||
|
@ -24,6 +29,7 @@ runs:
|
||||||
- name: Setup dependencies
|
- name: Setup dependencies
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
export PSQL_TAG=${{ inputs.postgresql_tag }}
|
||||||
docker-compose -f .github/actions/setup/docker-compose.yml up -d
|
docker-compose -f .github/actions/setup/docker-compose.yml up -d
|
||||||
poetry env use python3.11
|
poetry env use python3.11
|
||||||
poetry install
|
poetry install
|
||||||
|
|
|
@ -3,7 +3,7 @@ version: '3.7'
|
||||||
services:
|
services:
|
||||||
postgresql:
|
postgresql:
|
||||||
container_name: postgres
|
container_name: postgres
|
||||||
image: library/postgres:12
|
image: library/postgres:${PSQL_TAG:-12}
|
||||||
volumes:
|
volumes:
|
||||||
- db-data:/var/lib/postgresql/data
|
- db-data:/var/lib/postgresql/data
|
||||||
environment:
|
environment:
|
||||||
|
|
|
@ -80,12 +80,21 @@ jobs:
|
||||||
- name: migrate to latest
|
- name: migrate to latest
|
||||||
run: poetry run python -m lifecycle.migrate
|
run: poetry run python -m lifecycle.migrate
|
||||||
test-unittest:
|
test-unittest:
|
||||||
|
name: test-unittest - PostgreSQL ${{ matrix.psql }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 30
|
timeout-minutes: 30
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
psql:
|
||||||
|
- 11-alpine
|
||||||
|
- 12-alpine
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Setup authentik env
|
- name: Setup authentik env
|
||||||
uses: ./.github/actions/setup
|
uses: ./.github/actions/setup
|
||||||
|
with:
|
||||||
|
postgresql_tag: ${{ matrix.psql }}
|
||||||
- name: run unittest
|
- name: run unittest
|
||||||
run: |
|
run: |
|
||||||
poetry run make test
|
poetry run make test
|
||||||
|
|
|
@ -98,7 +98,7 @@ def traces_sampler(sampling_context: dict) -> float:
|
||||||
def before_send(event: dict, hint: dict) -> Optional[dict]:
|
def before_send(event: dict, hint: dict) -> Optional[dict]:
|
||||||
"""Check if error is database error, and ignore if so"""
|
"""Check if error is database error, and ignore if so"""
|
||||||
# pylint: disable=no-name-in-module
|
# pylint: disable=no-name-in-module
|
||||||
from psycopg.errors import Error
|
from psycopg2.errors import Error
|
||||||
|
|
||||||
ignored_classes = (
|
ignored_classes = (
|
||||||
# Inbuilt types
|
# Inbuilt types
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
"""Database engine that uses prometheus exporter"""
|
|
||||||
from django.db.backends.postgresql import base
|
|
||||||
from django_prometheus.db.common import DatabaseWrapperMixin, ExportingCursorWrapper
|
|
||||||
|
|
||||||
|
|
||||||
class DatabaseFeatures(base.DatabaseFeatures):
|
|
||||||
"""Our database has the exact same features as the base one."""
|
|
||||||
|
|
||||||
|
|
||||||
class DatabaseWrapper(DatabaseWrapperMixin, base.DatabaseWrapper):
|
|
||||||
"""Database wrapper which exports metrics to prometheus"""
|
|
||||||
|
|
||||||
def get_connection_params(self):
|
|
||||||
conn_params = super().get_connection_params()
|
|
||||||
conn_params["cursor_factory"] = ExportingCursorWrapper(base.Cursor, self.alias, self.vendor)
|
|
||||||
return conn_params
|
|
||||||
|
|
||||||
def create_cursor(self, name=None):
|
|
||||||
# cursor_factory is a kwarg to connect() so restore create_cursor()'s
|
|
||||||
# default behavior
|
|
||||||
return base.DatabaseWrapper.create_cursor(self, name=name)
|
|
|
@ -270,7 +270,7 @@ CHANNEL_LAYERS = {
|
||||||
|
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
"default": {
|
"default": {
|
||||||
"ENGINE": "authentik.root.db_engine",
|
"ENGINE": "django_prometheus.db.backends.postgresql",
|
||||||
"HOST": CONFIG.y("postgresql.host"),
|
"HOST": CONFIG.y("postgresql.host"),
|
||||||
"NAME": CONFIG.y("postgresql.name"),
|
"NAME": CONFIG.y("postgresql.name"),
|
||||||
"USER": CONFIG.y("postgresql.user"),
|
"USER": CONFIG.y("postgresql.user"),
|
||||||
|
|
|
@ -6,7 +6,7 @@ from inspect import getmembers, isclass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from psycopg import connect
|
from psycopg2 import connect
|
||||||
from structlog.stdlib import get_logger
|
from structlog.stdlib import get_logger
|
||||||
|
|
||||||
from authentik.lib.config import CONFIG
|
from authentik.lib.config import CONFIG
|
||||||
|
|
|
@ -5,7 +5,7 @@ from sys import exit as sysexit
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from urllib.parse import quote_plus
|
from urllib.parse import quote_plus
|
||||||
|
|
||||||
from psycopg import OperationalError, connect
|
from psycopg2 import OperationalError, connect
|
||||||
from redis import Redis
|
from redis import Redis
|
||||||
from redis.exceptions import RedisError
|
from redis.exceptions import RedisError
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -141,7 +141,7 @@ lxml = "*"
|
||||||
opencontainers = { extras = ["reggie"], version = "*" }
|
opencontainers = { extras = ["reggie"], version = "*" }
|
||||||
packaging = "*"
|
packaging = "*"
|
||||||
paramiko = "*"
|
paramiko = "*"
|
||||||
psycopg = { extras = ["binary"], version = "*" }
|
psycopg2-binary = "*"
|
||||||
pycryptodome = "*"
|
pycryptodome = "*"
|
||||||
pyjwt = "*"
|
pyjwt = "*"
|
||||||
python = "^3.11"
|
python = "^3.11"
|
||||||
|
|
Reference in New Issue