by
Anthony Vallone
This is the third in a series of
articles about our work environment. See the first and second.I will never forget the awe I felt when
running my first load test on my first project at Google. At previous companies
I’ve worked, running a substantial load test took quite a bit of resource
planning and preparation. At Google, I wrote less than 100 lines of code and was
simulating tens of thousands of users after just minutes of prep work. The ease
with which I was able to accomplish this is due to the impressive coding,
building, and testing tools available at Google. In this article, I will discuss
these tools and how they affect our test and development
process.
Coding and building The
tools and process for coding and building make it very easy to change production
and test code. Even though we are a large company, we have managed to remain
nimble. In a matter of minutes or hours, you can edit, test, review, and submit
code to head. We have achieved this without sacrificing code quality by heavily
investing in tools, testing, and infrastructure, and by prioritizing code
reviews.
Most production and test code is in a single, company-wide
source control repository (open source projects like Chromium and Android have
their own). There is a great deal of code sharing in the codebase, and this
provides an incredible suite of code to build on. Most code is also in a single
branch, so the majority of development is done at head. All code is also
navigable, searchable, and editable from the browser. You’ll find code in
numerous languages, but Java, C++, Python, Go, and JavaScript are the most
common.
Have a strong preference for editor? Engineers are free to
choose from many IDEs and editors. The most common are Eclipse, Emacs, Vim, and
IntelliJ, but many others are used as well. Engineers that are passionate about
their prefered editors have built up and shared some truly impressive editor
plugins/tooling over the years.
Code reviews for all submissions
are enforced via source control tooling. This also applies to test code, as our
test code is held to the same standards as production code. The reviews are done
via web-based code review tools that even include automatically generated test
results. The process is very streamlined and efficient. Engineers can change and
submit code in any part of the repository, but it must get reviewed by owners of
the code being changed. This is great, because you can easily change code that
your team depends on, rather than merely request a change to code you do not
own.
The
Google build system is used for building most code, and
it is designed to work across many languages and platforms. It is remarkably
simple to define and build targets. You won’t be needing that old Makefile
book.
Running jobs and tests We have
some pretty amazing machine and job management tools at Google. There is a
generally available pool of machines in many data centers around the globe. The
job management service makes it very easy to start jobs on arbitrary machines in
any of these data centers. Failing machines are automatically removed from the
pool, so tests rarely fail due to machine issues. With a little effort, you can
also set up monitoring and pager alerting for your important
jobs.
From any machine you can spin up a massive number of tests
and run them in parallel across many machines in the pool, via a single command.
Each of these tests are run in a standard, isolated environment, so we rarely
run into the “it works on my machine!” issue.
Before code is
submitted,
presubmit tests can be run that will find all tests
that depend transitively on the change and run them. You can also define
presubmit rules that run checks on a code change and verify that tests were run
before allowing submission.
Once you’ve submitted test code, the
build and test system automatically registers the test, and starts
building/testing continuously. If the test starts failing, your team will get
notification emails. You can also visit a test dashboard for your team and get
details about test runs and test data. Monitoring the build/test status is made
even easier with our build orbs designed and built by Googlers. These small
devices will glow red if the build starts failing. Many teams have had fun
customizing these orbs to various shapes, including a statue of liberty with a
glowing torch.