From 0f1a6c960f7d43ddeafb0ca9217049d1f555a772 Mon Sep 17 00:00:00 2001 From: Jim Fenton Date: Wed, 29 Mar 2023 10:45:03 +0900 Subject: [PATCH] chore: Update test docs to postgresql; remove extraneous sqlite stuff (#5400) * chore: Update test docs to postgresql; remove extraneous sqlite stuff * Reverted addition of settings_postgrestest.py to .gitignore --- .vscode/tasks.json | 4 +- README.md | 2 +- bin/setupenv | 45 ------------ docker-compose.yml | 2 +- docker/configs/settings_local_sqlitetest.py | 81 --------------------- docker/scripts/app-init.sh | 13 +--- ietf/.gitignore | 1 - ietf/settings_sqlitetest.py | 58 --------------- 8 files changed, 5 insertions(+), 201 deletions(-) delete mode 100755 bin/setupenv delete mode 100644 docker/configs/settings_local_sqlitetest.py delete mode 100644 ietf/settings_sqlitetest.py diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 5490af335..7e43a30f8 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -48,7 +48,7 @@ "args": [ "${workspaceFolder}/ietf/manage.py", "test", - "--settings=settings_local_sqlitetest" + "--settings=settings_postgrestest" ], "group": "test", "presentation": { @@ -68,7 +68,7 @@ "args": [ "${workspaceFolder}/ietf/manage.py", "test", - "--settings=settings_local_sqlitetest", + "--settings=settings_postgrestest", "--pattern=tests_js.py" ], "group": "test", diff --git a/README.md b/README.md index cfc73adc8..ead5bcb96 100644 --- a/README.md +++ b/README.md @@ -202,7 +202,7 @@ before activating a new release. From a datatracker container, run the command: ```sh -./ietf/manage.py test --settings=settings_local_sqlitetest +./ietf/manage.py test --settings=settings_postgrestest ``` > You can limit the run to specific tests using the `--pattern` argument. diff --git a/bin/setupenv b/bin/setupenv deleted file mode 100755 index b9f0f72da..000000000 --- a/bin/setupenv +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env python - - -import os -import subprocess -import requests -import sys -import stat -import shutil - -basedir = os.path.dirname(os.path.dirname(__file__)) - -sys.path.append(basedir) - -shutil.copyfile(os.path.join(basedir, 'docker/settings_local.py'), os.path.join(basedir, 'settings_local.py')) - -from ietf.settings_sqlitetest import * # we don't import from django.conf here, on purpose - -for dir in [ AGENDA_PATH, IDSUBMIT_REPOSITORY_PATH, IDSUBMIT_STAGING_PATH, - INTERNET_DRAFT_ARCHIVE_DIR, os.path.dirname(DRAFT_ALIASES_PATH), PHOTOS_DIR, - os.path.dirname(os.path.abspath(TEST_GHOSTDRIVER_LOG_PATH)), ]: - if not os.path.exists(dir): - print("Creating %s" % dir) - os.makedirs(dir) - -for path in [ DRAFT_ALIASES_PATH, DRAFT_VIRTUAL_PATH, GROUP_ALIASES_PATH, GROUP_VIRTUAL_PATH, ]: - if not os.path.exists(path): - print("Setting up %s" % path) - dir, fn = os.path.split(path) - url = "https://zinfandel.tools.ietf.org/src/db/tmp/%s" % fn - r = requests.get(url) - if r.status_code == 200: - with open(path, "w") as of: - of.write(r.text) - else: - print("Error %s fetching '%s'" % (r.status_code, url)) - -path = IDSUBMIT_IDNITS_BINARY -if not os.path.exists(path): - print("Setting up %s" % path) - r = requests.get('https://tools.ietf.org/tools/idnits/idnits') - with open(path, 'w') as idnits: - idnits.write(r.text) - os.chmod(path, 0755) - \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index cb2a58986..1b565bbf4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -26,7 +26,7 @@ services: # UID: 1001 # GID: 1001 # DATADIR: data - # DJANGO_SETTINGS_MODULE: settings_sqlitetest + # DJANGO_SETTINGS_MODULE: settings_postgrestest # Uncomment the next line to use a non-root user for all processes. # user: dev diff --git a/docker/configs/settings_local_sqlitetest.py b/docker/configs/settings_local_sqlitetest.py deleted file mode 100644 index 268fe6ec1..000000000 --- a/docker/configs/settings_local_sqlitetest.py +++ /dev/null @@ -1,81 +0,0 @@ -# Copyright The IETF Trust 2010-2020, All Rights Reserved -# -*- coding: utf-8 -*- - - -# Standard settings except we use SQLite and skip migrations, this is -# useful for speeding up tests that depend on the test database, try -# for instance: -# -# ./manage.py test --settings=settings_sqlitetest doc.ChangeStateTestCase -# - -import os -from ietf.settings import * # pyflakes:ignore -from ietf.settings import TEST_CODE_COVERAGE_CHECKER -import debug # pyflakes:ignore -debug.debug = True - -# Workaround to avoid spending minutes stepping through the migrations in -# every test run. The result of this is to use the 'syncdb' way of creating -# the test database instead of doing it through the migrations. Taken from -# https://gist.github.com/NotSqrt/5f3c76cd15e40ef62d09 - -class DisableMigrations(object): - - def __contains__(self, item): - return True - - def __getitem__(self, item): - return None - -MIGRATION_MODULES = DisableMigrations() - -DATABASES = { - 'default': { - 'NAME': 'test.db', - 'ENGINE': 'django.db.backends.sqlite3', - }, - } - -if TEST_CODE_COVERAGE_CHECKER and not TEST_CODE_COVERAGE_CHECKER._started: # pyflakes:ignore - TEST_CODE_COVERAGE_CHECKER.start() # pyflakes:ignore - -NOMCOM_PUBLIC_KEYS_DIR=os.path.abspath("tmp-nomcom-public-keys-dir") - -# Undo any developer-dependent middleware when running the tests -MIDDLEWARE = [ c for c in MIDDLEWARE if not c in DEV_MIDDLEWARE ] # pyflakes:ignore - -TEMPLATES[0]['OPTIONS']['context_processors'] = [ p for p in TEMPLATES[0]['OPTIONS']['context_processors'] if not p in DEV_TEMPLATE_CONTEXT_PROCESSORS ] # pyflakes:ignore - -REQUEST_PROFILE_STORE_ANONYMOUS_SESSIONS = False - -IDSUBMIT_IDNITS_BINARY = "/usr/local/bin/idnits" -IDSUBMIT_REPOSITORY_PATH = "test/id/" -IDSUBMIT_STAGING_PATH = "test/staging/" -INTERNET_DRAFT_ARCHIVE_DIR = "test/archive/" -INTERNET_ALL_DRAFTS_ARCHIVE_DIR = "test/archive/" -RFC_PATH = "test/rfc/" - -AGENDA_PATH = '/assets/www6s/proceedings/' -MEETINGHOST_LOGO_PATH = AGENDA_PATH - -USING_DEBUG_EMAIL_SERVER=True -EMAIL_HOST='localhost' -EMAIL_PORT=2025 - -MEDIA_BASE_DIR = 'test' -MEDIA_ROOT = MEDIA_BASE_DIR + '/media/' -MEDIA_URL = '/media/' - -PHOTOS_DIRNAME = 'photo' -PHOTOS_DIR = MEDIA_ROOT + PHOTOS_DIRNAME - -DOCUMENT_PATH_PATTERN = '/assets/ietf-ftp/{doc.type_id}/' - -SUBMIT_YANG_CATALOG_MODEL_DIR = '/assets/ietf-ftp/yang/catalogmod/' -SUBMIT_YANG_DRAFT_MODEL_DIR = '/assets/ietf-ftp/yang/draftmod/' -SUBMIT_YANG_INVAL_MODEL_DIR = '/assets/ietf-ftp/yang/invalmod/' -SUBMIT_YANG_IANA_MODEL_DIR = '/assets/ietf-ftp/yang/ianamod/' -SUBMIT_YANG_RFC_MODEL_DIR = '/assets/ietf-ftp/yang/rfcmod/' - -DE_GFM_BINARY = '/usr/local/bin/de-gfm' diff --git a/docker/scripts/app-init.sh b/docker/scripts/app-init.sh index 803e565ca..6be844c75 100755 --- a/docker/scripts/app-init.sh +++ b/docker/scripts/app-init.sh @@ -54,17 +54,6 @@ else fi fi -if [ ! -f "$WORKSPACEDIR/ietf/settings_local_sqlitetest.py" ]; then - echo "Setting up a default settings_local_sqlitetest.py ..." - cp $WORKSPACEDIR/docker/configs/settings_local_sqlitetest.py $WORKSPACEDIR/ietf/settings_local_sqlitetest.py -else - echo "Using existing ietf/settings_local_sqlitetest.py file" - if ! cmp -s $WORKSPACEDIR/docker/configs/settings_local_sqlitetest.py $WORKSPACEDIR/ietf/settings_local_sqlitetest.py; then - echo "NOTE: Differences detected compared to docker/configs/settings_local_sqlitetest.py!" - echo "We'll assume you made these deliberately." - fi -fi - if [ ! -f "$WORKSPACEDIR/ietf/settings_local_vite.py" ]; then echo "Setting up a default settings_local_vite.py ..." cp $WORKSPACEDIR/docker/configs/settings_local_vite.py $WORKSPACEDIR/ietf/settings_local_vite.py @@ -130,7 +119,7 @@ if [ -z "$EDITOR_VSCODE" ]; then echo echo "to start a development instance of the Datatracker." echo - echo " ietf/manage.py test --settings=settings_sqlitetest" + echo " ietf/manage.py test --settings=settings_postgrestest" echo echo "to run all the python tests." echo diff --git a/ietf/.gitignore b/ietf/.gitignore index 9df45d76a..2483dbda7 100644 --- a/ietf/.gitignore +++ b/ietf/.gitignore @@ -2,7 +2,6 @@ /settings_local.py /settings_local.py.bak /settings_local_debug.py -/settings_local_sqlitetest.py /settings_local_vite.py /settings_mysqldb.py /settings_postgresqldb.py diff --git a/ietf/settings_sqlitetest.py b/ietf/settings_sqlitetest.py deleted file mode 100644 index 784e8dea6..000000000 --- a/ietf/settings_sqlitetest.py +++ /dev/null @@ -1,58 +0,0 @@ -# Copyright The IETF Trust 2010-2020, All Rights Reserved -# -*- coding: utf-8 -*- - - -# Standard settings except we use SQLite and skip migrations, this is -# useful for speeding up tests that depend on the test database, try -# for instance: -# -# ./manage.py test --settings=settings_sqlitetest doc.ChangeStateTestCase -# - -import os -from ietf.settings import * # pyflakes:ignore -from ietf.settings import TEST_CODE_COVERAGE_CHECKER, BASE_DIR, PHOTOS_DIRNAME -import debug # pyflakes:ignore -debug.debug = True - -# Use a different hostname, to catch hardcoded values -IDTRACKER_BASE_URL = "https://sqlitetest.ietf.org" - -# Workaround to avoid spending minutes stepping through the migrations in -# every test run. The result of this is to use the 'syncdb' way of creating -# the test database instead of doing it through the migrations. Taken from -# https://gist.github.com/NotSqrt/5f3c76cd15e40ef62d09 - -class DisableMigrations(object): - - def __contains__(self, item): - return True - - def __getitem__(self, item): - return None - -MIGRATION_MODULES = DisableMigrations() - - -DATABASES = { - 'default': { - 'NAME': 'test.db', - 'ENGINE': 'django.db.backends.sqlite3', - }, - } - -if TEST_CODE_COVERAGE_CHECKER and not TEST_CODE_COVERAGE_CHECKER._started: # pyflakes:ignore - TEST_CODE_COVERAGE_CHECKER.start() # pyflakes:ignore - -NOMCOM_PUBLIC_KEYS_DIR=os.path.abspath("tmp-nomcom-public-keys-dir") - -MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'test/media/') # pyflakes:ignore -MEDIA_URL = '/test/media/' -PHOTOS_DIR = MEDIA_ROOT + PHOTOS_DIRNAME # pyflakes:ignore - -# Undo any developer-dependent middleware when running the tests -MIDDLEWARE = [ c for c in MIDDLEWARE if not c in DEV_MIDDLEWARE ] # pyflakes:ignore - -TEMPLATES[0]['OPTIONS']['context_processors'] = [ p for p in TEMPLATES[0]['OPTIONS']['context_processors'] if not p in DEV_TEMPLATE_CONTEXT_PROCESSORS ] # pyflakes:ignore - -REQUEST_PROFILE_STORE_ANONYMOUS_SESSIONS = False