From 1547c7c49a1852852ffbac0737d0ffdf54addda9 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Tue, 1 Mar 2011 18:47:03 +0100 Subject: isotests: entry and listing of release engineering tests Add a new project for entry and listing of testing results for our release ISOs. This will assist the release engineering team with determining a good ISO to make into the real deal. Signed-off-by: Dan McGee --- isotests/__init__.py | 0 isotests/admin.py | 10 +++++ isotests/fixtures/bootloaders.json | 23 ++++++++++ isotests/fixtures/filesystems.json | 23 ++++++++++ isotests/fixtures/hardware.json | 44 +++++++++++++++++++ isotests/fixtures/installtype.json | 30 +++++++++++++ isotests/fixtures/modules.json | 37 ++++++++++++++++ isotests/fixtures/source.json | 23 ++++++++++ isotests/models.py | 87 ++++++++++++++++++++++++++++++++++++++ isotests/templates/iso_list.html | 2 + isotests/tests.py | 23 ++++++++++ isotests/urls.py | 16 +++++++ isotests/views.py | 24 +++++++++++ settings.py | 1 + templates/isotests/add.html | 13 ++++++ templates/isotests/iso_list.html | 18 ++++++++ templates/isotests/test_list.html | 18 ++++++++ 17 files changed, 392 insertions(+) create mode 100644 isotests/__init__.py create mode 100644 isotests/admin.py create mode 100644 isotests/fixtures/bootloaders.json create mode 100644 isotests/fixtures/filesystems.json create mode 100644 isotests/fixtures/hardware.json create mode 100644 isotests/fixtures/installtype.json create mode 100644 isotests/fixtures/modules.json create mode 100644 isotests/fixtures/source.json create mode 100644 isotests/models.py create mode 100644 isotests/templates/iso_list.html create mode 100644 isotests/tests.py create mode 100644 isotests/urls.py create mode 100644 isotests/views.py create mode 100644 templates/isotests/add.html create mode 100644 templates/isotests/iso_list.html create mode 100644 templates/isotests/test_list.html diff --git a/isotests/__init__.py b/isotests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/isotests/admin.py b/isotests/admin.py new file mode 100644 index 00000000..03b5fbab --- /dev/null +++ b/isotests/admin.py @@ -0,0 +1,10 @@ +from isotests.models import * +from django.contrib import admin + +admin.site.register(Iso) +admin.site.register(Hardware) +admin.site.register(InstallType) +admin.site.register(Source) +admin.site.register(Filesystem) +admin.site.register(Module) +admin.site.register(Bootloader) diff --git a/isotests/fixtures/bootloaders.json b/isotests/fixtures/bootloaders.json new file mode 100644 index 00000000..545b5c0c --- /dev/null +++ b/isotests/fixtures/bootloaders.json @@ -0,0 +1,23 @@ +[ + { + "pk": 1, + "model": "isotests.bootloader", + "fields": { + "name": "grub" + } + }, + { + "pk": 2, + "model": "isotests.bootloader", + "fields": { + "name": "syslinux" + } + }, + { + "pk": 3, + "model": "isotests.bootloader", + "fields": { + "name": "other/manual" + } + } +] diff --git a/isotests/fixtures/filesystems.json b/isotests/fixtures/filesystems.json new file mode 100644 index 00000000..4d3f1bc4 --- /dev/null +++ b/isotests/fixtures/filesystems.json @@ -0,0 +1,23 @@ +[ + { + "pk": 1, + "model": "isotests.filesystem", + "fields": { + "name": "autoprepare (check the installed system, incl fstab)" + } + }, + { + "pk": 2, + "model": "isotests.filesystem", + "fields": { + "name": "manual" + } + }, + { + "pk": 3, + "model": "isotests.filesystem", + "fields": { + "name": "from config file" + } + } +] diff --git a/isotests/fixtures/hardware.json b/isotests/fixtures/hardware.json new file mode 100644 index 00000000..c9169146 --- /dev/null +++ b/isotests/fixtures/hardware.json @@ -0,0 +1,44 @@ +[ + { + "pk": 1, + "model": "isotests.hardware", + "fields": { + "name": "virtualbox" + } + }, + { + "pk": 2, + "model": "isotests.hardware", + "fields": { + "name": "qemu" + } + }, + { + "pk": 3, + "model": "isotests.hardware", + "fields": { + "name": "intel i686" + } + }, + { + "pk": 4, + "model": "isotests.hardware", + "fields": { + "name": "intel x86_64" + } + }, + { + "pk": 5, + "model": "isotests.hardware", + "fields": { + "name": "amd i686" + } + }, + { + "pk": 6, + "model": "isotests.hardware", + "fields": { + "name": "amd x86_64" + } + } +] diff --git a/isotests/fixtures/installtype.json b/isotests/fixtures/installtype.json new file mode 100644 index 00000000..d23bd4b2 --- /dev/null +++ b/isotests/fixtures/installtype.json @@ -0,0 +1,30 @@ +[ + { + "pk": 1, + "model": "isotests.installtype", + "fields": { + "name": "automatic install generic example" + } + }, + { + "pk": 2, + "model": "isotests.installtype", + "fields": { + "name": "automatic install fancy example" + } + }, + { + "pk": 3, + "model": "isotests.installtype", + "fields": { + "name": "automatic install custom config (specify in comments)" + } + }, + { + "pk": 4, + "model": "isotests.installtype", + "fields": { + "name": "interactive install" + } + } +] diff --git a/isotests/fixtures/modules.json b/isotests/fixtures/modules.json new file mode 100644 index 00000000..27d04c7a --- /dev/null +++ b/isotests/fixtures/modules.json @@ -0,0 +1,37 @@ +[ + { + "pk": 1, + "model": "isotests.module", + "fields": { + "name": "lvm2" + } + }, + { + "pk": 2, + "model": "isotests.module", + "fields": { + "name": "dm_crypt" + } + }, + { + "pk": 3, + "model": "isotests.module", + "fields": { + "name": "softraid" + } + }, + { + "pk": 4, + "model": "isotests.module", + "fields": { + "name": "nilfs2" + } + }, + { + "pk": 5, + "model": "isotests.module", + "fields": { + "name": "btrfs" + } + } +] diff --git a/isotests/fixtures/source.json b/isotests/fixtures/source.json new file mode 100644 index 00000000..1bf835a1 --- /dev/null +++ b/isotests/fixtures/source.json @@ -0,0 +1,23 @@ +[ + { + "pk": 1, + "model": "isotests.source", + "fields": { + "name": "net install manual networking config (Check that it works + rc.conf, resolv.conf, mirrorlist)" + } + }, + { + "pk": 2, + "model": "isotests.source", + "fields": { + "name": "net install dhcp (Check that it works + rc.conf)" + } + }, + { + "pk": 3, + "model": "isotests.source", + "fields": { + "name": "core" + } + } +] diff --git a/isotests/models.py b/isotests/models.py new file mode 100644 index 00000000..1eaca163 --- /dev/null +++ b/isotests/models.py @@ -0,0 +1,87 @@ +from django.db import models + +# Create your models here. +class Iso(models.Model): + date = models.DateField() + + def __unicode__(self): + return str(self.date) + +class Hardware(models.Model): + name = models.CharField(max_length=200) + + def __unicode__(self): + return self.name + +class InstallType(models.Model): + name = models.CharField(max_length=200) + + def __unicode__(self): + return self.name + +class Source(models.Model): + name = models.CharField(max_length=200) + + def __unicode__(self): + return self.name + +class Filesystem(models.Model): + name = models.CharField(max_length=200) + + def __unicode__(self): + return self.name + +class Module(models.Model): + name = models.CharField(max_length=200) + + def __unicode__(self): + return self.name + +class Bootloader(models.Model): + name = models.CharField(max_length=200) + + def __unicode__(self): + return self.name + +class Test(models.Model): + ARCH_CHOICES = ( + ('d86', 'dual, option i686'), + ('d64', 'dual, option x86_64'), + ('x86', 'i686'), + ('x64', 'x86_64') + ) + + ISOTYPE_CHOICES = ( + ('c', 'core'), + ('n', 'net') + ) + + BOOTTYPE_CHOICES = ( + ('o', 'optical'), + ('u', 'usb'), + ('p', 'pxe') + ) + + CLOCK_CHOICES = ( + ('d', 'default'), + ('m', 'configured manually'), + ('n', 'NTP') + ) + + user_name = models.CharField(max_length=500) + user_email = models.EmailField() + iso = models.ForeignKey(Iso) + arch = models.CharField(max_length=3, choices=ARCH_CHOICES) + isotype = models.CharField(max_length=1, choices=ISOTYPE_CHOICES) + boottype = models.CharField(max_length=1, choices=BOOTTYPE_CHOICES) + hardwaretype = models.ForeignKey(Hardware) + installtype = models.ForeignKey(InstallType) + source = models.ForeignKey(Source) + clock = models.CharField(max_length=1, choices=CLOCK_CHOICES) + filesystem = models.ForeignKey(Filesystem) + ms = models.ManyToManyField(Module) + rollback = models.BooleanField() + rollback_filesystem = models.ForeignKey(Filesystem, related_name="rollback_test") + rollback_modules = models.ManyToManyField(Module, related_name="rollback_test") + success = models.BooleanField() + comments = models.TextField() diff --git a/isotests/templates/iso_list.html b/isotests/templates/iso_list.html new file mode 100644 index 00000000..06572739 --- /dev/null +++ b/isotests/templates/iso_list.html @@ -0,0 +1,2 @@ +hello there +bla diff --git a/isotests/tests.py b/isotests/tests.py new file mode 100644 index 00000000..2247054b --- /dev/null +++ b/isotests/tests.py @@ -0,0 +1,23 @@ +""" +This file demonstrates two different styles of tests (one doctest and one +unittest). These will both pass when you run "manage.py test". + +Replace these with more appropriate tests for your application. +""" + +from django.test import TestCase + +class SimpleTest(TestCase): + def test_basic_addition(self): + """ + Tests that 1 + 1 always equals 2. + """ + self.failUnlessEqual(1 + 1, 2) + +__test__ = {"doctest": """ +Another way to test that 1 + 1 is equal to 2. + +>>> 1 + 1 == 2 +True +"""} + diff --git a/isotests/urls.py b/isotests/urls.py new file mode 100644 index 00000000..fdde9e3b --- /dev/null +++ b/isotests/urls.py @@ -0,0 +1,16 @@ +from django.conf.urls.defaults import patterns +from isotests.models import Test + +info_dict = { + 'queryset': Test.objects.all() +} + +urlpatterns = patterns('isotests.views', + (r'^add/$', 'add_result') +) + +urlpatterns += patterns('', + (r'^$', 'django.views.generic.list_detail.object_list', info_dict) +) + +# vim: set ts=4 sw=4 et: diff --git a/isotests/views.py b/isotests/views.py new file mode 100644 index 00000000..742be8ff --- /dev/null +++ b/isotests/views.py @@ -0,0 +1,24 @@ +# Create your views here. +from django.http import HttpResponse, HttpResponseRedirect +from django.forms import ModelForm +from isotests.models import Test +from django.shortcuts import render_to_response +from django.template import RequestContext + +class TestForm(ModelForm): + class Meta: + model = Test + +def add_result(request): + if request.method == 'POST': # If the form has been submitted... + form = TestForm(request.POST) # A form bound to the post data + if form.is_valid(): # All validation rules pass + form.save() + return HttpResponseRedirect('/isotests') # Redirect after POST + else: + form = TestForm() # An unbound form + + return render_to_response('isotests/add.html', { + 'form': form, + }, + context_instance=RequestContext(request)) diff --git a/settings.py b/settings.py index 1d26d9eb..107baa17 100644 --- a/settings.py +++ b/settings.py @@ -104,6 +104,7 @@ INSTALLED_APPS = ( 'devel', 'public', 'south', # database migration support + 'isotests', ) ## Import local settings diff --git a/templates/isotests/add.html b/templates/isotests/add.html new file mode 100644 index 00000000..07d3ed81 --- /dev/null +++ b/templates/isotests/add.html @@ -0,0 +1,13 @@ +{% extends "base.html" %} + +{% block title %}Arch Linux - Test Result Entry{% endblock %} + +{% block content %} +
+

Arch releng iso build test result entry

+
{% csrf_token %} + {{ form.as_p }} + +
+
+{% endblock %} diff --git a/templates/isotests/iso_list.html b/templates/isotests/iso_list.html new file mode 100644 index 00000000..f94bbe1a --- /dev/null +++ b/templates/isotests/iso_list.html @@ -0,0 +1,18 @@ +{% extends "base.html" %} + +{% block title %}Arch Linux - Testresults{% endblock %} + +{% block content %} +{% if object_list %} +
+

Arch releng iso buid test results

+
    + {% for iso in object_list %} +
  • {{ iso }}
  • + {% endfor %} +
+ {% else %} +

No tests are available.

+ {% endif %} +
+{% endblock %} diff --git a/templates/isotests/test_list.html b/templates/isotests/test_list.html new file mode 100644 index 00000000..1ef39a4c --- /dev/null +++ b/templates/isotests/test_list.html @@ -0,0 +1,18 @@ +{% extends "base.html" %} + +{% block title %}Arch Linux - Testresults{% endblock %} + +{% block content %} +
+

Arch releng iso build test results

+ {% if object_list %} + + {% else %} +

No test results are available.

+ {% endif %} +
+{% endblock %} -- cgit v1.2.3-55-g3dc8 From f4229daac60fa90cbf8d77bfdffd88a467869b3c Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Tue, 1 Mar 2011 20:43:37 +0100 Subject: isotests: view updates, choices->models, show results, admin * Started changing the view portion * Changed choices to models * Show the latest failed/succeeded tests on results page * Added some more admin pages Signed-off-by: Dan McGee --- isotests/admin.py | 4 + isotests/fixtures/architecture.json | 30 ++++++ isotests/fixtures/boottype.json | 23 +++++ isotests/fixtures/clockchoices.json | 23 +++++ isotests/fixtures/isotypes.json | 16 +++ isotests/models.py | 110 +++++++++++++++------ isotests/urls.py | 6 +- isotests/views.py | 42 ++++++-- templates/isotests/results.html | 190 ++++++++++++++++++++++++++++++++++++ 9 files changed, 402 insertions(+), 42 deletions(-) create mode 100644 isotests/fixtures/architecture.json create mode 100644 isotests/fixtures/boottype.json create mode 100644 isotests/fixtures/clockchoices.json create mode 100644 isotests/fixtures/isotypes.json create mode 100644 templates/isotests/results.html diff --git a/isotests/admin.py b/isotests/admin.py index 03b5fbab..b03ddea3 100644 --- a/isotests/admin.py +++ b/isotests/admin.py @@ -2,9 +2,13 @@ from isotests.models import * from django.contrib import admin admin.site.register(Iso) +admin.site.register(Architecture) +admin.site.register(Isotype) +admin.site.register(Boottype) admin.site.register(Hardware) admin.site.register(InstallType) admin.site.register(Source) +admin.site.register(Clockchoice) admin.site.register(Filesystem) admin.site.register(Module) admin.site.register(Bootloader) diff --git a/isotests/fixtures/architecture.json b/isotests/fixtures/architecture.json new file mode 100644 index 00000000..a21100ba --- /dev/null +++ b/isotests/fixtures/architecture.json @@ -0,0 +1,30 @@ +[ + { + "pk": 1, + "model": "isotests.architecture", + "fields": { + "name": "dual, option i686" + } + }, + { + "pk": 2, + "model": "isotests.architecture", + "fields": { + "name": "dual, option x86_64" + } + }, + { + "pk": 3, + "model": "isotests.architecture", + "fields": { + "name": "i686" + } + }, + { + "pk": 4, + "model": "isotests.architecture", + "fields": { + "name": "x86_64" + } + } +] diff --git a/isotests/fixtures/boottype.json b/isotests/fixtures/boottype.json new file mode 100644 index 00000000..5d87ef15 --- /dev/null +++ b/isotests/fixtures/boottype.json @@ -0,0 +1,23 @@ +[ + { + "pk": 1, + "model": "isotests.boottype", + "fields": { + "name": "optical" + } + }, + { + "pk": 2, + "model": "isotests.boottype", + "fields": { + "name": "usb" + } + }, + { + "pk": 3, + "model": "isotests.boottype", + "fields": { + "name": "pxe" + } + } +] diff --git a/isotests/fixtures/clockchoices.json b/isotests/fixtures/clockchoices.json new file mode 100644 index 00000000..2c078128 --- /dev/null +++ b/isotests/fixtures/clockchoices.json @@ -0,0 +1,23 @@ +[ + { + "pk": 1, + "model": "isotests.clockchoice", + "fields": { + "name": "default" + } + }, + { + "pk": 2, + "model": "isotests.clockchoice", + "fields": { + "name": "configured manually" + } + }, + { + "pk": 3, + "model": "isotests.clockchoice", + "fields": { + "name": "NTP" + } + } +] diff --git a/isotests/fixtures/isotypes.json b/isotests/fixtures/isotypes.json new file mode 100644 index 00000000..760e3738 --- /dev/null +++ b/isotests/fixtures/isotypes.json @@ -0,0 +1,16 @@ +[ + { + "pk": 1, + "model": "isotests.isotype", + "fields": { + "name": "core" + } + }, + { + "pk": 2, + "model": "isotests.isotype", + "fields": { + "name": "net" + } + } +] diff --git a/isotests/models.py b/isotests/models.py index 1eaca163..d9cfc78c 100644 --- a/isotests/models.py +++ b/isotests/models.py @@ -1,4 +1,6 @@ from django.db import models +from django.db.models import Max +from datetime import datetime # Create your models here. class Iso(models.Model): @@ -7,81 +9,125 @@ class Iso(models.Model): def __unicode__(self): return str(self.date) +class Architecture(models.Model): + name = models.CharField(max_length=200) + + def __unicode__(self): + return self.name + + def get_success_test(self): + return self.test_set.filter(success=True).aggregate(Max('iso__date'))['iso__date__max'] + def get_failed_test(self): + return self.test_set.filter(success=False).aggregate(Max('iso__date'))['iso__date__max'] + +class Isotype(models.Model): + name = models.CharField(max_length=200) + + def __unicode__(self): + return self.name + def get_success_test(self): + return self.test_set.filter(success=True).aggregate(Max('iso__date'))['iso__date__max'] + def get_failed_test(self): + return self.test_set.filter(success=False).aggregate(Max('iso__date'))['iso__date__max'] + +class Boottype(models.Model): + name = models.CharField(max_length=200) + + def __unicode__(self): + return self.name + def get_success_test(self): + return self.test_set.filter(success=True).aggregate(Max('iso__date'))['iso__date__max'] + def get_failed_test(self): + return self.test_set.filter(success=False).aggregate(Max('iso__date'))['iso__date__max'] + class Hardware(models.Model): name = models.CharField(max_length=200) def __unicode__(self): return self.name + def get_success_test(self): + return self.test_set.filter(success=True).aggregate(Max('iso__date'))['iso__date__max'] + def get_failed_test(self): + return self.test_set.filter(success=False).aggregate(Max('iso__date'))['iso__date__max'] class InstallType(models.Model): name = models.CharField(max_length=200) def __unicode__(self): return self.name + def get_success_test(self): + return self.test_set.filter(success=True).aggregate(Max('iso__date'))['iso__date__max'] + def get_failed_test(self): + return self.test_set.filter(success=False).aggregate(Max('iso__date'))['iso__date__max'] class Source(models.Model): name = models.CharField(max_length=200) def __unicode__(self): return self.name + def get_success_test(self): + return self.test_set.filter(success=True).aggregate(Max('iso__date'))['iso__date__max'] + def get_failed_test(self): + return self.test_set.filter(success=False).aggregate(Max('iso__date'))['iso__date__max'] + +class Clockchoice(models.Model): + name = models.CharField(max_length=200) + + def __unicode__(self): + return self.name + def get_success_test(self): + return self.test_set.filter(success=True).aggregate(Max('iso__date'))['iso__date__max'] + def get_failed_test(self): + return self.test_set.filter(success=False).aggregate(Max('iso__date'))['iso__date__max'] class Filesystem(models.Model): name = models.CharField(max_length=200) def __unicode__(self): return self.name + def get_success_test(self): + return self.test_set.filter(success=True).aggregate(Max('iso__date'))['iso__date__max'] + def get_failed_test(self): + return self.test_set.filter(success=False).aggregate(Max('iso__date'))['iso__date__max'] class Module(models.Model): name = models.CharField(max_length=200) def __unicode__(self): return self.name + def get_success_test(self): + return self.test_set.filter(success=True).aggregate(Max('iso__date'))['iso__date__max'] + def get_failed_test(self): + return self.test_set.filter(success=False).aggregate(Max('iso__date'))['iso__date__max'] class Bootloader(models.Model): name = models.CharField(max_length=200) def __unicode__(self): return self.name + def get_success_test(self): + return self.test_set.filter(success=True).aggregate(Max('iso__date'))['iso__date__max'] + def get_failed_test(self): + return self.test_set.filter(success=False).aggregate(Max('iso__date'))['iso__date__max'] class Test(models.Model): - ARCH_CHOICES = ( - ('d86', 'dual, option i686'), - ('d64', 'dual, option x86_64'), - ('x86', 'i686'), - ('x64', 'x86_64') - ) - - ISOTYPE_CHOICES = ( - ('c', 'core'), - ('n', 'net') - ) - - BOOTTYPE_CHOICES = ( - ('o', 'optical'), - ('u', 'usb'), - ('p', 'pxe') - ) - - CLOCK_CHOICES = ( - ('d', 'default'), - ('m', 'configured manually'), - ('n', 'NTP') - ) - user_name = models.CharField(max_length=500) user_email = models.EmailField() iso = models.ForeignKey(Iso) - arch = models.CharField(max_length=3, choices=ARCH_CHOICES) - isotype = models.CharField(max_length=1, choices=ISOTYPE_CHOICES) - boottype = models.CharField(max_length=1, choices=BOOTTYPE_CHOICES) + arch = models.ForeignKey(Architecture) + isotype = models.ForeignKey(Isotype) + boottype = models.ForeignKey(Boottype) hardwaretype = models.ForeignKey(Hardware) installtype = models.ForeignKey(InstallType) source = models.ForeignKey(Source) - clock = models.CharField(max_length=1, choices=CLOCK_CHOICES) + clock = models.ForeignKey(Clockchoice) filesystem = models.ForeignKey(Filesystem) - ms = models.ManyToManyField(Module) + ms = models.ManyToManyField(Module, null=True, blank=True) rollback = models.BooleanField() - rollback_filesystem = models.ForeignKey(Filesystem, related_name="rollback_test") - rollback_modules = models.ManyToManyField(Module, related_name="rollback_test") + rollback_filesystem = models.ForeignKey(Filesystem, + related_name="rollback_test", null=True, blank=True) + rollback_modules = models.ManyToManyField(Module, + related_name="rollback_test", null=True, blank=True) + bootloader = models.ForeignKey(Bootloader) success = models.BooleanField() - comments = models.TextField() + comments = models.TextField(null=True, blank=True) diff --git a/isotests/urls.py b/isotests/urls.py index fdde9e3b..e28497aa 100644 --- a/isotests/urls.py +++ b/isotests/urls.py @@ -6,11 +6,11 @@ info_dict = { } urlpatterns = patterns('isotests.views', - (r'^add/$', 'add_result') -) + (r'^$', 'view_results'), + (r'^add/$', 'add_result') + ) urlpatterns += patterns('', - (r'^$', 'django.views.generic.list_detail.object_list', info_dict) ) # vim: set ts=4 sw=4 et: diff --git a/isotests/views.py b/isotests/views.py index 742be8ff..738fa90d 100644 --- a/isotests/views.py +++ b/isotests/views.py @@ -1,9 +1,9 @@ # Create your views here. from django.http import HttpResponse, HttpResponseRedirect -from django.forms import ModelForm -from isotests.models import Test +from django.forms import ModelForm, DateField +from isotests.models import * from django.shortcuts import render_to_response -from django.template import RequestContext +from django.template import RequestContext, Context, loader class TestForm(ModelForm): class Meta: @@ -18,7 +18,35 @@ def add_result(request): else: form = TestForm() # An unbound form - return render_to_response('isotests/add.html', { - 'form': form, - }, - context_instance=RequestContext(request)) + return render_to_response('isotests/add.html', { 'form': form, }, + context_instance=RequestContext(request)) + +def view_results(request): + result_success_list = Test.objects.filter(success=True) + result_failed_list = Test.objects.filter(success=False) + + architecture_list = Architecture.objects.all() + isotype_list = Isotype.objects.all() + boottype_list = Boottype.objects.all() + hardware_list = Hardware.objects.all() + installtype_list = InstallType.objects.all() + source_list = Source.objects.all() + clockchoice_list = Clockchoice.objects.all() + module_list = Module.objects.all() + filesystem_list = Filesystem.objects.all() + bootloader_list = Bootloader.objects.all() + + t = loader.get_template("isotests/results.html") + c = Context({ + 'arch_choices': architecture_list, + 'isotype_choices': isotype_list, + 'boottype_choices': boottype_list, + 'hardware_list': hardware_list, + 'installtype_list': installtype_list, + 'source_list': source_list, + 'clock_choices': clockchoice_list, + 'filesystem_list': filesystem_list, + 'module_list': module_list, + 'bootloader_list': bootloader_list, + }) + return HttpResponse(t.render(c)) diff --git a/templates/isotests/results.html b/templates/isotests/results.html new file mode 100644 index 00000000..3e43ae47 --- /dev/null +++ b/templates/isotests/results.html @@ -0,0 +1,190 @@ +{% extends "base.html" %} + +{% block title %}Arch Linux - Testresults{% endblock %} + +{% block content %} +
+

Arch releng iso build test results

+ + + + + {% if arch_choices %} + {% for arch in arch_choices %} + + + + + + {% endfor %} + {% endif %} + + + + {% if isotype_choices %} + {% for isotype in isotype_choices %} + + + + + + {% endfor %} + {% endif %} + + + + {% if boottype_choices %} + {% for boottype in boottype_choices %} + + + + + + {% endfor %} + {% endif %} + + + + {% if hardware_list %} + {% for hardware in hardware_list %} + + + + + + {% endfor %} + {% endif %} + + + + {% if installtype_list %} + {% for installtype in installtype_list %} + + + + + + {% endfor %} + {% endif %} + + + + {% if source_list %} + {% for source in source_list %} + + + + + + {% endfor %} + {% endif %} + + + + {% if clock_choices %} + {% for clock in clock_choices %} + + + + + + {% endfor %} + {% endif %} + + + + {% if filesystem_list %} + {% for filesystem in filesystem_list %} + + + + + + {% endfor %} + {% endif %} + + + + {% if module_list %} + {% for module in module_list %} + + + + + + {% endfor %} + {% endif %} + + + + + + + + + + + + + {% if filesystem_list %} + {% for filesystem in filesystem_list %} + + + + + + {% endfor %} + {% endif %} + + + + {% if module_list %} + {% for module in module_list %} + + + + + + {% endfor %} + {% endif %} + + + + {% if bootloader_list %} + {% for bootloader in bootloader_list %} + + + + + + {% endfor %} + {% endif %} +
+

image arch

+
{{ arch.name }}{{ arch.get_success_test|default_if_none:"Never succeeded" }}{{ arch.get_failed_test|default_if_none:"Never failed" }}
+

image type

+
{{ isotype.name }}{{ isotype.get_success_test|default_if_none:"Never succeeded" }}{{ isotype.get_failed_test|default_if_none:"Never failed" }}
+

image boot

+
{{ boottype.name }}{{ boottype.get_success_test|default_if_none:"Never succeeded" }}{{ boottype.get_failed_test|default_if_none:"Never failed" }}
+

hardware type

+
{{ hardware.name }}{{ hardware.get_success_test|default_if_none:"Never succeeded" }}{{ hardware.get_failed_test|default_if_none:"Never failed" }}
+

install type

+
{{ installtype.name }}{{ installtype.get_success_test|default_if_none:"Never succeeded" }}{{ installtype.get_failed_test|default_if_none:"Never failed" }}
+

source selection

+
{{ source.name }}{{ source.get_success_test|default_if_none:"Never succeeded" }}{{ source.get_failed_test|default_if_none:"Never failed" }}
+

clock

+
{{ clock.name }}{{ clock.get_success_test|default_if_none:"Never succeeded" }}{{ clock.get_failed_test|default_if_none:"Never failed" }}
+

partitioning/filesystems

+
{{ filesystem.name }}{{ filesystem.get_success_test|default_if_none:"Never succeeded" }}{{ filesystem.get_failed_test|default_if_none:"Never failed" }}
+

fancy stuff

+
{{ module.name }}{{ module.get_success_test|default_if_none:"Never succeeded" }}{{ module.get_failed_test|default_if_none:"Never failed" }}
+

rollback

+
yes
no
+

rollback: partitioning/filesystems

+
{{ filesystem.name }}{{ filesystem.get_success_test|default_if_none:"Never succeeded" }}{{ filesystem.get_failed_test|default_if_none:"Never failed" }}
+

rollback: fancy stuff

+
{{ module.name }}{{ module.get_success_test|default_if_none:"Never succeeded" }}{{ module.get_failed_test|default_if_none:"Never failed" }}
+

bootloader

+
{{ bootloader.name }}{{ bootloader.get_success_test|default_if_none:"Never succeeded" }}{{ bootloader.get_failed_test|default_if_none:"Never failed" }}
+
+{% endblock %} -- cgit v1.2.3-55-g3dc8 From 00e096ddf0654d32e67ac8bc47f3de01ed7e740b Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Thu, 28 Apr 2011 13:00:27 -0500 Subject: isotests: style cleanup, ui improvements * Using radio buttons for widgets is smarter. * Model names cleanup. * Test.ms: totally un-descriptive field name, should be modules. * models, Iso: Likely need more than a date field here. Removed date and added name. * get_success_test/get_failed_test: now on abstract superclass * tests.py: I wasn't using these, so I might as well remove it. * admin.py: convention is not to use * imports. * models.py: "# Create your models here." -> not needed. * urls.py: I wasn't using info_dict anymore; I had a blank second pattern definition, and I should follow indentation patterns from elsewhere in the project. * views.py, add: switched to using mostly direct_to_template to avoid some of the boilerplate. * isotest/templates: was old, not used. * I had 4 + 1 templates, but only two views- these other ones were old, unnecessary and not wired up. Signed-off-by: Dan McGee --- isotests/admin.py | 12 +- isotests/fixtures/hardware.json | 12 +- isotests/models.py | 135 +++++--------- isotests/templates/iso_list.html | 2 - isotests/tests.py | 23 --- isotests/urls.py | 12 +- isotests/views.py | 66 ++++--- templates/isotests/iso_list.html | 18 -- templates/isotests/results.html | 364 +++++++++++++++++++------------------- templates/isotests/test_list.html | 18 -- 10 files changed, 279 insertions(+), 383 deletions(-) delete mode 100644 isotests/templates/iso_list.html delete mode 100644 isotests/tests.py delete mode 100644 templates/isotests/iso_list.html delete mode 100644 templates/isotests/test_list.html diff --git a/isotests/admin.py b/isotests/admin.py index b03ddea3..0cde0f83 100644 --- a/isotests/admin.py +++ b/isotests/admin.py @@ -1,14 +1,16 @@ -from isotests.models import * +from isotests.models import Iso, Architecture, IsoType, BootType +from isotests.models import HardwareType, InstallType, Source +from isotests.models import ClockChoice, Filesystem, Module, Bootloader from django.contrib import admin admin.site.register(Iso) admin.site.register(Architecture) -admin.site.register(Isotype) -admin.site.register(Boottype) -admin.site.register(Hardware) +admin.site.register(IsoType) +admin.site.register(BootType) +admin.site.register(HardwareType) admin.site.register(InstallType) admin.site.register(Source) -admin.site.register(Clockchoice) +admin.site.register(ClockChoice) admin.site.register(Filesystem) admin.site.register(Module) admin.site.register(Bootloader) diff --git a/isotests/fixtures/hardware.json b/isotests/fixtures/hardware.json index c9169146..335a50f6 100644 --- a/isotests/fixtures/hardware.json +++ b/isotests/fixtures/hardware.json @@ -1,42 +1,42 @@ [ { "pk": 1, - "model": "isotests.hardware", + "model": "isotests.hardwaretype", "fields": { "name": "virtualbox" } }, { "pk": 2, - "model": "isotests.hardware", + "model": "isotests.hardwaretype", "fields": { "name": "qemu" } }, { "pk": 3, - "model": "isotests.hardware", + "model": "isotests.hardwaretype", "fields": { "name": "intel i686" } }, { "pk": 4, - "model": "isotests.hardware", + "model": "isotests.hardwaretype", "fields": { "name": "intel x86_64" } }, { "pk": 5, - "model": "isotests.hardware", + "model": "isotests.hardwaretype", "fields": { "name": "amd i686" } }, { "pk": 6, - "model": "isotests.hardware", + "model": "isotests.hardwaretype", "fields": { "name": "amd x86_64" } diff --git a/isotests/models.py b/isotests/models.py index d9cfc78c..bffb2d94 100644 --- a/isotests/models.py +++ b/isotests/models.py @@ -1,128 +1,77 @@ from django.db import models from django.db.models import Max -from datetime import datetime -# Create your models here. -class Iso(models.Model): - date = models.DateField() - - def __unicode__(self): - return str(self.date) +class IsoOption(models.Model): + class Meta: + abstract = True -class Architecture(models.Model): name = models.CharField(max_length=200) def __unicode__(self): - return self.name + return str(self.name) def get_success_test(self): - return self.test_set.filter(success=True).aggregate(Max('iso__date'))['iso__date__max'] - def get_failed_test(self): - return self.test_set.filter(success=False).aggregate(Max('iso__date'))['iso__date__max'] - -class Isotype(models.Model): - name = models.CharField(max_length=200) + test = self.test_set.filter(success=True).annotate(Max('iso__id')) + if test: + return test[0].iso.name + return None - def __unicode__(self): - return self.name - def get_success_test(self): - return self.test_set.filter(success=True).aggregate(Max('iso__date'))['iso__date__max'] def get_failed_test(self): - return self.test_set.filter(success=False).aggregate(Max('iso__date'))['iso__date__max'] + test = self.test_set.filter(success=False).annotate(Max('iso__id')) + if test: + return test[0].iso.name + return None -class Boottype(models.Model): - name = models.CharField(max_length=200) +class Iso(models.Model): + name = models.CharField(max_length=500) + active = models.BooleanField(default=True) def __unicode__(self): return self.name - def get_success_test(self): - return self.test_set.filter(success=True).aggregate(Max('iso__date'))['iso__date__max'] - def get_failed_test(self): - return self.test_set.filter(success=False).aggregate(Max('iso__date'))['iso__date__max'] -class Hardware(models.Model): - name = models.CharField(max_length=200) +class Architecture(IsoOption): + pass - def __unicode__(self): - return self.name - def get_success_test(self): - return self.test_set.filter(success=True).aggregate(Max('iso__date'))['iso__date__max'] - def get_failed_test(self): - return self.test_set.filter(success=False).aggregate(Max('iso__date'))['iso__date__max'] +class IsoType(IsoOption): + pass -class InstallType(models.Model): - name = models.CharField(max_length=200) +class BootType(IsoOption): + pass - def __unicode__(self): - return self.name - def get_success_test(self): - return self.test_set.filter(success=True).aggregate(Max('iso__date'))['iso__date__max'] - def get_failed_test(self): - return self.test_set.filter(success=False).aggregate(Max('iso__date'))['iso__date__max'] +class HardwareType(IsoOption): + pass -class Source(models.Model): - name = models.CharField(max_length=200) +class InstallType(IsoOption): + pass - def __unicode__(self): - return self.name - def get_success_test(self): - return self.test_set.filter(success=True).aggregate(Max('iso__date'))['iso__date__max'] - def get_failed_test(self): - return self.test_set.filter(success=False).aggregate(Max('iso__date'))['iso__date__max'] - -class Clockchoice(models.Model): - name = models.CharField(max_length=200) - - def __unicode__(self): - return self.name - def get_success_test(self): - return self.test_set.filter(success=True).aggregate(Max('iso__date'))['iso__date__max'] - def get_failed_test(self): - return self.test_set.filter(success=False).aggregate(Max('iso__date'))['iso__date__max'] - -class Filesystem(models.Model): - name = models.CharField(max_length=200) - - def __unicode__(self): - return self.name - def get_success_test(self): - return self.test_set.filter(success=True).aggregate(Max('iso__date'))['iso__date__max'] - def get_failed_test(self): - return self.test_set.filter(success=False).aggregate(Max('iso__date'))['iso__date__max'] +class Source(IsoOption): + pass -class Module(models.Model): - name = models.CharField(max_length=200) +class ClockChoice(IsoOption): + pass - def __unicode__(self): - return self.name - def get_success_test(self): - return self.test_set.filter(success=True).aggregate(Max('iso__date'))['iso__date__max'] - def get_failed_test(self): - return self.test_set.filter(success=False).aggregate(Max('iso__date'))['iso__date__max'] +class Filesystem(IsoOption): + pass -class Bootloader(models.Model): - name = models.CharField(max_length=200) +class Module(IsoOption): + pass - def __unicode__(self): - return self.name - def get_success_test(self): - return self.test_set.filter(success=True).aggregate(Max('iso__date'))['iso__date__max'] - def get_failed_test(self): - return self.test_set.filter(success=False).aggregate(Max('iso__date'))['iso__date__max'] +class Bootloader(IsoOption): + pass class Test(models.Model): user_name = models.CharField(max_length=500) user_email = models.EmailField() iso = models.ForeignKey(Iso) - arch = models.ForeignKey(Architecture) - isotype = models.ForeignKey(Isotype) - boottype = models.ForeignKey(Boottype) - hardwaretype = models.ForeignKey(Hardware) - installtype = models.ForeignKey(InstallType) + architecture = models.ForeignKey(Architecture) + iso_type = models.ForeignKey(IsoType) + boot_type = models.ForeignKey(BootType) + hardware_type = models.ForeignKey(HardwareType) + install_type = models.ForeignKey(InstallType) source = models.ForeignKey(Source) - clock = models.ForeignKey(Clockchoice) + clock_choice = models.ForeignKey(ClockChoice) filesystem = models.ForeignKey(Filesystem) - ms = models.ManyToManyField(Module, null=True, blank=True) + modules = models.ManyToManyField(Module, null=True, blank=True) rollback = models.BooleanField() rollback_filesystem = models.ForeignKey(Filesystem, related_name="rollback_test", null=True, blank=True) diff --git a/isotests/templates/iso_list.html b/isotests/templates/iso_list.html deleted file mode 100644 index 06572739..00000000 --- a/isotests/templates/iso_list.html +++ /dev/null @@ -1,2 +0,0 @@ -hello there -bla diff --git a/isotests/tests.py b/isotests/tests.py deleted file mode 100644 index 2247054b..00000000 --- a/isotests/tests.py +++ /dev/null @@ -1,23 +0,0 @@ -""" -This file demonstrates two different styles of tests (one doctest and one -unittest). These will both pass when you run "manage.py test". - -Replace these with more appropriate tests for your application. -""" - -from django.test import TestCase - -class SimpleTest(TestCase): - def test_basic_addition(self): - """ - Tests that 1 + 1 always equals 2. - """ - self.failUnlessEqual(1 + 1, 2) - -__test__ = {"doctest": """ -Another way to test that 1 + 1 is equal to 2. - ->>> 1 + 1 == 2 -True -"""} - diff --git a/isotests/urls.py b/isotests/urls.py index e28497aa..f60f0bc9 100644 --- a/isotests/urls.py +++ b/isotests/urls.py @@ -1,16 +1,8 @@ from django.conf.urls.defaults import patterns -from isotests.models import Test - -info_dict = { - 'queryset': Test.objects.all() -} urlpatterns = patterns('isotests.views', - (r'^$', 'view_results'), - (r'^add/$', 'add_result') - ) - -urlpatterns += patterns('', + (r'^$', 'view_results'), + (r'^add/$', 'add_result') ) # vim: set ts=4 sw=4 et: diff --git a/isotests/views.py b/isotests/views.py index 738fa90d..cb7f23c5 100644 --- a/isotests/views.py +++ b/isotests/views.py @@ -1,50 +1,64 @@ -# Create your views here. from django.http import HttpResponse, HttpResponseRedirect -from django.forms import ModelForm, DateField -from isotests.models import * -from django.shortcuts import render_to_response -from django.template import RequestContext, Context, loader +from django.forms import ModelForm, RadioSelect, CheckboxSelectMultiple +from django.forms import ModelChoiceField +from isotests.models import Iso, Architecture, IsoType, BootType +from isotests.models import HardwareType, InstallType, Source, Test +from isotests.models import ClockChoice, Filesystem, Module, Bootloader +from django.template import Context, loader +from django.views.generic.simple import direct_to_template class TestForm(ModelForm): class Meta: model = Test + widgets = { + "architecture": RadioSelect(), + "iso_type": RadioSelect(), + "boot_type": RadioSelect(), + "hardware_type": RadioSelect(), + "install_type": RadioSelect(), + "source": RadioSelect(), + "clock_choice": RadioSelect(), + "filesystem": RadioSelect(), + "rollback_filesystem": RadioSelect(), + "bootloader": RadioSelect(), + "modules": CheckboxSelectMultiple(), + "rollback_modules": CheckboxSelectMultiple(), + } + iso = ModelChoiceField(queryset=Iso.objects.filter(active=True)) def add_result(request): - if request.method == 'POST': # If the form has been submitted... - form = TestForm(request.POST) # A form bound to the post data - if form.is_valid(): # All validation rules pass + if request.method == 'POST': + form = TestForm(request.POST) + if form.is_valid(): form.save() - return HttpResponseRedirect('/isotests') # Redirect after POST + return HttpResponseRedirect('/isotests') else: - form = TestForm() # An unbound form + form = TestForm() - return render_to_response('isotests/add.html', { 'form': form, }, - context_instance=RequestContext(request)) + context = {'form': form} + return direct_to_template(request, 'isotests/add.html', context) def view_results(request): - result_success_list = Test.objects.filter(success=True) - result_failed_list = Test.objects.filter(success=False) - architecture_list = Architecture.objects.all() - isotype_list = Isotype.objects.all() - boottype_list = Boottype.objects.all() - hardware_list = Hardware.objects.all() - installtype_list = InstallType.objects.all() + iso_type_list = IsoType.objects.all() + boot_type_list = BootType.objects.all() + hardware_type_list = HardwareType.objects.all() + install_type_list = InstallType.objects.all() source_list = Source.objects.all() - clockchoice_list = Clockchoice.objects.all() + clock_choice_list = ClockChoice.objects.all() module_list = Module.objects.all() filesystem_list = Filesystem.objects.all() bootloader_list = Bootloader.objects.all() t = loader.get_template("isotests/results.html") c = Context({ - 'arch_choices': architecture_list, - 'isotype_choices': isotype_list, - 'boottype_choices': boottype_list, - 'hardware_list': hardware_list, - 'installtype_list': installtype_list, + 'architecture_list': architecture_list, + 'iso_type_list': iso_type_list, + 'boot_type_list': boot_type_list, + 'hardware_type_list': hardware_type_list, + 'install_type_list': install_type_list, 'source_list': source_list, - 'clock_choices': clockchoice_list, + 'clock_choices_list': clock_choice_list, 'filesystem_list': filesystem_list, 'module_list': module_list, 'bootloader_list': bootloader_list, diff --git a/templates/isotests/iso_list.html b/templates/isotests/iso_list.html deleted file mode 100644 index f94bbe1a..00000000 --- a/templates/isotests/iso_list.html +++ /dev/null @@ -1,18 +0,0 @@ -{% extends "base.html" %} - -{% block title %}Arch Linux - Testresults{% endblock %} - -{% block content %} -{% if object_list %} -
-

Arch releng iso buid test results

-
    - {% for iso in object_list %} -
  • {{ iso }}
  • - {% endfor %} -
- {% else %} -

No tests are available.

- {% endif %} -
-{% endblock %} diff --git a/templates/isotests/results.html b/templates/isotests/results.html index 3e43ae47..b773056a 100644 --- a/templates/isotests/results.html +++ b/templates/isotests/results.html @@ -4,187 +4,187 @@ {% block content %}
-

Arch releng iso build test results

- - - - - {% if arch_choices %} - {% for arch in arch_choices %} - - - - - - {% endfor %} - {% endif %} - - - - {% if isotype_choices %} - {% for isotype in isotype_choices %} - - - - - - {% endfor %} - {% endif %} - - - - {% if boottype_choices %} - {% for boottype in boottype_choices %} - - - - - - {% endfor %} - {% endif %} - - - - {% if hardware_list %} - {% for hardware in hardware_list %} - - - - - - {% endfor %} - {% endif %} - - - - {% if installtype_list %} - {% for installtype in installtype_list %} - - - - - - {% endfor %} - {% endif %} - - - - {% if source_list %} - {% for source in source_list %} - - - - - - {% endfor %} - {% endif %} - - - - {% if clock_choices %} - {% for clock in clock_choices %} - - - - - - {% endfor %} - {% endif %} - - - - {% if filesystem_list %} - {% for filesystem in filesystem_list %} - - - - - - {% endfor %} - {% endif %} - - - - {% if module_list %} - {% for module in module_list %} - - - - - - {% endfor %} - {% endif %} - - - - - - - - - - - - - {% if filesystem_list %} - {% for filesystem in filesystem_list %} - - - - - - {% endfor %} - {% endif %} - - - - {% if module_list %} - {% for module in module_list %} - - - - - - {% endfor %} - {% endif %} - - - - {% if bootloader_list %} - {% for bootloader in bootloader_list %} - - - - - - {% endfor %} - {% endif %} -
-

image arch

-
{{ arch.name }}{{ arch.get_success_test|default_if_none:"Never succeeded" }}{{ arch.get_failed_test|default_if_none:"Never failed" }}
-

image type

-
{{ isotype.name }}{{ isotype.get_success_test|default_if_none:"Never succeeded" }}{{ isotype.get_failed_test|default_if_none:"Never failed" }}
-

image boot

-
{{ boottype.name }}{{ boottype.get_success_test|default_if_none:"Never succeeded" }}{{ boottype.get_failed_test|default_if_none:"Never failed" }}
-

hardware type

-
{{ hardware.name }}{{ hardware.get_success_test|default_if_none:"Never succeeded" }}{{ hardware.get_failed_test|default_if_none:"Never failed" }}
-

install type

-
{{ installtype.name }}{{ installtype.get_success_test|default_if_none:"Never succeeded" }}{{ installtype.get_failed_test|default_if_none:"Never failed" }}
-

source selection

-
{{ source.name }}{{ source.get_success_test|default_if_none:"Never succeeded" }}{{ source.get_failed_test|default_if_none:"Never failed" }}
-

clock

-
{{ clock.name }}{{ clock.get_success_test|default_if_none:"Never succeeded" }}{{ clock.get_failed_test|default_if_none:"Never failed" }}
-

partitioning/filesystems

-
{{ filesystem.name }}{{ filesystem.get_success_test|default_if_none:"Never succeeded" }}{{ filesystem.get_failed_test|default_if_none:"Never failed" }}
-

fancy stuff

-
{{ module.name }}{{ module.get_success_test|default_if_none:"Never succeeded" }}{{ module.get_failed_test|default_if_none:"Never failed" }}
-

rollback

-
yes
no
-

rollback: partitioning/filesystems

-
{{ filesystem.name }}{{ filesystem.get_success_test|default_if_none:"Never succeeded" }}{{ filesystem.get_failed_test|default_if_none:"Never failed" }}
-

rollback: fancy stuff

-
{{ module.name }}{{ module.get_success_test|default_if_none:"Never succeeded" }}{{ module.get_failed_test|default_if_none:"Never failed" }}
-

bootloader

-
{{ bootloader.name }}{{ bootloader.get_success_test|default_if_none:"Never succeeded" }}{{ bootloader.get_failed_test|default_if_none:"Never failed" }}
+

Arch releng iso build test results

+ + + + + {% if architecture_list %} + {% for architecture in architecture_list %} + + + + + + {% endfor %} + {% endif %} + + + + {% if iso_type_list %} + {% for iso_type in iso_type_list %} + + + + + + {% endfor %} + {% endif %} + + + + {% if boot_type_list %} + {% for boot_type in boot_type_list %} + + + + + + {% endfor %} + {% endif %} + + + + {% if hardware_type_list %} + {% for hardware_type in hardware_type_list %} + + + + + + {% endfor %} + {% endif %} + + + + {% if install_type_list %} + {% for install_type in install_type_list %} + + + + + + {% endfor %} + {% endif %} + + + + {% if source_list %} + {% for source in source_list %} + + + + + + {% endfor %} + {% endif %} + + + + {% if clock_choices_list %} + {% for clock_choice in clock_choices_list %} + + + + + + {% endfor %} + {% endif %} + + + + {% if filesystem_list %} + {% for filesystem in filesystem_list %} + + + + + + {% endfor %} + {% endif %} + + + + {% if module_list %} + {% for module in module_list %} + + + + + + {% endfor %} + {% endif %} + + + + + + + + + + + + + {% if filesystem_list %} + {% for filesystem in filesystem_list %} + + + + + + {% endfor %} + {% endif %} + + + + {% if module_list %} + {% for module in module_list %} + + + + + + {% endfor %} + {% endif %} + + + + {% if bootloader_list %} + {% for bootloader in bootloader_list %} + + + + + + {% endfor %} + {% endif %} +
+

image arch

+
{{ architecture.name }}{{ architecture.get_success_test|default_if_none:"Never succeeded" }}{{ architecture.get_failed_test|default_if_none:"Never failed" }}
+

image type

+
{{ iso_type.name }}{{ iso_type.get_success_test|default_if_none:"Never succeeded" }}{{ iso_type.get_failed_test|default_if_none:"Never failed" }}
+

image boot

+
{{ boot_type.name }}{{ boot_type.get_success_test|default_if_none:"Never succeeded" }}{{ boot_type.get_failed_test|default_if_none:"Never failed" }}
+

hardware type

+
{{ hardware_type.name }}{{ hardware_type.get_success_test|default_if_none:"Never succeeded" }}{{ hardware_type.get_failed_test|default_if_none:"Never failed" }}
+

install type

+
{{ install_type.name }}{{ install_type.get_success_test|default_if_none:"Never succeeded" }}{{ install_type.get_failed_test|default_if_none:"Never failed" }}
+

source selection

+
{{ source.name }}{{ source.get_success_test|default_if_none:"Never succeeded" }}{{ source.get_failed_test|default_if_none:"Never failed" }}
+

clock

+
{{ clock_choice.name }}{{ clock_choice.get_success_test|default_if_none:"Never succeeded" }}{{ clock_choice.get_failed_test|default_if_none:"Never failed" }}
+

partitioning/filesystems

+
{{ filesystem.name }}{{ filesystem.get_success_test|default_if_none:"Never succeeded" }}{{ filesystem.get_failed_test|default_if_none:"Never failed" }}
+

fancy stuff

+
{{ module.name }}{{ module.get_success_test|default_if_none:"Never succeeded" }}{{ module.get_failed_test|default_if_none:"Never failed" }}
+

rollback

+
yes
no
+

rollback: partitioning/filesystems

+
{{ filesystem.name }}{{ filesystem.get_success_test|default_if_none:"Never succeeded" }}{{ filesystem.get_failed_test|default_if_none:"Never failed" }}
+

rollback: fancy stuff

+
{{ module.name }}{{ module.get_success_test|default_if_none:"Never succeeded" }}{{ module.get_failed_test|default_if_none:"Never failed" }}
+

bootloader

+
{{ bootloader.name }}{{ bootloader.get_success_test|default_if_none:"Never succeeded" }}{{ bootloader.get_failed_test|default_if_none:"Never failed" }}
{% endblock %} diff --git a/templates/isotests/test_list.html b/templates/isotests/test_list.html deleted file mode 100644 index 1ef39a4c..00000000 --- a/templates/isotests/test_list.html +++ /dev/null @@ -1,18 +0,0 @@ -{% extends "base.html" %} - -{% block title %}Arch Linux - Testresults{% endblock %} - -{% block content %} -
-

Arch releng iso build test results

- {% if object_list %} - - {% else %} -

No test results are available.

- {% endif %} -
-{% endblock %} -- cgit v1.2.3-55-g3dc8 From db137d4db607461dd32c46e40bee9084eb508da9 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Thu, 31 Mar 2011 22:39:40 +0200 Subject: isotests: add syncisos command * Installtype fixture places 'interactive' at the top now. * Added a syncisos command to isotests to get new iso names from http://releng.archlinux.org/isos/ and add them to the database. Signed-off-by: Dan McGee --- isotests/fixtures/installtype.json | 8 ++--- isotests/management/__init__.py | 0 isotests/management/commands/__init__.py | 0 isotests/management/commands/syncisos.py | 51 ++++++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 isotests/management/__init__.py create mode 100644 isotests/management/commands/__init__.py create mode 100644 isotests/management/commands/syncisos.py diff --git a/isotests/fixtures/installtype.json b/isotests/fixtures/installtype.json index d23bd4b2..cc5c62a0 100644 --- a/isotests/fixtures/installtype.json +++ b/isotests/fixtures/installtype.json @@ -3,28 +3,28 @@ "pk": 1, "model": "isotests.installtype", "fields": { - "name": "automatic install generic example" + "name": "interactive install" } }, { "pk": 2, "model": "isotests.installtype", "fields": { - "name": "automatic install fancy example" + "name": "automatic install generic example" } }, { "pk": 3, "model": "isotests.installtype", "fields": { - "name": "automatic install custom config (specify in comments)" + "name": "automatic install fancy example" } }, { "pk": 4, "model": "isotests.installtype", "fields": { - "name": "interactive install" + "name": "automatic install custom config (specify in comments)" } } ] diff --git a/isotests/management/__init__.py b/isotests/management/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/isotests/management/commands/__init__.py b/isotests/management/commands/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/isotests/management/commands/syncisos.py b/isotests/management/commands/syncisos.py new file mode 100644 index 00000000..975104d9 --- /dev/null +++ b/isotests/management/commands/syncisos.py @@ -0,0 +1,51 @@ +import re +import urllib +from HTMLParser import HTMLParser, HTMLParseError + +from django.core.management.base import BaseCommand, CommandError + +from isotests.models import Iso +from settings import ISOLISTURL + +class IsoListParser(HTMLParser): + def __init__(self): + HTMLParser.__init__(self) + + self.hyperlinks = [] + self.url_re = re.compile('(?!\.{2})/$') + + def handle_starttag(self, tag, attrs): + if tag == 'a': + for name, value in attrs: + if name == "href": + if value != '../' and self.url_re.search(value) != None: + self.hyperlinks.append(value[:len(value)-1]) + + def parse(self, url): + try: + f = urllib.urlopen(url) + + s = f.read() + f.close() + + self.feed(s) + self.close() + + return self.hyperlinks + except HTMLParseError: + raise CommandError('Couldn\'t parse "%s"' % url) + +class Command(BaseCommand): + help = 'Gets new isos from http://releng.archlinux.org/isos/' + + def handle(self, *args, **options): + parser = IsoListParser() + isonames = Iso.objects.values_list('name', flat=True) + new_isos = parser.parse(ISOLISTURL) + + for iso in new_isos: + if iso not in isonames: + new = Iso(name=iso) + new.save() + +# vim: set ts=4 sw=4 et: -- cgit v1.2.3-55-g3dc8 From c292dcfc6bf96ebf5f34342beb1367aa5361f7c4 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Thu, 28 Apr 2011 13:19:42 -0500 Subject: isotests: various changes and updates * isotests/fixtures/clockchoices.json: changed 'default' to 'unchanged' * isotests/fixtures/filesystems.json: removed 'check the installed system' line from one of the options * isotests/fixtures/modules.json: added 'ext2','ext3','ext4','swap','xfs','jfs','reiserFS' * isotests/models.py: * Added RollbackOption abstract class that adds the functions get_rollback_success_test and get_rollback_failed_test on top of the IsoOption abstract class for use with the Filesystem and Module classes since Test uses these both in 2 ways (regular and rollback). This keeps them seperated. * renamed the related names of these properties from rollback_test to rollback_test_set (seems more in-tune with the other relations) * isotests/views.py: * changed the order of the fields, the automatic order makes no sense. * Added help texts to the fields success, filesystem, rollback_filesystem and rollback_modules. * Removed help text from modules (made no sense) * Added a website field, should remain empty, a simplistic way to hopefully reduce spambot entries. * templates/isotests/results.html: * Removed the rollback yes/no section * The rollback labels should check get_rollback_success_test and get_rollback_failed_test. * Rollback checkbox removed. * Clearly tell users that success must only be selected if everything works right. * Clearly tell users to only fill in the rollback options if they did a rollback. * Added a thanks page that tells people thanks. * Added links between the pages. * Added links to lists with tests of either a specific iso or of any iso where a specific option was selected. Signed-off-by: Dan McGee Conflicts: templates/isotests/results.html --- isotests/fixtures/clockchoices.json | 2 +- isotests/fixtures/filesystems.json | 2 +- isotests/fixtures/modules.json | 49 +++ isotests/models.py | 51 +++- isotests/urls.py | 8 +- isotests/views.py | 64 +++- templates/isotests/add.html | 2 + templates/isotests/result_list.html | 34 +++ templates/isotests/results.html | 595 +++++++++++++++++++++++++----------- templates/isotests/thanks.html | 14 + templates/public/index.html | 2 + 11 files changed, 616 insertions(+), 207 deletions(-) create mode 100644 templates/isotests/result_list.html create mode 100644 templates/isotests/thanks.html diff --git a/isotests/fixtures/clockchoices.json b/isotests/fixtures/clockchoices.json index 2c078128..6dfd06e1 100644 --- a/isotests/fixtures/clockchoices.json +++ b/isotests/fixtures/clockchoices.json @@ -3,7 +3,7 @@ "pk": 1, "model": "isotests.clockchoice", "fields": { - "name": "default" + "name": "unchanged" } }, { diff --git a/isotests/fixtures/filesystems.json b/isotests/fixtures/filesystems.json index 4d3f1bc4..5386c391 100644 --- a/isotests/fixtures/filesystems.json +++ b/isotests/fixtures/filesystems.json @@ -3,7 +3,7 @@ "pk": 1, "model": "isotests.filesystem", "fields": { - "name": "autoprepare (check the installed system, incl fstab)" + "name": "autoprepare" } }, { diff --git a/isotests/fixtures/modules.json b/isotests/fixtures/modules.json index 27d04c7a..ae8a1683 100644 --- a/isotests/fixtures/modules.json +++ b/isotests/fixtures/modules.json @@ -33,5 +33,54 @@ "fields": { "name": "btrfs" } + }, + { + "pk": 6, + "model": "isotests.module", + "fields": { + "name": "ext2" + } + }, + { + "pk": 7, + "model": "isotests.module", + "fields": { + "name": "ext3" + } + }, + { + "pk": 8, + "model": "isotests.module", + "fields": { + "name": "ext4" + } + }, + { + "pk": 9, + "model": "isotests.module", + "fields": { + "name": "swap" + } + }, + { + "pk": 10, + "model": "isotests.module", + "fields": { + "name": "xfs" + } + }, + { + "pk": 11, + "model": "isotests.module", + "fields": { + "name": "jfs" + } + }, + { + "pk": 12, + "model": "isotests.module", + "fields": { + "name": "reiserFS" + } } ] diff --git a/isotests/models.py b/isotests/models.py index bffb2d94..ae5bf96f 100644 --- a/isotests/models.py +++ b/isotests/models.py @@ -7,19 +7,49 @@ class IsoOption(models.Model): name = models.CharField(max_length=200) + success_tests = None + failed_tests = None + def __unicode__(self): return str(self.name) def get_success_test(self): - test = self.test_set.filter(success=True).annotate(Max('iso__id')) - if test: - return test[0].iso.name + if not self.success_tests: + self.success_tests = self.test_set.filter(success=True).annotate(Max('iso__id')) + + if self.success_tests: + return self.success_tests[0].iso return None def get_failed_test(self): - test = self.test_set.filter(success=False).annotate(Max('iso__id')) - if test: - return test[0].iso.name + if not self.failed_tests: + self.failed_tests = self.test_set.filter(success=False).annotate(Max('iso__id')) + + if self.failed_tests: + return self.failed_tests[0].iso + return None + +class RollbackOption(IsoOption): + class Meta: + abstract = True + + success_rollback_tests = None + failed_rollback_tests = None + + def get_rollback_success_test(self): + if not self.success_rollback_tests: + self.success_rollback_tests = self.rollback_test_set.filter(success=True).annotate(Max('iso__id')) + + if self.success_rollback_tests: + return self.success_rollback_tests[0].iso + return None + + def get_rollback_failed_test(self): + if not self.failed_rollback_tests: + self.failed_rollback_tests = self.rollback_test_set.filter(success=False).annotate(Max('iso__id')) + + if self.failed_rollback_tests: + return self.failed_rollback_tests[0].iso return None class Iso(models.Model): @@ -50,10 +80,10 @@ class Source(IsoOption): class ClockChoice(IsoOption): pass -class Filesystem(IsoOption): +class Filesystem(RollbackOption): pass -class Module(IsoOption): +class Module(RollbackOption): pass class Bootloader(IsoOption): @@ -72,11 +102,10 @@ class Test(models.Model): clock_choice = models.ForeignKey(ClockChoice) filesystem = models.ForeignKey(Filesystem) modules = models.ManyToManyField(Module, null=True, blank=True) - rollback = models.BooleanField() rollback_filesystem = models.ForeignKey(Filesystem, - related_name="rollback_test", null=True, blank=True) + related_name="rollback_test_set", null=True, blank=True) rollback_modules = models.ManyToManyField(Module, - related_name="rollback_test", null=True, blank=True) + related_name="rollback_test_set", null=True, blank=True) bootloader = models.ForeignKey(Bootloader) success = models.BooleanField() comments = models.TextField(null=True, blank=True) diff --git a/isotests/urls.py b/isotests/urls.py index f60f0bc9..7f438368 100644 --- a/isotests/urls.py +++ b/isotests/urls.py @@ -1,8 +1,12 @@ from django.conf.urls.defaults import patterns urlpatterns = patterns('isotests.views', - (r'^$', 'view_results'), - (r'^add/$', 'add_result') + (r'^$', 'view_results'), + (r'^add/$', 'add_result'), + (r'^thanks/$', 'thanks'), + (r'^results/$', 'view_results'), + (r'^results/(?P