Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

db.model schema - string column without size to default to length 255 #330

Merged
merged 34 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2e6f354
(1) db.models -
ntai-arxiv Oct 18, 2024
ab5d9c6
"It works on my machine" - take 2.
ntai-arxiv Oct 18, 2024
3fd6e01
Fix up the models
ntai-arxiv Oct 19, 2024
720136a
progress made. save the codegen before reform
ntai-arxiv Oct 29, 2024
953bf1d
Tests passed.
ntai-arxiv Nov 5, 2024
bc34008
Save the current db schema, and remove unused file.
ntai-arxiv Nov 6, 2024
6444980
Cooking down the codegen override as small as possible.
ntai-arxiv Nov 6, 2024
4caf5dc
Preserve the class slot variable order between the original and auto-…
ntai-arxiv Nov 7, 2024
a8a48dd
Add table's index patching.
ntai-arxiv Nov 8, 2024
b37df31
Add docstring copy. Mark some of classes deprecated with it.
ntai-arxiv Nov 8, 2024
38a44ea
All of sqlalchemy warnings are resolved.
ntai-arxiv Nov 11, 2024
75d67ea
Ues SOURCE_FORMAT from arxiv.document.versions for Metadata.source_fo…
ntai-arxiv Nov 11, 2024
2eaaa2f
If the column is "enum", use the enum values for the slot type.
ntai-arxiv Nov 11, 2024
8c5d352
More docs, comments and helpers.
ntai-arxiv Nov 12, 2024
a858b43
Modified sqlacodegen - readme and modifications
ntai-arxiv Nov 13, 2024
06684d4
Add warning for changed primary join between existing and latest.
ntai-arxiv Nov 13, 2024
b3963bb
Update readmes and better comments.
ntai-arxiv Nov 19, 2024
3a6671f
Add "load_arxiv_db_schema.py"
ntai-arxiv Nov 21, 2024
c1bd8f8
Add "load_arxiv_db_schema.py" (updated without fluff)
ntai-arxiv Nov 21, 2024
1fed981
Change the mysql version to 5.7.20.
ntai-arxiv Nov 21, 2024
b02b9a1
First pass of tests working with MySQL.
ntai-arxiv Dec 11, 2024
4f2fdb6
Remove the noisy logging.
ntai-arxiv Dec 11, 2024
f9c8779
Tests run without bruteforce connection killing. Pup back MySQL 5.7.2…
ntai-arxiv Dec 11, 2024
7535bd1
Add mysql test in github action
ntai-arxiv Dec 11, 2024
ff3cf96
Run mysql test first!
ntai-arxiv Dec 12, 2024
2dcce3f
merge the current develop eff8c5a
ntai-arxiv Dec 12, 2024
1ea2cd1
Update poetry.lock file
ntai-arxiv Dec 12, 2024
9cd745e
Fixes failing test in test_fastly.py
bdc34 Dec 12, 2024
1040998
Attempt two to fix broken db related to test_fastly.py
bdc34 Dec 12, 2024
b5db550
Set up venv. Set up firefox-esr + gecko driver.
ntai-arxiv Dec 13, 2024
ffe1d6f
Merge remote-tracking branch 'origin/ntai/fix-db-subset-for-db-clonin…
ntai-arxiv Dec 13, 2024
c6be5f7
Skip the oauth2 log in test if there is no web browser + driver is no…
ntai-arxiv Dec 13, 2024
9cd5a5e
Find the firefox-esr and geckodriver.
ntai-arxiv Dec 13, 2024
42d4fbf
Fix the test fixture after the file moved the location.
ntai-arxiv Dec 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions .github/workflows/pullreqeust_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,16 @@ jobs:
poetry --version
# Check if poetry lock file is current with pyproject.toml
poetry check --lock
poetry install --with=dev
poetry install --with=dev --no-ansi

- name: Run db/test with MySQL docker
run: |
sudo apt update
sudo apt install -y mysql-client
cd arxiv && poetry run pytest auth/legacy/tests --db=mysql

- name: Run arxiv-base tests with coverage
run: poetry run pytest --cov=arxiv.base fourohfour --cov-fail-under=67 arxiv/base fourohfour
run: poetry run pytest --cov=arxiv.base fourohfour --cov-fail-under=75 arxiv/base fourohfour
# - name: Check Types
# TODO The types are in bad shape and need to be fixed
# run: poetry run mypy --exclude "test*" -p arxiv
Expand All @@ -31,16 +38,17 @@ jobs:
sudo add-apt-repository -y ppa:mozillateam/ppa
sudo apt update
sudo apt install -y firefox-esr
wget https://github.com/mozilla/geckodriver/releases/latest/download/geckodriver-v0.35.0-linux64.tar.gz
tar -xvzf geckodriver-v0.35.0-linux64.tar.gz
sudo mv geckodriver /usr/local/bin/
wget https://github.com/mozilla/geckodriver/releases/latest/download/geckodriver-v0.35.0-linux64.tar.gz
tar -xvzf geckodriver-v0.35.0-linux64.tar.gz
sudo mv geckodriver /usr/local/bin/
sudo chmod +x /usr/local/bin/geckodriver

- name: Run other tests
# These tests are split out because their coverage is low
run: poetry run pytest --cov=arxiv --cov-fail-under=25 arxiv
run: poetry run pytest --cov=arxiv --cov-fail-under=40 arxiv --ignore=arxiv/base --ignore=arxiv/auth/legacy --db=sqlite
#- name: Check Doc Style
# run: poetry run pydocstyle --convention=numpy --add-ignore=D401 arxiv

- name: Run App Tests
run: poetry run python tests/run_app_tests.py

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,7 @@ fastly_hourly_stats.ini

foo.json
test.db-journal

arxiv/db/.autogen_models.py
/arxiv/db/autogen_models.py
/arxiv/db/near_models.py
41 changes: 41 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
PROD_DB_PROXY_PORT := 2021

.PHONY: prod-proxy test

default: venv/bin/poetry /usr/bin/firefox-esr /usr/local/bin/geckodriver

venv/bin/poetry: venv/bin/pip
. venv/bin/activate && pip install poetry

venv/bin/pip: venv
. venv/bin/activate && pip install --upgrade pip

venv:
python3.11 -m venv venv

/usr/bin/firefox-esr:
sudo add-apt-repository -y ppa:mozillateam/ppa
sudo apt update
sudo apt install -y firefox-esr

/usr/local/bin/geckodriver:
wget https://github.com/mozilla/geckodriver/releases/latest/download/geckodriver-v0.35.0-linux64.tar.gz
tar -xvzf geckodriver-v0.35.0-linux64.tar.gz
sudo mv geckodriver /usr/local/bin/
sudo chmod +x /usr/local/bin/geckodriver

~/.arxiv:
mkdir ~/.arxiv

~/.arxiv/arxiv-db-prod-readonly: ~/.arxiv
op item get as76tjqjnr5wduypygusvfyy34 --fields username,password --reveal | python3 -c "import sys;import urllib.parse; unpw=sys.stdin.read().split(','); sys.stdout.write('mysql://%s:%[email protected]:2021/arXiv' % (unpw[0].strip(),urllib.parse.quote(unpw[1].strip(),safe='*')))" > $@


prod-proxy:
/usr/local/bin/cloud-sql-proxy --address 0.0.0.0 --port ${PROD_DB_PROXY_PORT} arxiv-production:us-central1:arxiv-production-rep9 > /dev/null 2>&1 &

test: venv/bin/poetry
venv/bin/poetry run pytest --cov=arxiv.base fourohfour --cov-fail-under=67 arxiv/base fourohfour
TEST_ARXIV_DB_URI=mysql://testuser:[email protected]:13306/testdb venv/bin/poetry run pytest --cov=arxiv --cov-fail-under=25 arxiv
TEST_ARXIV_DB_URI=mysql://testuser:[email protected]:13306/testdb venv/bin/poetry run python tests/run_app_tests.py

1 change: 1 addition & 0 deletions arxiv/auth/auth/tests/test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from .. import scopes, decorators
from ... import domain


EASTERN = timezone('US/Eastern')
""" @mock.patch(f'{decorators.__name__}.request')"""

Expand Down
171 changes: 0 additions & 171 deletions arxiv/auth/conftest.py

This file was deleted.

2 changes: 1 addition & 1 deletion arxiv/auth/legacy/tests/test_accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def get_user(session, user_id):
def test_with_nonexistant_user_w_app(app):
"""There is no user with the passed username."""
with app.app_context():
assert not accounts.does_username_exist('baruser')
assert not accounts.does_username_exist('baruser')

def test_with_nonexistant_user_wo_app(db_configed):
"""There is no user with the passed username."""
Expand Down
58 changes: 36 additions & 22 deletions arxiv/auth/legacy/tests/test_bootstrap.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
"""Test the legacy integration with synthetic data."""

import os
import shutil
import sys
import tempfile
from typing import Tuple
from unittest import TestCase
from flask import Flask
import locale
import pytest

from typing import List
import random
from datetime import datetime
from pytz import timezone, UTC
from pytz import timezone
from mimesis import Person, Internet, Datetime, locales

from sqlalchemy import select, func
from sqlalchemy import select

import arxiv.db
from arxiv.db import transaction
Expand Down Expand Up @@ -65,6 +61,8 @@ def setUp(self):
arxiv.db.models.configure_db_engine(engine,None)
util.create_all(engine)

visited = set()

with self.app.app_context():
with transaction() as session:
edc = session.execute(select(models.Endorsement)).all()
Expand All @@ -80,21 +78,22 @@ def setUp(self):
papers_to_endorse=3
))

for category in definitions.CATEGORIES_ACTIVE.keys():
if '.' in category:
archive, subject_class = category.split('.', 1)
else:
archive, subject_class = category, ''

with transaction() as session:
#print(f"arch: {archive} sc: {subject_class}")
session.add(models.Category(
archive=archive,
subject_class=subject_class,
definitive=1,
active=1,
endorsement_domain='test_domain_bootstrap'
))
# categories are loaded already
# for category in definitions.CATEGORIES_ACTIVE.keys():
# if '.' in category:
# archive, subject_class = category.split('.', 1)
# else:
# archive, subject_class = category, ''
#
# with transaction() as session:
# #print(f"arch: {archive} sc: {subject_class}")
# session.add(models.Category(
# archive=archive,
# subject_class=subject_class,
# definitive=1,
# active=1,
# endorsement_domain='test_domain_bootstrap'
# ))

COUNT = 100

Expand Down Expand Up @@ -192,6 +191,19 @@ def setUp(self):
issued_when = util.epoch(
Datetime(locale).datetime().replace(tzinfo=EASTERN)
)

# These are the constraints on the table.
key = {
"endorsee": db_user.email,
"endorser_id": endorser_id,
"archive": archive,
"subject_class": subject_class,
}
key_str = repr(key)
if key_str in visited:
# print(f"{key_str} appeared already. This would violate the table constraint.")
continue
visited.add(key_str)
session.add(models.Endorsement(
endorsee=db_user,
endorser_id=endorser_id,
Expand Down Expand Up @@ -235,6 +247,8 @@ def setUp(self):
def tearDown(self):
shutil.rmtree(self.db_path)

@pytest.mark.skipif(lambda request: request.config.getoption("--db") == "mysql",
reason="is set up for sqlite3 only")
def test_authenticate_and_use_session(self):
"""Attempt to authenticate users and create/load auth sessions."""
with self.app.app_context():
Expand Down
Loading
Loading