Merge lp:~cjohnston/qa-dashboard/smoke-artifact-admin into lp:qa-dashboard

Proposed by Chris Johnston
Status: Superseded
Proposed branch: lp:~cjohnston/qa-dashboard/smoke-artifact-admin
Merge into: lp:qa-dashboard
Diff against target: 262 lines (+155/-1)
7 files modified
common/admin.py (+8/-0)
common/management/__init__.py (+4/-0)
common/migrations/0006_add_artifacts.py (+82/-0)
common/models.py (+11/-0)
smokeng/admin.py (+17/-0)
smokeng/management/commands/jenkins_pull_smokeng.py (+26/-1)
smokeng/models.py (+7/-0)
To merge this branch: bzr merge lp:~cjohnston/qa-dashboard/smoke-artifact-admin
Reviewer Review Type Date Requested Status
QA Dashboard Developers Pending
Review via email: mp+180453@code.launchpad.net

Commit message

Adds a smoke only artifact view in admin

To post a comment you must log in.

Unmerged revisions

576. By Chris Johnston

Add 'smoke only' artifacts using common.models Artifact

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'common/admin.py'
2--- common/admin.py 2013-08-09 03:20:35 +0000
3+++ common/admin.py 2013-08-16 01:01:50 +0000
4@@ -17,6 +17,7 @@
5 Bug,
6 JenkinsJob,
7 JenkinsBuild,
8+ Artifact,
9 )
10
11 from django.contrib import admin
12@@ -50,6 +51,13 @@
13 ]
14 date_hierarchy = 'ran_at'
15
16+
17+class ArtifactAdmin(admin.ModelAdmin):
18+ list_display = ('name', 'jenkins_build', 'publish')
19+ search_fields = ['name', 'jenkins_build']
20+
21+
22 admin.site.register(Bug, BugAdmin)
23 admin.site.register(JenkinsJob, JenkinsJobAdmin)
24 admin.site.register(JenkinsBuild, JenkinsBuildAdmin)
25+admin.site.register(Artifact, ArtifactAdmin)
26
27=== modified file 'common/management/__init__.py'
28--- common/management/__init__.py 2013-08-02 18:56:36 +0000
29+++ common/management/__init__.py 2013-08-16 01:01:50 +0000
30@@ -327,6 +327,9 @@
31 def _process_logs(self, build, build_date, install_data, func):
32 raise NotImplementedError
33
34+ def process_artifacts(self, build, install_data):
35+ pass
36+
37 def add_result(self):
38 pass
39
40@@ -615,6 +618,7 @@
41 if self.install_data['process_build']:
42 self.add_job_bugs(build)
43 self.process_build(build)
44+ self.process_artifacts(build, self.install_data)
45 self.process_add_result(build)
46 self.post_process_build(build)
47
48
49=== added file 'common/migrations/0006_add_artifacts.py'
50--- common/migrations/0006_add_artifacts.py 1970-01-01 00:00:00 +0000
51+++ common/migrations/0006_add_artifacts.py 2013-08-16 01:01:50 +0000
52@@ -0,0 +1,82 @@
53+# -*- coding: utf-8 -*-
54+import datetime
55+from south.db import db
56+from south.v2 import SchemaMigration
57+from django.db import models
58+
59+
60+class Migration(SchemaMigration):
61+
62+ def forwards(self, orm):
63+ # Adding model 'Artifact'
64+ db.create_table('common_artifacts', (
65+ ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
66+ ('created_at', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
67+ ('updated_at', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, blank=True)),
68+ ('internal', self.gf('django.db.models.fields.BooleanField')(default=True)),
69+ ('publish', self.gf('django.db.models.fields.BooleanField')(default=True)),
70+ ('url', self.gf('django.db.models.fields.URLField')(max_length=200)),
71+ ('name', self.gf('django.db.models.fields.CharField')(max_length=4096)),
72+ ('jenkins_build', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['common.JenkinsBuild'])),
73+ ))
74+ db.send_create_signal('common', ['Artifact'])
75+
76+
77+ def backwards(self, orm):
78+ # Deleting model 'Artifact'
79+ db.delete_table('common_artifacts')
80+
81+
82+ models = {
83+ 'common.artifact': {
84+ 'Meta': {'object_name': 'Artifact', 'db_table': "'common_artifacts'"},
85+ 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
86+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
87+ 'internal': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
88+ 'jenkins_build': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['common.JenkinsBuild']"}),
89+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '4096'}),
90+ 'publish': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
91+ 'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
92+ 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'})
93+ },
94+ 'common.bug': {
95+ 'Meta': {'object_name': 'Bug', 'db_table': "'bugs'"},
96+ 'assignee': ('django.db.models.fields.CharField', [], {'max_length': '4096', 'null': 'True'}),
97+ 'bug_no': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
98+ 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
99+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
100+ 'importance': ('django.db.models.fields.CharField', [], {'default': "u'unknown'", 'max_length': '4096'}),
101+ 'internal': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
102+ 'project': ('django.db.models.fields.CharField', [], {'max_length': '4096', 'null': 'True'}),
103+ 'publish': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
104+ 'status': ('django.db.models.fields.CharField', [], {'default': "u'unknown'", 'max_length': '4096'}),
105+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '4096', 'null': 'True'}),
106+ 'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'})
107+ },
108+ 'common.jenkinsbuild': {
109+ 'Meta': {'unique_together': "(('job', 'build_number'),)", 'object_name': 'JenkinsBuild', 'db_table': "'jenkins_builds'"},
110+ 'bugs': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'build_bugs'", 'symmetrical': 'False', 'to': "orm['common.Bug']"}),
111+ 'build_description': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '1024'}),
112+ 'build_number': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
113+ 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
114+ 'failed': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
115+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
116+ 'internal': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
117+ 'job': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['common.JenkinsJob']"}),
118+ 'publish': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
119+ 'ran_at': ('django.db.models.fields.DateTimeField', [], {}),
120+ 'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'})
121+ },
122+ 'common.jenkinsjob': {
123+ 'Meta': {'object_name': 'JenkinsJob', 'db_table': "'jenkins_jobs'"},
124+ 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
125+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
126+ 'internal': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
127+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '200'}),
128+ 'publish': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
129+ 'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
130+ 'url': ('django.db.models.fields.URLField', [], {'max_length': '200'})
131+ }
132+ }
133+
134+ complete_apps = ['common']
135\ No newline at end of file
136
137=== modified file 'common/models.py'
138--- common/models.py 2013-07-02 21:04:09 +0000
139+++ common/models.py 2013-08-16 01:01:50 +0000
140@@ -150,3 +150,14 @@
141 """ Get number of bugs for this build. """
142
143 return self.bugs.count()
144+
145+
146+class Artifact(DashboardBaseModel):
147+ """ Add artifacts """
148+
149+ class Meta:
150+ db_table = "common_artifacts"
151+
152+ url = models.URLField()
153+ name = models.CharField(max_length=4096)
154+ jenkins_build = models.ForeignKey(JenkinsBuild)
155
156=== modified file 'smokeng/admin.py'
157--- smokeng/admin.py 2013-07-10 16:56:19 +0000
158+++ smokeng/admin.py 2013-08-16 01:01:50 +0000
159@@ -13,11 +13,14 @@
160 # You should have received a copy of the GNU Affero General Public License
161 # along with this program. If not, see <http://www.gnu.org/licenses/>.
162
163+from common.models import Artifact
164+
165 from smokeng.models import (
166 SmokeImage,
167 SmokeResult,
168 SmokeResultBug,
169 SmokeTestResult,
170+ SmokeArtifact,
171 )
172
173 from django.contrib import admin
174@@ -59,7 +62,21 @@
175 list_display = ('result', 'testcase', 'returncode')
176 ordering = ['result']
177
178+
179+class SmokeArtifactAdmin(admin.ModelAdmin):
180+ list_display = ('name', 'jenkins_build', 'publish')
181+ search_fields = ['name', 'jenkins_build']
182+
183+ def queryset(self, request):
184+ results = SmokeResult.objects.all().values('jenkins_build')
185+ builds = []
186+ for result in results:
187+ builds.append(result['jenkins_build'])
188+ artifacts = SmokeArtifact.objects.filter(jenkins_build__in=builds)
189+ return artifacts
190+
191 admin.site.register(SmokeImage, SmokeImageAdmin)
192 admin.site.register(SmokeResult, SmokeResultAdmin)
193 admin.site.register(SmokeResultBug, SmokeResultBugAdmin)
194 admin.site.register(SmokeTestResult, SmokeTestResultAdmin)
195+admin.site.register(SmokeArtifact, SmokeArtifactAdmin)
196
197=== modified file 'smokeng/management/commands/jenkins_pull_smokeng.py'
198--- smokeng/management/commands/jenkins_pull_smokeng.py 2013-08-07 19:05:49 +0000
199+++ smokeng/management/commands/jenkins_pull_smokeng.py 2013-08-16 01:01:50 +0000
200@@ -25,7 +25,7 @@
201
202 from common.utah_parser import UTAHParser, ParserError
203 from common.utils import regexes
204-from common.models import Bug
205+from common.models import Bug, Artifact
206
207 from smokeng.models import (
208 SmokeImage,
209@@ -107,6 +107,31 @@
210 total=total_count,
211 )
212
213+ def process_artifacts(self, build, install_data):
214+ artifact_regex = re.compile(
215+ ur'^(clientlogs\/|)(.*.yaml|.*.log$|media-info|.*.props|.*.crash)'
216+ )
217+ for artifact in build['artifacts']:
218+ path = artifact['relativePath']
219+ if artifact_regex.match(path):
220+ logfile_path = "{}{}/artifact/{}".format(
221+ self.install_data['jenkins_build'].job.url,
222+ self.install_data['jenkins_build'].build_number,
223+ artifact['relativePath'],
224+ )
225+ artifact, new_artifact = Artifact.objects.get_or_create(
226+ url=logfile_path,
227+ name=artifact['fileName'],
228+ jenkins_build=install_data['jenkins_build'],
229+ )
230+
231+ if new_artifact:
232+ logging.info(
233+ "Adding %s for jenkins build %s",
234+ artifact['fileName'],
235+ install_data['jenkins_build'],
236+ )
237+
238 def _process_logs(self, build, build_date, install_data, func):
239
240 if not hasattr(func, '__call__'):
241
242=== modified file 'smokeng/models.py'
243--- smokeng/models.py 2013-07-30 21:05:41 +0000
244+++ smokeng/models.py 2013-08-16 01:01:50 +0000
245@@ -19,6 +19,7 @@
246 DashboardBaseModel,
247 Bug,
248 JenkinsBuild,
249+ Artifact,
250 )
251
252
253@@ -164,3 +165,9 @@
254 returncode = models.IntegerField()
255 stderr = models.TextField(null=True)
256 stdout = models.TextField(null=True)
257+
258+
259+class SmokeArtifact(Artifact):
260+ class Meta:
261+ proxy = True
262+ app_label = 'smokeng'

Subscribers

People subscribed via source and target branches