# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+from buildfarm.build import BuildStatus
from buildfarm.sqldb import distinct_builds, Cast, StormBuild, setup_schema, StormHostDatabase
from buildfarm.tree import Tree
from storm.database import create_database
return distinct_builds(result.order_by(Desc(StormBuild.upload_time)))
def get_summary_builds(self):
- """returns tree and status to the ViewSummaryPage class"""
+ """Return last build age, status for each tree/host/compiler.
+
+ :return: iterator over tree, status
+ """
store = self._get_store()
- return store.execute("""
-SELECT obd.tree, obd.status AS status_str
+ return ((tree, BuildStatus.__deserialize__(status_str))
+ for (tree, status_str) in store.execute("""
+SELECT obd.tree, obd.status AS status_str
FROM build obd
INNER JOIN(
- SELECT MAX(age) age, tree, host, compiler
- FROM build
- GROUP BY tree, host, compiler
-) ibd ON obd.age = ibd.age AND obd.tree = ibd.tree AND obd.host = ibd.host AND obd.compiler = ibd.compiler;
-""")
+ SELECT MAX(age) age, tree, host, compiler
+ FROM build
+ GROUP BY tree, host, compiler
+) ibd ON obd.age = ibd.age AND
+ obd.tree = ibd.tree AND
+ obd.host = ibd.host AND
+ obd.compiler = ibd.compiler;
+"""))
def get_tree_builds(self, tree):
result = self._get_store().find(StormBuild,
os.link(build.basename+".log", new_basename+".log")
if os.path.exists(build.basename+".err"):
os.link(build.basename+".err", new_basename+".err")
- # They are supposed to be in unicode only but since comparision for sumary page depends on them
- # the unicode conversion is done to avoid duplicates when running query in summary_builds
- new_build = StormBuild(new_basename, unicode(build.tree), unicode(build.host), unicode(build.compiler), rev)
+ new_build = StormBuild(new_basename, build.tree, build.host, build.compiler, rev)
new_build.checksum = build.log_checksum()
new_build.upload_time = build.upload_time
new_build.status_str = build.status().__serialize__()
self.assertEquals("12", builds[1].revision_details())
self.assertEquals("other", builds[1].tree)
+ def test_get_summary_builds_empty(self):
+ self.assertEquals([], list(self.x.get_summary_builds()))
+
+ def test_get_summary_builds(self):
+ path = self.upload_mock_logfile(self.x.builds, "other", "myhost", "cc",
+ "BUILD COMMIT REVISION: 12\n", mtime=1200)
+ path = self.upload_mock_logfile(self.x.builds, "trivial", "myhost", "cc",
+ "BUILD COMMIT REVISION: 13\n", mtime=1300)
+ path = self.upload_mock_logfile(self.x.builds, "trivial", "myhost", "cc",
+ "BUILD COMMIT REVISION: 42\n", mtime=4200)
+ builds = list(self.x.get_summary_builds())
+ self.assertEquals(2, len(builds))
+ self.assertEquals(4200, builds[0].upload_time)
+ self.assertEquals("42", builds[0].revision_details())
+ self.assertEquals("trivial", builds[0].tree)
+ self.assertEquals(1200, builds[1].upload_time)
+ self.assertEquals("12", builds[1].revision_details())
+ self.assertEquals("other", builds[1].tree)
+
def test_get_host_builds_empty(self):
self.assertEquals([], list(self.x.get_host_builds("myhost")))
LogFileMissing,
NoSuchBuildError,
NoTestOutput,
- BuildStatus,
)
import cgi
builds = self.buildfarm.get_summary_builds()
- for tree, status_str in builds:
+ for tree, status in builds:
host_count[tree]+=1
- status = BuildStatus.__deserialize__(status_str)
if status.failed:
broken_count[tree]+=1