2 # Copyright (C) 2012 Google Inc. All rights reserved.
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are
8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above
11 # copyright notice, this list of conditions and the following disclaimer
12 # in the documentation and/or other materials provided with the
14 # * Neither the name of Google Inc. nor the names of its
15 # contributors may be used to endorse or promote products derived from
16 # this software without specific prior written permission.
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 from google.appengine.ext import db
36 class NumericIdHolder(db.Model):
37 owner = db.ReferenceProperty()
38 # Dummy class whose sole purpose is to generate key().id()
41 def createInTransactionWithNumericIdHolder(callback):
42 idHolder = NumericIdHolder()
44 idHolder = NumericIdHolder.get(idHolder.key())
45 owner = db.run_in_transaction(callback, idHolder.key().id())
47 idHolder.owner = owner
53 def deleteModelWithNumericIdHolder(model):
54 idHolder = NumericIdHolder.get_by_id(model.id)
59 def modelFromNumericId(id, expectedKind):
60 idHolder = NumericIdHolder.get_by_id(id)
61 return idHolder.owner if idHolder and idHolder.owner and isinstance(idHolder.owner, expectedKind) else None
64 class Branch(db.Model):
65 id = db.IntegerProperty(required=True)
66 name = db.StringProperty(required=True)
69 class Platform(db.Model):
70 id = db.IntegerProperty(required=True)
71 name = db.StringProperty(required=True)
74 class Builder(db.Model):
75 name = db.StringProperty(required=True)
76 password = db.StringProperty(required=True)
78 def authenticate(self, rawPassword):
79 return self.password == hashlib.sha256(rawPassword).hexdigest()
82 def hashedPassword(rawPassword):
83 return hashlib.sha256(rawPassword).hexdigest()
86 class Build(db.Model):
87 branch = db.ReferenceProperty(Branch, required=True, collection_name='build_branch')
88 platform = db.ReferenceProperty(Platform, required=True, collection_name='build_platform')
89 builder = db.ReferenceProperty(Builder, required=True, collection_name='builder_key')
90 buildNumber = db.IntegerProperty(required=True)
91 revision = db.IntegerProperty(required=True)
92 timestamp = db.DateTimeProperty(required=True)
95 # Used to generate TestMap in the manifest efficiently
97 id = db.IntegerProperty(required=True)
98 name = db.StringProperty(required=True)
99 branches = db.ListProperty(db.Key)
100 platforms = db.ListProperty(db.Key)
103 def cacheKey(testId, branchId, platformId):
104 return 'runs:%d,%d,%d' % (testId, branchId, platformId)
107 class TestResult(db.Model):
108 name = db.StringProperty(required=True)
109 build = db.ReferenceProperty(Build, required=True)
110 value = db.FloatProperty(required=True)
111 valueMedian = db.FloatProperty()
112 valueStdev = db.FloatProperty()
113 valueMin = db.FloatProperty()
114 valueMax = db.FloatProperty()
117 # Temporarily log reports sent by bots
118 class ReportLog(db.Model):
119 timestamp = db.DateTimeProperty(required=True)
120 headers = db.TextProperty()
121 payload = db.TextProperty()