automation: initial support for running Linux tests

Authored by indygreg.


automation: initial support for running Linux tests

Building on top of our Windows automation support, this commit
implements support for performing automated tasks on remote Linux
machines. Specifically, we implement support for running tests
on ephemeral EC2 instances. This seems to be a worthwhile place
to start, as building packages on Linux is more or less a solved
problem because we already have facilities for building in Docker
containers, which provide "good enough" reproducibility guarantees.

The new run-tests-linux command works similarly to
run-tests-windows: it ensures an AMI with hg dependencies is
available, provisions a temporary EC2 instance with this AMI, pushes
local changes to that instance via SSH, then invokes

Using this new command, I am able to run the entire test harness
substantially faster then I am on my local machine courtesy of
access to massive core EC2 instances:

wall: 16:20 ./ -l (i7-6700K)
wall: 14:00 run-tests-linux --ec2-instance c5.2xlarge
wall: 8:30 run-tests-linux --ec2-instance m5.4xlarge
wall: 8:04 run-tests-linux --ec2-instance c5.4xlarge
wall: 4:30 run-tests-linux --ec2-instance c5.9xlarge
wall: 3:57 run-tests-linux --ec2-instance m5.12xlarge
wall: 3:05 run-tests-linux --ec2-instance m5.24xlarge
wall: 3:02 run-tests-linux --ec2-instance c5.18xlarge

~3 minute wall time to run pretty much the entire test harness is
not too bad!

The AMIs install multiple versions of Python. And the run-tests-linux
command specifies which one to use: run-tests-linux --python system3 run-tests-linux --python 3.5 run-tests-linux --python pypy2.7

By default, the system Python 2.7 is used. Using this functionality,
I was able to identity some unexpected test failures on PyPy!

Included in the feature is support for running with alternate
filesystems. You can simply pass --filesystem to the command to
specify the type of filesystem to run tests on. When the ephemeral
instance is started, a new filesystem will be created and tests
will run from it:

wall: 4:30 run-tests-linux --ec2-instance c5.9xlarge
wall: 4:20 run-tests-linux --ec2-instance c5d.9xlarge --filesystem xfs
wall: 4:24 run-tests-linux --ec2-instance c5d.9xlarge --filesystem tmpfs
wall: 4:26 run-tests-linux --ec2-instance c5d.9xlarge --filesystem ext4

We also support multiple Linux distributions:

$ run-tests-linux --distro debian9
total time: 298.1s; setup: 60.7s; tests: 237.5s; setup overhead: 20.4%

$ run-tests-linux --distro ubuntu18.04
total time: 286.1s; setup: 61.3s; tests: 224.7s; setup overhead: 21.4%

$ run-tests-linux --distro ubuntu18.10
total time: 278.5s; setup: 58.2s; tests: 220.3s; setup overhead: 20.9%

$ run-tests-linux --distro ubuntu19.04
total time: 265.8s; setup: 42.5s; tests: 223.3s; setup overhead: 16.0%

Debian and Ubuntu are supported because those are what I use and am
most familiar with. It should be easy enough to add support for other

Unlike the Windows AMIs, Linux EC2 instances bill per second. So
the cost to instantiating an ephemeral instance isn't as severe.
That being said, there is some overhead, as it takes several dozen
seconds for the instance to boot, push local changes, and build
Mercurial. During this time, the instance is largely CPU idle and
wasting money. Even with this inefficiency, running tests is
relatively cheap: $0.15-$0.25 per full test run. A machine running
tests as efficiently as these EC2 instances would cost say $6,000, so
you can run the test harness a >20,000 times for the cost of an
equivalent machine. Running tests in EC2 is almost certainly cheaper
than buying a beefy machine for developers to use :)

no-check-commit because foo_bar function names

Differential Revision:


indygregSat, Apr 27, 2:48 PM
Differential Revision
D6319: automation: initial support for running Linux tests
rHG195dcc10b3d7: automation: move image operations to own functions