summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjasplin <qt-info@nokia.com>2011-03-29 17:22:02 +0200
committerjasplin <qt-info@nokia.com>2011-03-29 17:22:02 +0200
commit9e7061ffb1f9cd8ecbe3bb118a7f7c74a3336199 (patch)
treeac3dab573edfe5f5b9fd80df667bedd872f76e37
parente913546f11a33555b7148e4280145fc48609e7b7 (diff)
Update a 'testable snapshots' file on each upload.
This patch causes the upload script to update a a 'testable snapshots' file (located at qt@gitestr.nokia.troll.no:bmtestable/bmtestable.xml) each time a new set of results is successfully uploaded to the database. This file indicates the most recent tested snapshot (SHA-1) in each branch. The file can be inspected by external testers (like Tieto) to ensure they test a subset of the snapshots tested locally. This property can be important for certain analyses.
-rwxr-xr-xscripts/uploadresults.py86
1 files changed, 85 insertions, 1 deletions
diff --git a/scripts/uploadresults.py b/scripts/uploadresults.py
index 3fd38a8..045e787 100755
--- a/scripts/uploadresults.py
+++ b/scripts/uploadresults.py
@@ -2,7 +2,7 @@
import sys
from subprocess import Popen, PIPE
-from xml.dom.minidom import parse
+from xml.dom.minidom import parse, getDOMImplementation
from dbaccess import setDatabase, execQuery, commit
from misc import (
getOptions, textToId, idToText, isValidSHA1, getContext, getAllSnapshots)
@@ -333,6 +333,78 @@ def execComputeRankings(options, new_context):
sys.stdout.write(" stdout: >" + stdout.strip() + "<\n")
sys.stdout.write(" stderr: >" + stderr.strip() + "<\n")
+
+# Executes an external command. Exits program upon failure.
+def runCommand(cmd):
+ p = Popen(cmd, stdout = PIPE, stderr = PIPE)
+ stdout, stderr = p.communicate()
+ if (p.returncode != 0):
+ print "\nfailed to run command", cmd
+ print " return code:", p.returncode
+ print " stdout: >%s<" % stdout.strip()
+ print " stderr: >%s<" % stderr.strip()
+ print "exiting ..."
+ sys.exit(1)
+
+
+def updateTestableSnapshotsFile():
+
+ # --- BEGIN create XML structure ---
+ impl = getDOMImplementation()
+ doc = impl.createDocument(None, "branches", None)
+ branches_elem = doc.documentElement
+
+ # Loop over branches:
+ branch_ids = execQuery("SELECT DISTINCT branchId FROM context", ())
+ for branch_id in zip(*branch_ids)[0]:
+ # Get the latest snapshot for this branch:
+ sha1_id = execQuery(
+ "SELECT sha1Id FROM context WHERE branchId = %s"
+ " ORDER BY timestamp DESC LIMIT 1",
+ (branch_id,))[0][0]
+
+ # Create 'branch' element:
+ branch_elem = doc.createElement("branch")
+ branch_elem.setAttribute("name", idToText("branch", branch_id))
+ branch_elem.setAttribute("sha1", idToText("sha1", sha1_id))
+ branches_elem.appendChild(branch_elem)
+
+ # Loop over contexts matching this branch/snapshot combination:
+ contexts = execQuery(
+ "SELECT id, hostId, platformId FROM context"
+ " WHERE branchId = %s AND sha1Id = %s",
+ (branch_id, sha1_id))
+ for context_id, host_id, platform_id in contexts:
+ uploads = execQuery(
+ "SELECT count(DISTINCT uploadId) FROM result"
+ " WHERE contextId = %s",
+ (context_id,))[0][0]
+
+ # Create 'testsystem' element:
+ testsystem_elem = doc.createElement("testsystem")
+ testsystem_elem.setAttribute("host", idToText("host", host_id))
+ testsystem_elem.setAttribute(
+ "platform", idToText("platform", platform_id))
+ testsystem_elem.setAttribute("uploads", str(uploads))
+ branch_elem.appendChild(testsystem_elem)
+ # --- END create XML structure ---
+
+
+ # Dump XML structure to file in tiny repo on gitestr:
+ f = open('/tmp/bmtestable.xml', 'w')
+ f.write(doc.toprettyxml(indent=' '))
+ f.close()
+ runCommand(
+ ["scp", "/tmp/bmtestable.xml",
+ "qt@gitestr.nokia.troll.no:bmtestable/bmtestable.xml"])
+ runCommand(["rm", "/tmp/bmtestable.xml"])
+
+ # Add new revision:
+ runCommand(
+ ["ssh", "qt@gitestr.nokia.troll.no",
+ "cd bmtestable", "git commit -a -m update"])
+
+
# --- END Global functions ----------------------------------------------
@@ -437,6 +509,18 @@ else:
sys.stdout.write("UPLOADING RESULTS DONE\n")
+
+
+# Update the 'testable snapshots' file for external testers to ensure that they
+# test a subset of the snapshots that we test locally:
+if options["db"] == "bm": # this is only supported for the 'bm' database
+ sys.stdout.write(
+ "updating 'testable snapshots' file for external testers ...")
+ sys.stdout.flush()
+ updateTestableSnapshotsFile()
+ sys.stdout.write("done\n")
+
+
sys.exit(0)
# --- END Main program ----------------------------------------------