Commit a159dcdc authored by Arkadiusz Hiler's avatar Arkadiusz Hiler

api: Make /newrevision/ copy a revision and mark it as rerun

Up until this patch, rerunning was just creating a 'newrevision' event
for the existing revision, effectively queuing it again. Any incoming
results would overwrite the existing ones.

Now, whenever rerun is hit, the last revision will be duplicated (no
results overwriting!), bumping "Last Update" time for the series. We
also mark such series as a rerun so we will be able to display it for
the users / expose it in the API.
Signed-off-by: Arkadiusz Hiler's avatarArkadiusz Hiler <arkadiusz.hiler@intel.com>
parent 2a4a395a
# -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2018-11-27 20:31
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('patchwork', '0028_auto_20180220_2246'),
]
operations = [
migrations.AddField(
model_name='seriesrevision',
name='is_rerun',
field=models.BooleanField(default=False),
),
]
......@@ -611,6 +611,7 @@ class SeriesRevision(models.Model):
state_summary = jsonfield.JSONField(null=True)
test_state = models.SmallIntegerField(choices=TestState.STATE_CHOICES,
null=True, blank=True)
is_rerun = models.BooleanField(default=False)
class Meta:
unique_together = [('series', 'version')]
......
......@@ -395,6 +395,14 @@ class EventTest(APITestBase):
self.assertEqual(403, ret.status_code)
self.assertEqual(events_before['count'], events_after['count'])
def testRetestApiEndpointCreatesNewRerunRevision(self):
revisions_before = list(self.series.revisions())
self.post(NEW_REV_URL, user=self.maintainer)
revisions_after = list(self.series.revisions())
self.assertEqual(len(revisions_before) + 1, len(revisions_after))
self.assertTrue(revisions_after[-1].is_rerun)
def testPullRequestEvent(self):
submitter = Person()
submitter.save()
......
......@@ -27,7 +27,7 @@ from django.http import HttpResponse
from patchwork.tasks import send_reviewer_notification
from patchwork.models import (Project, Series, SeriesRevision, Patch, EventLog,
State, Test, TestResult, TestState, Person,
RevisionState, Event)
RevisionState)
from rest_framework import (views, viewsets, mixins, filters, permissions,
status)
from rest_framework.authentication import BasicAuthentication
......@@ -315,11 +315,9 @@ class RevisionViewSet(mixins.ListModelMixin, ListMixin,
raise PermissionDenied
# log event
new_revision = Event.objects.get(name='series-new-revision')
log = EventLog(event=new_revision, series=rev.series,
user=request.user,
parameters={'revision': rev.version})
log.save()
new_rev = rev.duplicate()
new_rev.is_rerun = True
new_rev.save()
return HttpResponse()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment