Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Learning the hard way -- django_compressor offline and running tests

122 views
Skip to first unread message

Peter Bengtsson

unread,
Nov 7, 2011, 8:42:09 PM11/7/11
to tools...@lists.mozilla.org
Today I killed the Jenkins test for a while. It was tricky to understand
what was going on.

Basically, the preferred approach we have is to compress offline (rather
than doing it on-the-fly). See settings/base.py (COMPRESS_OFFLINE=True).
If you choose this approach, it means that you need to first run
``./manage.py collectstatic --noinput && ./manage.py compress`` before
running tests.

Also, to be able to do that, the offline compressor goes through all
templates and picks up static files it can compress. Because we had an
obsolete template that referenced static files that no longer exists, it
was impossible to change the jenkins build script to run said commands
before starting the test runner.

All of this took me a long time to come to grips with and I ended up
force-landing two bustage fixes on "develop":

1.
https://github.com/mozilla/elmo/commit/0c5892c9e7b15849129ea6c31182c2e3aabaaf73
2.
https://github.com/mozilla/elmo/commit/22db88abee12312275f0bcc757c9ade56bc94957

Sorry :)

This lead me to look into running tests without having to collect and
compress first. That now wasn't possible because of the stupidity of our
handler500() view function. (arguable, it's stupid that our 500.html
depends on Django template code in the form of extending base.html)
To remedy this, I created this bug and uploaded a patch:
https://bugzilla.mozilla.org/show_bug.cgi?id=700521

Now it becomes possible to run the whole test suite with
COMPRESS_OFFLINE switched off.

Lastly, the current approach in
https://github.com/mozilla/elmo/blob/develop/scripts/build.sh#L54 is to
run the tests with compression being offline. That just feels better
because we're not using the compress-on-the-fly approach in production.
If we'd want to run tests with COMPRESS_OFFLINE=False, we'd first need
to apply the patch in #700521 mentioned above.

Peter

Axel Hecht

unread,
Nov 8, 2011, 8:31:43 AM11/8/11
to mozilla-t...@lists.mozilla.org
I wonder, should we fix the template for 404/500 instead? Like a
root.html with our styling, and have base.html inherit that with log-in
and js logic?

OTH, that's not going to save us, as we'd still compress the site style?
Though we could perhaps make root.html not compress, and overload that
with compressed from base.html :-/

I really like re-using the django views, and I think we've been hit by
the "context needed for errors" too often. Totally unscientific measure,
though.

Axel

Peter Bengtsson

unread,
Nov 8, 2011, 11:20:04 AM11/8/11
to Axel Hecht, mozilla-t...@lists.mozilla.org
I like the idea of a root.html that has nothing fancy in it except some
basic html tags. Might file a bug for this.
However, we're not really suffering at the moment since it works fine.
Especially thanks to the patch above and our chosen way of doing
offline bundling. However, sooner or later we're going to get an error
in base.html itself and that's going to murder our 500.html template.


Den Tue Nov 8 05:31:43 2011 skrev Axel Hecht: 
> On 08.11.11 02:42, Peter Bengtsson wrote:
> I wonder, should we fix the template for 404/500 instead? Like a
> root.html with our styling, and have base.html inherit that with
> log-in and js logic?
>
> OTH, that's not going to save us, as we'd still compress the site
> style? Though we could perhaps make root.html not compress, and
> overload that with compressed from base.html :-/
>
> I really like re-using the django views, and I think we've been hit by
> the "context needed for errors" too often. Totally unscientific
> measure, though.
>
> Axel
> _______________________________________________
> Tools-elmo mailing list
> Tools...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/tools-elmo
0 new messages