Skip to content

Instantly share code, notes, and snippets.

@cbednarski
Last active October 8, 2015 22:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cbednarski/be7f677a2ba96209c431 to your computer and use it in GitHub Desktop.
Save cbednarski/be7f677a2ba96209c431 to your computer and use it in GitHub Desktop.
Script to rerun a test to catch a race condition
import re
import subprocess
import os
small_before_re = re.compile("(\w+) /tmp/small")
big_before_re = re.compile("(\w+) /tmp/big")
small_after_re = re.compile("(\w+) small")
big_after_re = re.compile("(\w+) big")
os.putenv("PACKER_LOG", "1")
while True:
output = subprocess.check_output(["packer", "build", "docker-download.json"], stderr=subprocess.STDOUT)
small_before = small_before_re.findall(output)[0]
big_before = big_before_re.findall(output)[0]
small_after = small_after_re.findall(output)[0]
big_after = big_after_re.findall(output)[0]
print "small {0} {1}".format(small_before, small_after)
print "big {0} {1}".format(big_before, big_after)
if small_before != small_after:
print output
exit(1)
if big_before != big_after:
print output
exit(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment