From 35074660dc18cb2ede7c209312dfb2ab32deb740 Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Wed, 18 Sep 2024 12:08:01 -0700 Subject: [PATCH] chore: Prevent test suite artifact creation in work directory (#6438) * chore: Prevent test suite artifact creation in work directory Also remove a few other stale test assets while I'm here. * Try and fix CI * Change IDSUBMIT_REPOSITORY_PATH * Make the dir * test: clean up media/nomcom directories * test: de-dup settings_temp_path_overrides * chore: remove debug * refactor: avoid premature import of test_utils * refactor: drop useless lambda wrapper --------- Co-authored-by: Jennifer Richards --- dev/tests/settings_local.py | 4 +- docker/configs/settings_local.py | 4 +- docker/scripts/app-create-dirs.sh | 8 +- ietf/meeting/tests_js.py | 11 +- ietf/person/factories.py | 7 +- ietf/settings_test.py | 24 +- ietf/utils/test_utils.py | 13 +- media/.gitignore | 1 - media/photo/nopictureavailable.jpg | Bin 1618 -> 0 bytes media/photo/profile-default.jpg | Bin 1397 -> 0 bytes test/data/profile-default.jpg | Bin 1397 -> 0 bytes test/data/youtube-discovery.json | 10879 ------------------------- test/data/youtube-playlistid.json | 1 - test/data/youtube-playlistitems.json | 1 - test/lib/.gitignore | 1 - test/lib/README | 9 - test/media/floor/.gitignore | 1 - test/media/photo/.gitignore | 1 - 18 files changed, 33 insertions(+), 10932 deletions(-) delete mode 100644 media/.gitignore delete mode 100644 media/photo/nopictureavailable.jpg delete mode 100644 media/photo/profile-default.jpg delete mode 100644 test/data/profile-default.jpg delete mode 100644 test/data/youtube-discovery.json delete mode 100644 test/data/youtube-playlistid.json delete mode 100644 test/data/youtube-playlistitems.json delete mode 100644 test/lib/.gitignore delete mode 100644 test/lib/README delete mode 100644 test/media/floor/.gitignore delete mode 100644 test/media/photo/.gitignore diff --git a/dev/tests/settings_local.py b/dev/tests/settings_local.py index 8b5d90b1e..20941359d 100644 --- a/dev/tests/settings_local.py +++ b/dev/tests/settings_local.py @@ -17,8 +17,8 @@ DATABASES = { } IDSUBMIT_IDNITS_BINARY = "/usr/local/bin/idnits" -IDSUBMIT_REPOSITORY_PATH = "test/id/" -IDSUBMIT_STAGING_PATH = "test/staging/" +IDSUBMIT_REPOSITORY_PATH = "/assets/ietfdata/doc/draft/repository" +IDSUBMIT_STAGING_PATH = "/assets/www6s/staging/" AGENDA_PATH = '/assets/www6s/proceedings/' MEETINGHOST_LOGO_PATH = AGENDA_PATH diff --git a/docker/configs/settings_local.py b/docker/configs/settings_local.py index bcd04898e..5d9859c19 100644 --- a/docker/configs/settings_local.py +++ b/docker/configs/settings_local.py @@ -8,7 +8,7 @@ ALLOWED_HOSTS = ['*'] from ietf.settings_postgresqldb import DATABASES # pyflakes:ignore IDSUBMIT_IDNITS_BINARY = "/usr/local/bin/idnits" -IDSUBMIT_STAGING_PATH = "test/staging/" +IDSUBMIT_STAGING_PATH = "/assets/www6s/staging/" AGENDA_PATH = '/assets/www6s/proceedings/' MEETINGHOST_LOGO_PATH = AGENDA_PATH @@ -53,7 +53,7 @@ IDSUBMIT_REPOSITORY_PATH = INTERNET_DRAFT_PATH FTP_DIR = '/assets/ftp' NOMCOM_PUBLIC_KEYS_DIR = 'data/nomcom_keys/public_keys/' -SLIDE_STAGING_PATH = 'test/staging/' +SLIDE_STAGING_PATH = '/assets/www6s/staging/' DE_GFM_BINARY = '/usr/local/bin/de-gfm' diff --git a/docker/scripts/app-create-dirs.sh b/docker/scripts/app-create-dirs.sh index b75c57767..50431f479 100755 --- a/docker/scripts/app-create-dirs.sh +++ b/docker/scripts/app-create-dirs.sh @@ -1,13 +1,6 @@ #!/bin/bash for sub in \ - test/id \ - test/staging \ - test/archive \ - test/rfc \ - test/media \ - test/wiki/ietf \ - data/nomcom_keys/public_keys \ /assets/archive/id \ /assets/collection \ /assets/collection/draft-archive \ @@ -27,6 +20,7 @@ for sub in \ /assets/ietfdata/derived \ /assets/ietfdata/derived/bibxml \ /assets/ietfdata/derived/bibxml/bibxml-ids \ + /assets/ietfdata/doc/draft/repository \ /assets/www6s \ /assets/www6s/staging \ /assets/www6s/wg-descriptions \ diff --git a/ietf/meeting/tests_js.py b/ietf/meeting/tests_js.py index 6199ed7eb..b15aa70e7 100644 --- a/ietf/meeting/tests_js.py +++ b/ietf/meeting/tests_js.py @@ -5,7 +5,7 @@ import time import datetime import shutil -import os +import tempfile import re from django.utils import timezone @@ -939,13 +939,8 @@ class InterimTests(IetfSeleniumTestCase): def tempdir(self, label): # Borrowed from test_utils.TestCase slug = slugify(self.__class__.__name__.replace('.','-')) - dirname = "tmp-{label}-{slug}-dir".format(**locals()) - if 'VIRTUAL_ENV' in os.environ: - dirname = os.path.join(os.environ['VIRTUAL_ENV'], dirname) - path = os.path.abspath(dirname) - if not os.path.exists(path): - os.mkdir(path) - return path + suffix = "-{label}-{slug}-dir".format(**locals()) + return tempfile.mkdtemp(suffix=suffix) def displayed_interims(self, groups=None): sessions = add_event_info_to_session_qs( diff --git a/ietf/person/factories.py b/ietf/person/factories.py index 2247fa9b2..2012483c0 100644 --- a/ietf/person/factories.py +++ b/ietf/person/factories.py @@ -8,7 +8,7 @@ import faker import faker.config import os import random -import shutil +from PIL import Image from unidecode import unidecode from unicodedata import normalize @@ -103,10 +103,9 @@ class PersonFactory(factory.django.DjangoModelFactory): media_name = "%s/%s.jpg" % (settings.PHOTOS_DIRNAME, photo_name) obj.photo = media_name obj.photo_thumb = media_name - photosrc = os.path.join(settings.TEST_DATA_DIR, "profile-default.jpg") photodst = os.path.join(settings.PHOTOS_DIR, photo_name + '.jpg') - if not os.path.exists(photodst): - shutil.copy(photosrc, photodst) + img = Image.new('RGB', (200, 200)) + img.save(photodst) def delete_file(file): os.unlink(file) atexit.register(delete_file, photodst) diff --git a/ietf/settings_test.py b/ietf/settings_test.py index 024512a8d..94ca22c71 100755 --- a/ietf/settings_test.py +++ b/ietf/settings_test.py @@ -9,9 +9,12 @@ # ./manage.py test --settings=settings_test doc.ChangeStateTestCase # -import os +import atexit +import os +import shutil +import tempfile from ietf.settings import * # pyflakes:ignore -from ietf.settings import TEST_CODE_COVERAGE_CHECKER, BASE_DIR, PHOTOS_DIRNAME +from ietf.settings import TEST_CODE_COVERAGE_CHECKER import debug # pyflakes:ignore debug.debug = True @@ -48,11 +51,20 @@ DATABASES = { 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 +def tempdir_with_cleanup(**kwargs): + """Utility to create a temporary dir and arrange cleanup""" + _dir = tempfile.mkdtemp(**kwargs) + atexit.register(shutil.rmtree, _dir) + return _dir + + +NOMCOM_PUBLIC_KEYS_DIR = tempdir_with_cleanup(suffix="-nomcom-public-keys-dir") + +MEDIA_ROOT = tempdir_with_cleanup(suffix="-media") +PHOTOS_DIRNAME = "photo" +PHOTOS_DIR = os.path.join(MEDIA_ROOT, PHOTOS_DIRNAME) +os.mkdir(PHOTOS_DIR) # Undo any developer-dependent middleware when running the tests MIDDLEWARE = [ c for c in MIDDLEWARE if not c in DEV_MIDDLEWARE ] # pyflakes:ignore diff --git a/ietf/utils/test_utils.py b/ietf/utils/test_utils.py index ba35665a8..86c5a0c1c 100644 --- a/ietf/utils/test_utils.py +++ b/ietf/utils/test_utils.py @@ -34,7 +34,7 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -import os +import tempfile import re import email import html5lib @@ -239,13 +239,8 @@ class TestCase(django.test.TestCase): def tempdir(self, label): slug = slugify(self.__class__.__name__.replace('.','-')) - dirname = "tmp-{label}-{slug}-dir".format(**locals()) - if 'VIRTUAL_ENV' in os.environ: - dirname = os.path.join(os.environ['VIRTUAL_ENV'], dirname) - path = os.path.abspath(dirname) - if not os.path.exists(path): - os.mkdir(path) - return path + suffix = "-{label}-{slug}-dir".format(**locals()) + return tempfile.mkdtemp(suffix=suffix) def assertNoFormPostErrors(self, response, error_css_selector=".is-invalid"): """Try to fish out form errors, if none found at least check the @@ -306,7 +301,7 @@ class TestCase(django.test.TestCase): # Replace settings paths with temporary directories. self._ietf_temp_dirs = {} # trashed during tearDown, DO NOT put paths you care about in this - for setting in self.settings_temp_path_overrides: + for setting in set(self.settings_temp_path_overrides): self._ietf_temp_dirs[setting] = self.tempdir(slugify(setting)) self._ietf_saved_context = django.test.utils.override_settings(**self._ietf_temp_dirs) self._ietf_saved_context.enable() diff --git a/media/.gitignore b/media/.gitignore deleted file mode 100644 index dfa8ca37c..000000000 --- a/media/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/floor diff --git a/media/photo/nopictureavailable.jpg b/media/photo/nopictureavailable.jpg deleted file mode 100644 index 0895f9f57c74c6199a8eed323d71fe1caae52c9e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1618 zcmeH|+dmTu0LM3)k;R%}$~pEytF;rIK#{T{wAzdTR(6Uqv@3IG5=8S8}c`bFZuk(c|` z37l)*0KhioXnT84ti3(dGco>jbnGbrz`CG-5FDjP&_s16MH=lH!^a-VId>PWyjQu@ z=THr+BV%?J5l6=&rVM#R@#nD{Psgk+J2z`Q96Zx3mMb;;pR{K}jlZf+qgdwG6!uO{ zK#ftX?-Wnom0Er|(y~0dqj~Ps=QLrJ;8yDAN09;$?@_%Uy+jiTuDEBa4d*1~7SWEG z6jO7nwdHDjaS)T>I#(HlhvNAMf%EpgsUdG)&2BLo+Z`cV(6jpCtsn0y(u#mz?hrM7-%sLZuf(pZ);jyrh8$_!!!CwW8+(-yM}C7WZF= zRJ+CS>v@ZRhFAVETiu)>2-{+idZKcKq`o`jrs>S(#*nYoIlT6F;?h&jEzp3S)3_~5cZI+uzN!Z@b1aVzdKe9vS zp5*@a!vSk+$Zg$u9f1|ALx~a+{?;0Iartn?NNNg3y74&0NlZ>;9Qm}A#uHNMrrV`| zUoWF*^;2jWHIBAoE@!KG##v2PCq{P>n_+hKFO@*^_rauE-nfgBw$+5b3z)x=W$U0vN7n?|9 zZokX;;JezMI27=_v&FSIYv{$8`GBa&D6-*v3EJ zOvRCT9kda%?xW*gfMJR#qFffNYaiKobFgca{ER$G9wYYz%akBTs@}5~%o6mILI%Y# zLfwG*RB+19_Q)mr8K$#=QLNT(aAGfF0T%{e+ovQSVTYT{qBrs-V21gvV-S@H{f~Df zL2NT0V4kE|M&!0dAb2k&l15Z>P&`U-0duX!wbMXTYFc#XQ| z30u|N*4pH1l8i(Oc~uwJ;|JFv(c+75;IOA3qaS)%o;L^+d2Mh`y9wxNS$h# z?tzpzr76Cf__iW`vH`!4zB#cp)1SoTnr1$*LRLMQ7o2;II{u>p5Lu7`tY)MUJVUqQ z0RR~Q7Gvvu0r;uZLZR=V=D^fd{(2^A2py^jjCW{&8()!)FE06#D%d1{JvP|QwXj+; zY|r9f@Hd}iV#4az7686bOo)NGF$DB2}c8==|f?7-9&`9RxkOH`QrTlKbV z`4>C<)mn^VLF%_PTA;)elM04T`-rx~h4-~E#qPt|#gH%)8no*Fq5r@UKi@Jb9qAz3 erH0!=i&Q7I<(v2jXU|_>0l+%AWA537X8#0-_TYm6 diff --git a/media/photo/profile-default.jpg b/media/photo/profile-default.jpg deleted file mode 100644 index d6b03e100415a0fa9effad25c793f33957929e2d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1397 zcmex=>ukC3pCfH06P05XITq?4J21E^7eo0A(TN+S4wfI*Oh zA%!7@nNf*>Nsy6Qkn#T!25GQUnSsuQ0}gg37NE<3k~RVijLbkcb24+YLKHAEFfjuq z*##916FG#0B^(2Tr#w_DY!neSG7m~hE-G2LQQ6pe;^vD$-6F__LQDsV3L;qr6}`p4 z!wfW8kXewyp5ekpK}JCV!P>Ier_+?rbWdKHE7*~#p#0QyQ}e|`{OR`!-(>uFVYbSi z_fx^?Y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