[SCM] build.samba.org - branch master updated

Jelmer Vernooij jelmer at samba.org
Wed Nov 17 02:27:24 MST 2010


The branch, master has been updated
       via  20c6f90 Fix age handling.
      from  7d445b7 Fix tree argument to storm get_last_builds.

http://gitweb.samba.org/?p=build-farm.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 20c6f90f3c3df367d0da520e2aa54f293ee705b8
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Wed Nov 17 10:26:07 2010 +0100

    Fix age handling.

-----------------------------------------------------------------------

Summary of changes:
 buildfarm/data.py            |   17 ++++-------------
 buildfarm/filecache.py       |    1 -
 buildfarm/sqldb.py           |    2 +-
 buildfarm/tests/test_data.py |   10 +---------
 buildfarm/web/__init__.py    |   14 ++++----------
 5 files changed, 10 insertions(+), 34 deletions(-)


Changeset truncated at 500 lines:

diff --git a/buildfarm/data.py b/buildfarm/data.py
index 2ef40b0..3846e8b 100644
--- a/buildfarm/data.py
+++ b/buildfarm/data.py
@@ -233,18 +233,9 @@ class Build(object):
     def remove(self):
         self.remove_logs()
 
-    ###################
-    # the mtime age is used to determine if builds are still happening
-    # on a host.
-    # the ctime age is used to determine when the last real build happened
-
-    def age_mtime(self):
-        """get the age of build from mtime"""
-        st = os.stat("%s.log" % self.basename)
-        return time.time() - st.st_mtime
-
-    def age_ctime(self):
-        """get the age of build from ctime"""
+    @property
+    def age(self):
+        """get the age of build"""
         st = os.stat("%s.log" % self.basename)
         return time.time() - st.st_ctime
 
@@ -401,7 +392,7 @@ class BuildResultStore(object):
                     continue
                 ret.append(self.get_build(tree, host, compiler, rev))
 
-        ret.sort(lambda a, b: cmp(a.age_mtime(), b.age_mtime()))
+        ret.sort(lambda a, b: cmp(a.age, b.age))
 
         return ret
 
diff --git a/buildfarm/filecache.py b/buildfarm/filecache.py
index bd15d5f..0e0823d 100644
--- a/buildfarm/filecache.py
+++ b/buildfarm/filecache.py
@@ -24,7 +24,6 @@ from buildfarm import (
 from buildfarm.data import (
     Build,
     BuildResultStore,
-    BuildStageResult,
     BuildStatus,
     NoSuchBuildError,
     UploadBuildResultStore,
diff --git a/buildfarm/sqldb.py b/buildfarm/sqldb.py
index 00b150f..304faa1 100644
--- a/buildfarm/sqldb.py
+++ b/buildfarm/sqldb.py
@@ -203,7 +203,7 @@ class StormCachingBuildResultStore(BuildResultStore):
         new_build = StormBuild(new_basename, unicode(build.tree), unicode(build.host),
             unicode(build.compiler), rev)
         new_build.checksum = build.log_checksum()
-        new_build.age = build.age_mtime()
+        new_build.age = build.age
         new_build.status_str = unicode(build.status().__serialize__())
         self.store.add(new_build)
         return new_build
diff --git a/buildfarm/tests/test_data.py b/buildfarm/tests/test_data.py
index c96b266..87e8dc9 100755
--- a/buildfarm/tests/test_data.py
+++ b/buildfarm/tests/test_data.py
@@ -52,14 +52,6 @@ class BuildResultStoreTestBase(object):
         build = self.x.get_build("tdb", "charis", "cc", "12")
         self.assertEquals("<%s: revision 12 of tdb on charis using cc>" % build.__class__.__name__, repr(build))
 
-    def test_build_age_mtime(self):
-        path = self.create_mock_logfile("tdb", "charis", "cc", "12")
-        # Set mtime to something in the past
-        os.utime(path, (time.time(), time.time() - 990))
-        build = self.x.get_build("tdb", "charis", "cc", "12")
-        age = build.age_mtime()
-        self.assertTrue(age >= 990 and age <= 1000, "age was %d" % age)
-
     def test_get_build_nonexistant(self):
         self.assertRaises(data.NoSuchBuildError, self.x.get_build, "tdb",
             "charis", "cc", "12")
@@ -68,7 +60,7 @@ class BuildResultStoreTestBase(object):
         path = self.create_mock_logfile("tdb", "charis", "cc", "12")
         # Set mtime to something in the past
         build = self.x.get_build("tdb", "charis", "cc", "12")
-        age = build.age_ctime()
+        age = build.age
         self.assertTrue(age >= 0 and age <= 10, "age was %d" % age)
 
     def test_read_log(self):
diff --git a/buildfarm/web/__init__.py b/buildfarm/web/__init__.py
index 5c771c3..7a2bf2a 100755
--- a/buildfarm/web/__init__.py
+++ b/buildfarm/web/__init__.py
@@ -487,7 +487,6 @@ class ViewBuildPage(BuildFarmPage):
         cflags = ""
         config = ""
         build = self.buildfarm.get_build(tree, host, compiler, rev)
-        age_mtime = build.age_mtime()
         try:
             (revision, revision_time) = build.revision_details()
         except data.MissingRevisionInfo:
@@ -537,7 +536,7 @@ class ViewBuildPage(BuildFarmPage):
         yield "<tr><td>Uname:</td><td>%s</td></tr>\n" % uname
         yield "<tr><td>Tree:</td><td>%s</td></tr>\n" % self.tree_link(myself, tree)
         yield "<tr><td>Build Revision:</td><td>%s</td></tr>\n" % revision_link(myself, revision, tree)
-        yield "<tr><td>Build age:</td><td><div class='age'>%s</div></td></tr>\n" % self.red_age(age_mtime)
+        yield "<tr><td>Build age:</td><td><div class='age'>%s</div></td></tr>\n" % self.red_age(build.age)
         yield "<tr><td>Status:</td><td>%s</td></tr>\n" % status
         yield "<tr><td>Compiler:</td><td>%s</td></tr>\n" % compiler
         yield "<tr><td>CFLAGS:</td><td>%s</td></tr>\n" % cflags
@@ -615,15 +614,13 @@ class ViewRecentBuildsPage(BuildFarmPage):
         for build in self.buildfarm.get_last_builds(tree=tree):
             host = self.buildfarm.hostdb.host(build.host)
             status = build_status_html(myself, build)
-            age_mtime = build.age_mtime()
-            age_ctime = build.age_ctime()
             try:
                 (revision, revision_time) = build.revision_details()
             except data.MissingRevisionInfo:
                 pass
             else:
                 all_builds.append([
-                    age_ctime,
+                    build.age,
                     host.platform.encode("utf-8"),
                     "<a href='%s?function=View+Host;host=%s;tree=%s;compiler=%s#%s'>%s</a>"
                         % (myself, host.name.encode("utf-8"),
@@ -682,14 +679,12 @@ class ViewHostPage(BuildFarmPage):
             (revision, revision_time) = build.revision_details()
         except data.MissingRevisionInfo:
             revision = None
-        age_mtime = build.age_mtime()
-        age_ctime = build.age_ctime()
         warnings = build.err_count()
         status = build_status_html(myself, build)
         yield "<tr>"
         yield "<td><span class='tree'>" + self.tree_link(myself, build.tree) +"</span>/" + build.compiler + "</td>"
         yield "<td>" + revision_link(myself, revision, build.tree) + "</td>"
-        yield "<td><div class='age'>" + self.red_age(age_mtime) + "</div></td>"
+        yield "<td><div class='age'>" + self.red_age(build.age) + "</div></td>"
         yield "<td><div class='status'>%s</div></td>" % status
         yield "<td>%s</td>" % warnings
         yield "</tr>"
@@ -735,7 +730,7 @@ class ViewHostPage(BuildFarmPage):
                 for build in builds:
                     yield "%-12s %-10s %-10s %-10s %-10s\n" % (
                             build.tree.encode("utf-8"), build.compiler.encode("utf-8"),
-                            util.dhm_time(build.age_mtime()),
+                            util.dhm_time(build.age),
                             str(build.status()), build.err_count())
                 yield "\n"
 
@@ -783,7 +778,6 @@ class ViewSummaryPage(BuildFarmPage):
         builds = self.buildfarm.get_last_builds()
 
         for build in builds:
-            age_mtime = build.age_mtime()
             host_count[build.tree]+=1
             status = build.status()
 


-- 
build.samba.org


More information about the samba-cvs mailing list