Permalink
Browse files

Ensure updater creates separate test folders for each revision

Fix getting ip

Use tuple in build_needed
  • Loading branch information...
1 parent fb23d9b commit 0dcde9a21107858ebefc7fcba3fb90d62eb3b211 @ahal committed Jan 25, 2011
Showing with 52 additions and 65 deletions.
  1. +14 −18 runFBTests/execute_fb_tests.py
  2. +2 −2 runFBTests/fb_run.py
  3. +36 −45 runFBTests/fb_update.py
@@ -85,17 +85,17 @@ def clean_temp_folder(self, build=False):
except Exception as e:
print "[Warn] Could not delete temporary files in '" + self.tempdir + "': " + str(e)
- def build_needed(self, build, buildpath):
+ def build_needed(self, version, build, buildpath):
"""
Return True if the tests have never been run against the current changeset of 'build'
Return False otherwise
"""
# Find new changeset
new_changeset = utils.get_changeset(buildpath)
- if not build in self.changeset:
- self.changeset[build] = -1
- if self.changeset[build] != new_changeset:
- self.changeset[build] = new_changeset
+ if not (version, build) in self.changeset:
+ self.changeset[(version, build)] = -1
+ if self.changeset[(version, build)] != new_changeset:
+ self.changeset[(version, build)] = new_changeset
return True
return False
@@ -112,12 +112,8 @@ def prepare_builds(self, version, builds):
"""
Downloads the builds and starts the tests
"""
- # Lookup table mapping Firefox versions to Gecko versions (as specified in Firebug's test-bot.config)
- lookup = { '3.5' : '1.9.1', '3.6' : '1.9.2', '3.7' : 'central', '4.0' : 'central' } # TODO Use Gecko versions in test-bot.config instead of Firefox versions so this isn't necessary
-
# For each version of Firefox, see if there is a new changeset and run the tests
for build in builds:
- build = lookup[build]
print "[Info] Running Firebug" + version + " tests against Mozilla " + build
# Scrape for the latest tinderbox build and extract it to the basedir
@@ -158,7 +154,7 @@ def prepare_builds(self, version, builds):
continue
# If the newest tinderbox changeset is different from the previously run changeset
- if self.build_needed(build, buildPath):
+ if self.build_needed(version, build, buildPath):
if self.platform == "darwin":
self.binary = buildPath
else:
@@ -171,6 +167,7 @@ def prepare_builds(self, version, builds):
# Remove build directories and temp files
self.clean_temp_folder(build)
+ self.testlist = None
return 0
def run(self):
@@ -187,17 +184,16 @@ def run(self):
for section in config.sections():
version = section[-3:]
if not self.version or version == self.version:
- if not self.testlist:
- try:
+ try:
+ if not self.testlist:
self.testlist = config.get("Firebug" + version, "TEST_LIST")
- except Exception as e:
- print "[Error] Malformed config file: " + str(e)
- continue
- if not self.binary:
- builds = config.get("Firebug" + version, "FIREFOX_VERSION").split(",")
+ if not self.binary:
+ builds = config.get("Firebug" + version, "GECKO_VERSION").split(",")
+ except Exception as e:
+ print "[Error] Malformed config file: " + str(e)
+ continue
print "[Info] Starting builds and FBTests for Firebug" + version
-
# Run the build(s)
if not self.binary:
ret = self.prepare_builds(version, builds)
View
@@ -189,9 +189,9 @@ def run(self):
print "[Info] Sending log file to couchdb at '" + self.couchURI + "'"
try:
fb_logs.main(["--log", filename, "--database", self.databasename, "--couch", self.couchURI,
- "--changeset", get_changeset((self.binary if self.platform == "darwin" else os.path.dirname(self.binary)))])
+ "--changeset", utils.get_changeset((self.binary if self.platform == "darwin" else os.path.dirname(self.binary)))])
except Exception as e:
- print "[Error] Log file not sent to couchdb at server: '" + self.couchURI + "' and database: '" + self.databasename + "'"
+ print "[Error] Log file not sent to couchdb at server: '" + self.couchURI + "' and database: '" + self.databasename + "': " + str(e)
# Cleanup
mozrunner.kill_process_by_name("crashreporter" + (".exe" if self.platform == "windows" else ""))
View
@@ -40,43 +40,15 @@
# the fbtests and testlists and store them on the local webserver
from ConfigParser import ConfigParser
from time import sleep
+import fb_utils as utils
import fileinput
import os, sys
import subprocess
import shutil
import optparse
import urllib2
-def retrieve_url(url, filename):
- """
- Save the file located at 'url' into 'filename'
- """
- try:
- ret = urllib2.urlopen(url)
- except:
- return -1
- dir = os.path.dirname(filename)
- if dir and not os.path.exists(dir):
- os.makedirs(dir)
- output = open(filename, 'wb')
- output.write(ret.read())
- output.close()
- return 0
-
-def localizeConfig(configFile):
- # Get server's ip address
- proc = subprocess.Popen("ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'", stdout=subprocess.PIPE)
- ip = proc.communicate()[0]
-
- for line in fileinput.input(configFile, inplace=1):
- if line.find("FIREBUG_XPI") != -1 or line.find("FBTEST_XPI") != -1 or line.find("TEST_LIST") != -1:
- index = line.find("=")
- print line[:index] + "http://" + ip + "/" + getRelativePath(line[index + 1:])
- else:
- print line.rstrip()
-
-
-def getRelativePath(url):
+def getRelativeURL(url):
if (url.find("http://") != -1):
index = url[7:].find("/") + 7
elif (FIREBUG_XPI.find("https://") != -1):
@@ -87,9 +59,13 @@ def getRelativePath(url):
def update(opt):
+ # Get server's ip address
+ proc = subprocess.Popen("ifconfig | grep 'inet addr:' | cut -d: -f2 | grep -v '127.0.0.1' | awk '{ print $1}'", shell=True, stdout=subprocess.PIPE)
+ ip = proc.communicate()[0].rstrip()
+
# Grab the test_bot.config file
configDir = "releases/firebug/test-bot.config"
- retrieve_url("http://getfirebug.com/" + configDir, os.path.join(opt.repo, configDir))
+ utils.download("http://getfirebug.com/" + configDir, os.path.join(opt.repo, configDir))
# Parse the config file
test_bot = ConfigParser()
@@ -104,23 +80,38 @@ def update(opt):
# Update or create the svn test repository
if not os.path.isdir(os.path.join(opt.repo, ".svn")):
- os.system("svn co http://fbug.googlecode.com/svn/tests/ " + os.path.join(opt.repo, "tests") + " -r " + SVN_REVISION)
+ os.system("svn co http://fbug.googlecode.com/svn/tests/ " + os.path.join(opt.repo, SVN_REVISION, "tests") + " -r " + SVN_REVISION)
else:
os.system(os.path.join(opt.repo, "svn") + " update -r " + SVN_REVISION)
# Download the extensions
print FIREBUG_XPI
- relPath = getRelativePath(FIREBUG_XPI)
+ relPath = getRelativeURL(FIREBUG_XPI)
savePath = os.path.join(opt.repo, relPath)
- retrieve_url(FIREBUG_XPI, savePath)
+ utils.download(FIREBUG_XPI, savePath)
print FBTEST_XPI
- relPath = getRelativePath(FBTEST_XPI)
+ relPath = getRelativeURL(FBTEST_XPI)
savePath = os.path.join(opt.repo, relPath)
- retrieve_url(FBTEST_XPI, savePath)
+ utils.download(FBTEST_XPI, savePath)
+
+ # Localize extensions for the server
+ relPath = getRelativeURL(FIREBUG_XPI)
+ FIREBUG_XPI = "http://" + ip + "/" + relPath
+ test_bot.set(section, "FIREBUG_XPI", FIREBUG_XPI)
+
+ relPath = getRelativeURL(FBTEST_XPI)
+ FBTEST_XPI = "http://" + ip + "/" + relPath
+ test_bot.set(section, "FBTEST_XPI", FBTEST_XPI)
+
+ # Localize testlist for the server
+ testlist = test_bot.get(section, "TEST_LIST")
+ relPath = getRelativeURL(testlist)
+ testlist = "http://" + ip + "/" + SVN_REVISION + "/" + relPath
+ test_bot.set(section, "TEST_LIST", testlist)
- test_bot.close()
- localizeConfig(os.path.join(opt.repo, "releases/firebug/test-bot.config"), opt.serverpath)
+ with open(os.path.join(opt.repo, configDir), 'wb') as configfile:
+ test_bot.write(configfile)
# Copy the files to the webserver
os.system("cp -r " + os.path.join(opt.repo, "*") + " " + opt.serverpath)
@@ -145,16 +136,16 @@ def main(argv):
os.mkdir(opt.repo)
while (1):
+ print "[INFO] Updating server extensions and tests"
try:
- print "[INFO] Updating server extensions and tests"
update(opt)
- if opt.waitTime != None:
- print "[INFO] Sleeping for " + str(opt.waitTime) + " hour" + ("s" if int(opt.waitTime) > 1 else "")
- sleep(int(opt.waitTime) * 3600)
- else:
- break;
- except Exception(e):
+ except Exception as e:
print "[Error] Could not update the server files: " + str(e)
+ if opt.waitTime != None:
+ print "[INFO] Sleeping for " + str(opt.waitTime) + " hour" + ("s" if int(opt.waitTime) > 1 else "")
+ sleep(int(opt.waitTime) * 3600)
+ else:
+ break;
if __name__ == '__main__':

0 comments on commit 0dcde9a

Please sign in to comment.