PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.ruby > Slow RAILS testing
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Slow RAILS testing

Réponse
 
LinkBack Outils de la discussion
Vieux 13/09/2007, 21h14   #1
kevin cline
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Slow RAILS testing

My RAILS unit tests take approximately one minute to run. This may
not sound like much, but it's a real drag on incremental development.
I imagine most of the slowness in spent in applying the database
schema to the test database. Is there a memory-resident database that
would speed up my tests?

  Réponse avec citation
Vieux 13/09/2007, 21h54   #2
George Malamidis
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Slow RAILS testing

Hello,

Do all your tests need to access the database? I find this approach
( http://nutrun.com/weblog/rails-fast-test-suite/ ) useful in terms
of instant feedback and application code responsibility boundaries.

Thanks,
George

On 13 Sep 2007, at 21:15, kevin cline wrote:

> My RAILS unit tests take approximately one minute to run. This may
> not sound like much, but it's a real drag on incremental development.
> I imagine most of the slowness in spent in applying the database
> schema to the test database. Is there a memory-resident database that
> would speed up my tests?
>
>



  Réponse avec citation
Vieux 13/09/2007, 22h22   #3
Alex Young
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Slow RAILS testing

kevin cline wrote:
> My RAILS unit tests take approximately one minute to run. This may
> not sound like much, but it's a real drag on incremental development.
> I imagine most of the slowness in spent in applying the database
> schema to the test database. Is there a memory-resident database that
> would speed up my tests?

I think you can run SQLite in-memory. The Rails people would know more,
though:

http://groups.google.com/group/rubyonrails-talk

I tend to factor tests so that they don't use Rails' built-in fixtures,
though - you really don't need to test the database interface, so it's
pure overhead.

--
Alex

  Réponse avec citation
Vieux 14/09/2007, 00h38   #4
Travis D Warlick Jr
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Slow RAILS testing

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

kevin cline wrote:
> My RAILS unit tests take approximately one minute to run. This may
> not sound like much, but it's a real drag on incremental development.
> I imagine most of the slowness in spent in applying the database
> schema to the test database. Is there a memory-resident database that
> would speed up my tests?


You can use Heap tables with MySQL if you wish. This SQL statement will convert
a table into a Heap (memory-resident) table:

ALTER TABLE tablename TYPE=HEAP;
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG6cnYWvapaOIz2YYRAuuvAJ4wwlypxThIaHCkVy7t4V 1iDdgEHQCfZ5w+
wYBYFf9cGzqs56/O04qhG9I=
=JLqS
-----END PGP SIGNATURE-----

  Réponse avec citation
Vieux 14/09/2007, 09h23   #5
Gaspard Bucher
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Slow RAILS testing

I could more then double the speed of my tests by avoiding fixtures
reload on each test and using transactions. Have a look at
http://dev.zenadmin.org/browser/trun...test_er.rb and
http://dev.zenadmin.org/browser/trunk/test/zena_test.rb.

It sure ed me (and I will now try Travis' HEAP idea on top of that).

Gaspard

2007/9/14, Travis D Warlick Jr <warlickt@operissystems.com>:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> kevin cline wrote:
> > My RAILS unit tests take approximately one minute to run. This may
> > not sound like much, but it's a real drag on incremental development.
> > I imagine most of the slowness in spent in applying the database
> > schema to the test database. Is there a memory-resident database that
> > would speed up my tests?

>
> You can use Heap tables with MySQL if you wish. This SQL statement will convert
> a table into a Heap (memory-resident) table:
>
> ALTER TABLE tablename TYPE=HEAP;
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.7 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFG6cnYWvapaOIz2YYRAuuvAJ4wwlypxThIaHCkVy7t4V 1iDdgEHQCfZ5w+
> wYBYFf9cGzqs56/O04qhG9I=
> =JLqS
> -----END PGP SIGNATURE-----
>
>


  Réponse avec citation
Vieux 14/09/2007, 09h28   #6
Gaspard Bucher
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Slow RAILS testing

HEAP does not support TEXT columns... Too bad.

Gaspard
2007/9/14, Gaspard Bucher <gaspard@teti.ch>:
> I could more then double the speed of my tests by avoiding fixtures
> reload on each test and using transactions. Have a look at
> http://dev.zenadmin.org/browser/trun...test_er.rb and
> http://dev.zenadmin.org/browser/trunk/test/zena_test.rb.
>
> It sure ed me (and I will now try Travis' HEAP idea on top of that).
>
> Gaspard
>
> 2007/9/14, Travis D Warlick Jr <warlickt@operissystems.com>:
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > kevin cline wrote:
> > > My RAILS unit tests take approximately one minute to run. This may
> > > not sound like much, but it's a real drag on incremental development.
> > > I imagine most of the slowness in spent in applying the database
> > > schema to the test database. Is there a memory-resident database that
> > > would speed up my tests?

> >
> > You can use Heap tables with MySQL if you wish. This SQL statement will convert
> > a table into a Heap (memory-resident) table:
> >
> > ALTER TABLE tablename TYPE=HEAP;
> > -----BEGIN PGP SIGNATURE-----
> > Version: GnuPG v1.4.7 (MingW32)
> > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
> >
> > iD8DBQFG6cnYWvapaOIz2YYRAuuvAJ4wwlypxThIaHCkVy7t4V 1iDdgEHQCfZ5w+
> > wYBYFf9cGzqs56/O04qhG9I=
> > =JLqS
> > -----END PGP SIGNATURE-----
> >
> >

>


  Réponse avec citation
Vieux 15/09/2007, 11h43   #7
Phlip
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Slow RAILS testing

Travis D Warlick Jr wrote:

> ALTER TABLE tablename TYPE=HEAP;


Ain't that ENGINE=HEAP?


Gaspard Bucher wrote:

> HEAP does not support TEXT columns... Too bad.


Suppose one wrote a rake task db:heap_mode, to switch the test environment
DB to the faster system. Could that task programmatically access schema.rb,
find the TEXT columns, and downgrade them to long strings?

--
Phlip
http://www.oreilly.com/catalog/9780596510657/
"Test Driven Ajax (on Rails)"
assert_xpath, assert_javascript, & assert_ajax


  Réponse avec citation
Vieux 15/09/2007, 13h30   #8
Travis D Warlick Jr
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Slow RAILS testing

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Phlip wrote:
> Travis D Warlick Jr wrote:
>
>> ALTER TABLE tablename TYPE=HEAP;

>
> Ain't that ENGINE=HEAP?


Both is valid.

> Gaspard Bucher wrote:
>
>> HEAP does not support TEXT columns... Too bad.

>
> Suppose one wrote a rake task db:heap_mode, to switch the test
> environment DB to the faster system. Could that task programmatically
> access schema.rb, find the TEXT columns, and downgrade them to long
> strings?


One possible rails issue: I believe the entire test database structure is erased
and recreated everytime, so it couldn't be a rake task, it would have to be
integrated into the test task.

A database issue: you would have to beware of your table size. Every HEAP table
with at least 1 VARCHAR is at least 50KB due to how the VARCHARs are stored in
memory, and the larger you make your VARCHARs the larger your tables get (eg. a
table with 1 field of VARCHAR(20000) gives a table size of ~170KB).

If anyone wants to do this, note that the largest record size using the HEAP
engine is 64KB, and the largest single VARCHAR is ~21000.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG69BFWvapaOIz2YYRAv5cAJ0Z29aPLUVD8q/coTpULjzkzMahuACfUxqy
Sbr0ZNzCUHCFbrGI4FBQJMk=
=6GQA
-----END PGP SIGNATURE-----

  Réponse avec citation
Vieux 15/09/2007, 17h24   #9
Phlip
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Slow RAILS testing

Travis D Warlick Jr wrote:

> One possible rails issue: I believe the entire test database structure is
> erased
> and recreated everytime, so it couldn't be a rake task, it would have to
> be
> integrated into the test task.


Yup; I just got that.

Then I put the conversion into the top of the source file of the first test
suite in alphabetic order (please nobody comment on the sustainability!),
and got a huge spew of test faults, as if I had no fixtures. The converter
was just this:

require File.dirname(__FILE__) + '/../test_er'

def setup_database
tables = %w( accessories chats fighter_images props rings rounds users )
tables.each do |table|
ActiveRecord::Base.connection.execute("
ALTER TABLE #{ table } ENGINE=HEAP
")
end
end
setup_database

class AccessoryTest < Test::Unit::TestCase
...

And note, per the memory consumption issues you mentioned, that you don't
need to put all the fixtures in the list - if it worked!

--
Phlip


  Réponse avec citation
Vieux 15/09/2007, 20h22   #10
Gaspard Bucher
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Slow RAILS testing

I tried this, but HEAP does not support transactions either. From what
I see, it feels like it's going to be much slower to reload the
fixtures then to do a ROLLBACK...

2007/9/15, Phlip <phlip2005@gmail.com>:
> Travis D Warlick Jr wrote:
>
> > ALTER TABLE tablename TYPE=HEAP;

>
> Ain't that ENGINE=HEAP?
>
>
> Gaspard Bucher wrote:
>
> > HEAP does not support TEXT columns... Too bad.

>
> Suppose one wrote a rake task db:heap_mode, to switch the test environment
> DB to the faster system. Could that task programmatically access schema.rb,
> find the TEXT columns, and downgrade them to long strings?
>
> --
> Phlip
> http://www.oreilly.com/catalog/9780596510657/
> "Test Driven Ajax (on Rails)"
> assert_xpath, assert_javascript, & assert_ajax
>
>
>


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 05h24.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,17720 seconds with 18 queries