Pivotal Labs

Main menu

Skip to primary content
Skip to secondary content
  • About
  • Case Studies
  • Team
    • Executives
    • Locations
      • San Francisco (HQ)
      • Boston
      • Boulder
      • Denver
      • London
      • Los Angeles
      • New York
  • Community
    • Blogs
    • Tech Talks
    • Events
  • Careers
    • Lifestyle
    • Principles & Practices
    • Benefits
    • FAQ
    • Apply
  • Contact
    • Press Room
    • Press Releases
    • In The News
    • Press Kit
  • All
  • Labs
  • Standup
  • Tracker

Monthly Archives: March 2011

Will Read

Standup 3.18.2011: Rails Bridge

Will Read
Friday, March 18, 2011

Interesting Things

  • Rails Bridge is hosting an event here at Pivotal Labs to teach people how to develop Rails applications (including TDD and source control!). The students are designers, bootstrapping startups and those who are just curious. THIS EVENT NEEDS VOLUNTEERS! Come teach their well-laid out lesson plan, OR if you’re not up for teaching, come and help out with the install-fest Friday night. The dates are March 25th for the install-fest and March 26 for the actual class.
    Here’s the deets on Meetup
    Here’s the volunteer page
  • 0 Shares
  • Share on Facebook
  • Share on Twitter
JT Archie

Standup 3.17.2011 — will_paginate render and devise testing

JT Archie
Thursday, March 17, 2011

Help

How do I test a custom will_paginate renderer?

If using RSpec, test the custom render in a helper spec by using helper.will_paginate and the options you need to test your rendering settings.

When testing with Devise, my custom Devise views are not loading in the specs, instead Devise’s default views are. Why?

Interesting Things

  • When using Devise in integration test, users were logged in when they shouldn’t have been. The culprit was that in the integration test there was before block that logged a user in and in the same scope a pending test. The logged in user was never officially logged in, so later in the test suite a view that did not require login had a logged in user. Be careful how you log in users and clean your session!
  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Pivotal Labs

NYC Standup 2: Fun with sed and git

Pivotal Labs
Thursday, March 17, 2011

Helps

“Showing multiple errors on a field in Rails?”

Often you’ll have multiple validations on a field, for example, ensuring a date is present and also that it is in the right range. If you don’t want to just render the array of errors, one way to go is to create fancier errors using custom validators that will be easier to parse and play with in your view than a bunch of concatenated strings.

“Cross browser testing in the cloud?”

A pivot (who will remain unnamed) wishes to view a webpage on various browser configurations, for example, IE6, in the “cloud.” Pivotal humans suggest Browser Shots.

Interesting Things

“Careful with your command line…”

Careful with your usage of commands like
find . -type f | xargs your_favorite_command
in projects with a git repo. Pretty sure you (I) didn’t mean to do a global search replace inside of the
.git/
directory.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Dan Podsedly

TrackerBot: Pivotal Tracker on your iPad/iPhone

Dan Podsedly
Wednesday, March 16, 2011

TrackerBot, from Vulpine Labs, is a great new app that brings Pivotal Tracker to your iPad and/or iPhone, complete with multi-touch, drag and drop, and off-line support. It’s available now in the app store.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Pivotal Labs

Visiting Pivotal Labs in Boulder, CO

Pivotal Labs
Wednesday, March 16, 2011

I recently had the opportunity to visit Boulder, CO (Wiki, Map). The reason for my visit was to visit the Pivotal Labs office and spend a day pairing with them.

One of the cool/interesting features of the Pivotal office is that the company provides breakfast in the morning. I walked into the office to find two quiches, pears, strawberries, Orange Juice, Milk, Coffee and several choices of breakfast cereal.

The day started out with a standup. We then split off into pairs and worked on our respective projects. It was interesting to be thrown into the fire and within a half hour I was working on a large, well known website, implementing features that are now live on that site.

We split for lunch around 11:30. After lunch we switched pairs and I worked on a different portion of the code. Pivotal has a strong TDD/BDD approach to coding. We wrote tests that failed, then wrote the code to make them pass. After all the tests passed, we refactored. This is what Rails development is supposed to be.

The afternoon/evening was rounded out with a team retrospective meeting. After the meeting, the office all joined in for a game of StarCraft II.

I thought my interview/pairing day went really well, and I’m happy to say that I’m moving to Boulder to start working for Pivotal Labs March 14th.

Here’s some pics:

The Snow was falling as I arrived at Denver International Airport


The Pivotal office has a full size, full time ping-pong table


This is the view from the office.


The spotting scope is from a Russian Destroyer. One of the Pivots said during the summer you can see mountain climbers climbing the distant mountains. The large grill is for hosting summer parties.


This is from across the street. Pivotal Labs is on the second floor. Ted’s is an easy lunch.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Will Read

Standup 3.16.2011: Autosave Inheritance, Margins, and Logging (the LumberJack way)

Will Read
Wednesday, March 16, 2011

Ask for Help

“How do I show the 80 character line guide in RubyMine?”

Search your RM preferences, it’s in there.

Interesting Things

  • Autosave doesn’t work when you have a has_many :through relationship in your model. The POST gets rewritten as a PUT and doesn’t work as expected. See an example here.

  • Got multiple log files? Want to join those log entries across a specific request? LumberJack is for you! It adds metadata to each log – things like:

    • severity – The severity recorded for the message.
    • time – The time at which the message was recorded.
    • program name – The name of the program logging the message. This can be either set for all messages or customized with each message.
    • process id – The process id (pid) of the process that logged the message.
    • unit of work id – The unique 12 byte hexadecimal number generated for a unit of work.
  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Service-Oriented Design in Practice

Tuesday, March 15, 2011

Bryan Helmkamp talks about practical service-oriented design.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Danny Burkes

Standup 3/10/2011

Danny Burkes
Monday, March 14, 2011

Interesting

RSpec 2.5, Capybara, and Selenium

Capybara, Selenium, and RSpec’s request specs play nicely together, and you can even run tests that require javascript, using the :js => true option.

However, doing do requires the very latest Capybara, so be sure to specify the :git option in your Gemfile.

Ryan Bates has done an excellent RailsCasts episode on just this.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Alexander Murmann

Resque Heroku Autoscaler Gem

Alexander Murmann
Saturday, March 12, 2011

For my side project I needed some worker processes. My project is hosted on Heroku which makes it really easy to add workers. However, currently I am the only user of that project and don’t need a worker to be running all the time. Automatically scaling the workers up when there are pending Resque jobs and scaling them back down once all the work is done seemed like to be the obvious solution to this. Googling immediately brought up a good blog post by Daniel Huckstep. As good as that solution looks, I don’t like to have untested copy-and-paste code in my project. So I decided to test drive my own solution and put it into a convenient gem which of course can be found on Github as well.

Setup

In order for the scaling to work Resque Heroku Atoscaler (RHA) needs to know your Heroku app’s name, your Heroku user name and your Heroku password. Per default those are being read from the following environment variables:

  • HEROKU_APP
  • HEROKU_USER
  • HEROKU_PASS

If you prefer you also can configure RHA using a config block. For example you might put the following into config/initialiazers/resque_heroku_autoscaler_setup.config

require 'resque/plugins/resque_heroku_autoscaler'

Resque::Plugins::HerokuAutoscaler.config do |c|
  c.heroku_user = 'john doe'
  c.heroku_pass = ENV['HEROKU_PASSWORD']
  c.heroku_app  = "my_app_#{Rails.env}"
end

To use RHA in one of your jobs, just extend your job class with Resque::Plugins::HerokuAutoscaler.

For example:

require 'resque/plugins/resque_heroku_autoscaler'

class TestJob
  extend Resque::Plugins::HerokuAutoscaler

  @queue = :test

  def perform
   ...awesome stuff...
  end
end

When you add the job to your Resque queue, a new worker will be started if there isn’t already one. If all jobs in the queue are processed the worker will be stopped again, keeping your costs low.

Changing Scaling Behavior

Per default RHA will only start a single worker, no matter how many jobs are pending. You can change this behavior in the config block as well:

require 'resque/plugins/resque_heroku_autoscaler'

Resque::Plugins::HerokuAutoscaler.config do |c|
  c.new_worker_count do |pending|
    (pending/5).ceil.to_i
  end
end

When calculating the new number of required workers the block given to new_worker_count will be called. Thus the example will result in starting one additional worker for every 5 pending jobs.

Please let me know if you run into any problems with the gem or can think of any features that might be helpful.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Matthew Kocher

Chef Solo – Tugging on the bootstraps

Matthew Kocher
Thursday, March 10, 2011

There’s certainly no wrong way to run chef, however, a reasonable set of defaults are usually helpful as a starting place. I’m building an example of a simple deploy with chef, with the goals of ending up with something that’s easy to understand, copy and modify. Eventually, I hope this allows for discussion of and iteration on what a solid ruby app stack should include.

The first stumbling block with chef for most people is not usually building am ami. It’s usually getting chef and their recipes runningon a box. At Pivotal we’re firm believers in doing the simplest thing that could possibly work, and so what follows is the just least I could do to cleanly run chef. Essentially, you want to install the ruby prerequisites, install a known Ruby (let Wayne figure out how), install chef, get some cookbooks on the box and run chef. This boils down to a script written in Bash to get you to the point you can run Ruby, and some capistrano tasks to install gems and run chef.

I’ve written Soloist, a gem I use for invoking chef solo easily. The goal is for it to be a thin layer over chef-solo to make it more friendly to use. I’ll use it here, but all it’s doing is generating a solo.rb and node.json files – it’s not magic.

Here are the files I ended up with:

├── Capfile                   <- How we tell cap what to do
├── Gemfile                   <- The three gems we need
├── Gemfile.lock
├── bootstrap.sh          <- The bash script to bootstrap an instance
├── chef
│   └── cookbooks         <- Chef cookbooks go here
│       └── joy_of_cooking
│           └── recipes
│               └── default.rb
├── config
│   └── deploy
│       └── staging.rb        <- What servers are in your environment
└── soloistrc             <- How you'll tell chef what to run

First off we’l start with a bash script. You can see the full thing on github, but the psuedocode is:

as root:
    Create an app user account
    allow password authentication       # adding an Authorized key would be fine too
    add epel as an RPM repository       # for an easy git instal
    install git
    install the rvm prereqs             # readline, zlib, openssl and more
    enable passwordless sudo            # it's the only way to live
as user:
    install rvm
    add rvm to bashrc
    set rvm to trust all rvmrcs, install rubys on use and install gemsets on use

That’s it. My example is 41 lines of bash (including 11 blank and 6 comment lines).

Capistrano is a reasonable multi server SSH tool. Parts of it are fundamentally flawed, but the “ssh out to some servers and run some commands” works just fine. So, we’ll use it to upload and run the bootstrap script:

desc "bootstrap"
task :bootstrap do
  set :user, "root"
  set :default_shell, "/bin/bash"
  upload "bootstrap.sh", "/root/bootstrap.sh"
  run "chmod a+x /root/bootstrap.sh"
  run "/root/bootstrap.sh"
end

The boostrap task sets the user to root because everywhere else the user is set to the app user. We set the shell to /bin/bash to override the use of rvm-shell. We then upload the bootstrap script and run it.

The deploy task consists of:

desc "Deploys"
task :deploy do
  install_base_gems
  upload_cookbooks
  run_chef
end

To see the details of each task, see the Capfile. Be aware the first time you deploy, rvm will compile the requested ruby – this will take a few minutes.

This leaves us at 4 lines in the terminal to spin up as many ec2 instances as amazon will let you and run chef on them:

ec2-run-instances ami-e67e8d8f -k mine2 -t m1.large
ec2-describe-instances  # you'll need to add the IP(s) of your
                        # new instance(s) to the staging.rb file
cap staging bootstrap
cap staging deploy

Currently, the chef run consists of a recipe which touches a file in the root directory. For my next trick, I hope to actually run a web app. Stay tuned.

All the source code is available on github.

Lessons learned:

  • Rubyforge will be down when you’d like to to be up.
  • Learning the ec2 shell commands is well worth the time over using the web interface.

Open questions/issues:

  • Is there a good alternative to cap for this use case? This is not something that involves a server process, a web process, CouchDB, RabitMQ, a Solr server and a Solr indexer.
  • Should I switch to using the rvm gem to load the capistrano patching? RVM doesn’t even say it’s possible, but it seems like it would keep the deploy from depending on an untracked local version of rvm.
  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Topics

  • agile (781)
  • rails (113)
  • testing (88)
  • ruby (83)
  • ruby on rails (70)
  • jobs (62)
  • javascript (55)
  • techtalk (44)
  • rspec (38)
  • ironblogger (32)
  • productivity (30)
  • activerecord (29)
  • gogaruco (29)
  • git (28)
  • nyc (27)
  • rubymine (26)
  • bloggerdome (23)
  • mobile (22)
  • process (21)
  • pivotal tracker (21)
  • cucumber (20)
  • design (19)
  • jasmine (19)
  • ios (18)
  • webos (17)
  • objective-c (17)
  • android (16)
  • tracker ecosystem (16)
  • palm (16)
  • "soft" ware (16)
  • fun (15)
  • ci (15)
  • cedar (15)
  • rails3 (14)
  • performance (14)
  • bdd (14)
  • gem (13)
  • css (13)
  • tdd (13)
  • selenium (12)
  • goruco (12)
  • bundler (12)
  • meetup (11)
  • railsconf (11)
  • nyc-standup (11)
  • capybara (10)
  • mac (10)
  • mojo (10)
  • chef (10)
  • api (10)
Subscribe to Community Feed
  1. ←
  2. 1
  3. 2
  4. 3
  5. 4
  6. 5
  7. →
  • About
  • Case Studies
  • Team
  • Community
  • Careers
  • Contact
  • Labs
  • Events

Contact Us

contact@pivotallabs.com
+1 415-77-PIVOT
TwitterLinkedInFacebook

Pivotal Tracker

Tracker is the award-winning agile project management tool that enables real-time collaboration around a shared, prioritized backlog.
Visit pivotaltracker.com >