O slideshow foi denunciado.
Seu SlideShare está sendo baixado. ×

Otimizando tempo de build: performance da suíte de testes

Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Carregando em…3
×

Confira estes a seguir

1 de 58 Anúncio

Mais Conteúdo rRelacionado

Quem viu também gostou (20)

Anúncio

Semelhante a Otimizando tempo de build: performance da suíte de testes (20)

Anúncio

Mais recentes (20)

Otimizando tempo de build: performance da suíte de testes

  1. 1. Optimizing build time Performance running tests Jônatas Paganini @jonatasdp
  2. 2. test suite
  3. 3. RSpec
  4. 4. 12K assertions
  5. 5. ~25’ Build time / 3 machines
  6. 6. >100’ in localhost
  7. 7. MONOLITHIC APP
  8. 8. NOW
  9. 9. ~13’ Build time / 4 machines
  10. 10. ?
  11. 11. Little Changes on factories
  12. 12. girl ?factory
  13. 13. Avoid callbacks Callbacks can be lazy and unuseful running all the time
  14. 14. Model#skip_callback To avoid run the the hook each factory
  15. 15. Coverage?
  16. 16. after(:create) To run it in a specific factory
  17. 17. Profiling Associations
  18. 18. Specializing factories
  19. 19. Specialized factories
  20. 20. Associations Results
  21. 21. Use lazy Associations Associations naturally invokes their own factories.
  22. 22. Avoid factory: for associations Associations naturally invokes their own factories.
  23. 23. association &block
  24. 24. association &block
  25. 25. quick wins
  26. 26. Use build_stubbed Instead of create
  27. 27. hack sign_in Avoid touch database each login
  28. 28. ConfigureRSpec
  29. 29. sign_inbuild_stubbed
  30. 30. Use stub to avoid inflateassociations
  31. 31. build Instead of create
  32. 32. CI Improvements We use CircleCI ● Split specs by context ● Hack postgres.conf ● Postgresql on Memory
  33. 33. Splitspecs by Context
  34. 34. CircleCi divide tests by time NOT context
  35. 35. SplitSpecs by DIRECTORY
  36. 36. postgres.conf
  37. 37. fsync = ’off’
  38. 38. full_page_writes = ’off’
  39. 39. checkpoint_segments = ’100’ checkpoint_timeout = ’45 min’
  40. 40. data_directory = ’/tmp/postgres-on-memory’
  41. 41. dir=/tmp/postgresql-on-memory
  42. 42. dir=/tmp/postgresql-on-memory mkdir $dir
  43. 43. dir=/tmp/postgresql-on-memory mkdir $dir mount -o size=200M,mode=0666 tmpfs $dir
  44. 44. dir=/tmp/postgresql-on-memory mkdir $dir mount -o size=200M,mode=0666 tmpfs $dir chown postgres:postgres $dir
  45. 45. dir=/tmp/postgresql-on-memory mkdir $dir mount -o size=200M,mode=0666 tmpfs $dir chown postgres:postgres $dir sudo su - postgres -c '/usr/lib/postgresql/9.4/bin/initdb --encoding=UTF8 --pgdata=$dir
  46. 46. NEXT LEVEL <what> run <when>
  47. 47. hardcore scenarios Split Specs
  48. 48. Nightly Build
  49. 49. if [ -n "${RUN_NIGHTLY_BUILD}" ]; rspec spec/features --tag "~smoke"
  50. 50. if [ -n "${RUN_NIGHTLY_BUILD}" ]; rspec spec/features --tag "~smoke" if [ -z "${RUN_NIGHTLY_BUILD}" ]; rspec spec/features --tag "smoke"
  51. 51. http://shipit.resultadosdigitais.com.br/blog ● /ruby-e-rspec-melhorando-a-legibilidade-de-seus-testes/ ● /rspec-performance-tips/ ● /otimizando-testes-factory-girl-e-rspec/
  52. 52. Conclusion ● Avoid touch database ● Avoid callbacks no sense ● Avoid things you don’t need ● Write specialized factories ● Rate (classify) your test ● Benchmark all isolated steps It’s all about responsibilities
  53. 53. Thanks! @jonatasdp http://ideia.me http://shipit.resultadosdigitais.com.br

×