Should the test suite pass on a read-only filesystem?

74 views
Skip to first unread message

Aymeric Augustin

unread,
Feb 21, 2015, 6:08:38 AM2/21/15
to django-d...@googlegroups.com
Hello,

Would it be a good property of the test suite to pass on a read-only checkout?
Here’s one way to try it without messing up your git checkout (guess why I’m
mentioning this):

% find django tests -type f -print0 | xargs -0 chmod u-w
% find django tests -type d -print0 | xargs -0 chmod u-w
% cd tests
% ./runtests.py

With the current master branch this results in:

FAILED (failures=7, errors=155, skipped=534, expected failures=6)

Specifically I would like to require all tests that touch the filesystem to
write exclusively in TEMP_DIR = os.environ['DJANGO_TEST_TEMP_DIR']. This has
several advantages:

- Since TEMP_DIR is shutil.rmtree'd during teardown, it guarantees that no
files will be leaked.
- It alleviates the need to serialize tests that write in the same filesystem
location when running tests in parallel, provided each runner uses its own
subdirectory inside TEMP_DIR.
- Writing files in the Django checkout during tests is gross: if a test fails,
sometimes these files show up in git status and must be manually removed.
- It may allow for faster tests by pointing TEMP_DIR to a RAM disk. On my test
parallelization branch, I/O appears to be the bottleneck even with a SSD and
an in-memory SQLite database. When CPU usage drops, iosnoop reports lots of
writes that clearly come from `collectstatic` or `makemessages`.

I foresee two difficulties:

- How do we enforce this in the long run? Can we run the CI server with a very
unprivileged user that isn’t allowed to write anywhere other than /tmp?
- makemessages isn’t flexible at all It’s going to be hard to convince it to write
its output outside of the directory it’s processing.

What do you think?

--
Aymeric.

Tim Graham

unread,
Feb 21, 2015, 12:54:16 PM2/21/15
to django-d...@googlegroups.com
Sounds good to me. On Jenkins, I think using chmod to remove write permissions from the relevant checkout directories might work.

Claude Paroz

unread,
Feb 21, 2015, 2:50:22 PM2/21/15
to django-d...@googlegroups.com
Le samedi 21 février 2015 12:08:38 UTC+1, Aymeric Augustin a écrit :
(...)
I foresee two difficulties:

- How do we enforce this in the long run? Can we run the CI server with a very
  unprivileged user that isn’t allowed to write anywhere other than /tmp?
- makemessages isn’t flexible at all It’s going to be hard to convince it to write
  its output outside of the directory it’s processing.
 
Not so much. It should be possible to mock the command and add --output=... to its xgettext_options property.

Claude
Reply all
Reply to author
Forward
0 new messages