[tools] testbot: Take the patchset version into account.

Francois Gouget fgouget at codeweavers.com
Sun Mar 8 14:27:34 CDT 2020


This avoids errors when a new revision of a patchset is sent before
the previous one has been fully received.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48353
Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---

This patch requires updating the database schema by applying 
update43.sql and then restarting the web server and TestBot Engine.

Note that the foreign key deletion (PendingPatches_ibfk_1) is a bit 
fragile because the '_1' suffix gets incremented every time the 
foreign key gets recreated. But presumably the TestBot still has the 
original foreign key that got created by winetestbot.sql so '_1' should 
be the right value.

 testbot/bin/Janitor.pl                      |   3 +-
 testbot/ddl/update43.sql                    |  26 +++++
 testbot/ddl/winetestbot.sql                 |   8 +-
 testbot/doc/winetestbot-schema.dia          | 108 ++++++++++++++------
 testbot/lib/WineTestBot/PendingPatchSets.pm |   4 +-
 testbot/lib/WineTestBot/PendingPatches.pm   |   3 +-
 6 files changed, 115 insertions(+), 37 deletions(-)
 create mode 100644 testbot/ddl/update43.sql

diff --git a/testbot/bin/Janitor.pl b/testbot/bin/Janitor.pl
index bc9b87603c..9481d51adc 100755
--- a/testbot/bin/Janitor.pl
+++ b/testbot/bin/Janitor.pl
@@ -162,7 +162,8 @@ foreach my $Set (@{$Sets->GetItems()})
   if (! defined($MostRecentPatch) ||
       $MostRecentPatch->Received < $DeleteBefore)
   {
-    Trace "Deleting pending series for ", $Set->EMail, " (got ", join(" ", sort @Parts), " / ", $Set->TotalParts, ")\n";
+    my $Version = $Version eq "" ? "" : " v$Version";
+    Trace "Deleting pending series$Version for ", $Set->EMail, " (got ", join(" ", sort @Parts), " / ", $Set->TotalParts, ")\n";
     next if ($DryRun);
 
     $Sets->DeleteItem($Set);
diff --git a/testbot/ddl/update43.sql b/testbot/ddl/update43.sql
new file mode 100644
index 0000000000..80d1a35bb5
--- /dev/null
+++ b/testbot/ddl/update43.sql
@@ -0,0 +1,26 @@
+USE winetestbot;
+
+ALTER TABLE PendingPatches
+  DROP FOREIGN KEY PendingPatches_ibfk_1;
+
+
+ALTER TABLE PendingPatchSets
+  ADD Version INT(2) NOT NULL
+      AFTER Email;
+
+ALTER TABLE PendingPatchSets
+  DROP PRIMARY KEY,
+  ADD PRIMARY KEY (EMail, Version, TotalParts);
+
+
+ALTER TABLE PendingPatches
+  ADD PendingPatchSetVersion INT(2) NOT NULL
+      AFTER PendingPatchSetEmail;
+
+ALTER TABLE PendingPatches
+  DROP PRIMARY KEY,
+  ADD PRIMARY KEY (PendingPatchSetEMail, PendingPatchSetVersion, PendingPatchSetTotalParts, No);
+
+ALTER TABLE PendingPatches
+  ADD FOREIGN KEY (PendingPatchSetEMail, PendingPatchSetVersion, PendingPatchSetTotalParts)
+      REFERENCES PendingPatchSets(EMail, Version, TotalParts);
diff --git a/testbot/ddl/winetestbot.sql b/testbot/ddl/winetestbot.sql
index e1cb5714f3..533941dd62 100644
--- a/testbot/ddl/winetestbot.sql
+++ b/testbot/ddl/winetestbot.sql
@@ -82,19 +82,21 @@ ENGINE=InnoDB DEFAULT CHARSET=utf8;
 CREATE TABLE PendingPatchSets
 (
   EMail      VARCHAR(40) NOT NULL,
+  Version    INT(2)      NOT NULL,
   TotalParts INT(2)      NOT NULL,
-  PRIMARY KEY (EMail, TotalParts)
+  PRIMARY KEY (EMail, Version, TotalParts)
 )
 ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 CREATE TABLE PendingPatches
 (
   PendingPatchSetEMail      VARCHAR(40) NOT NULL,
+  PendingPatchSetVersion    INT(2)      NOT NULL,
   PendingPatchSetTotalParts INT(2)      NOT NULL,
   No                        INT(2)      NOT NULL,
   PatchId                   INT(7)      NOT NULL,
-  FOREIGN KEY (PendingPatchSetEMail, PendingPatchSetTotalParts)
-          REFERENCES PendingPatchSets(EMail, TotalParts),
+  FOREIGN KEY (PendingPatchSetEMail, PendingPatchSetVersion, PendingPatchSetTotalParts)
+          REFERENCES PendingPatchSets(EMail, Version, TotalParts),
   FOREIGN KEY (PatchId) REFERENCES Patches(Id),
   PRIMARY KEY (PendingPatchSetEMail, PendingPatchSetTotalParts, No)
 )
diff --git a/testbot/doc/winetestbot-schema.dia b/testbot/doc/winetestbot-schema.dia
index 81ab656b7f..a5ef142bd2 100644
--- a/testbot/doc/winetestbot-schema.dia
+++ b/testbot/doc/winetestbot-schema.dia
@@ -962,22 +962,22 @@
     </dia:object>
     <dia:object type="Database - Table" version="0" id="O8">
       <dia:attribute name="obj_pos">
-        <dia:point val="-16.4708,-2.55002"/>
+        <dia:point val="-16.3208,-2.55002"/>
       </dia:attribute>
       <dia:attribute name="obj_bb">
-        <dia:rectangle val="-16.4708,-2.55002;-5.9308,6.04998"/>
+        <dia:rectangle val="-16.3208,-2.55002;-6.1658,5.24998"/>
       </dia:attribute>
       <dia:attribute name="meta">
         <dia:composite type="dict"/>
       </dia:attribute>
       <dia:attribute name="elem_corner">
-        <dia:point val="-16.4708,-2.55002"/>
+        <dia:point val="-16.3208,-2.55002"/>
       </dia:attribute>
       <dia:attribute name="elem_width">
-        <dia:real val="10.539999999999999"/>
+        <dia:real val="10.155000000000001"/>
       </dia:attribute>
       <dia:attribute name="elem_height">
-        <dia:real val="8.5999999999999996"/>
+        <dia:real val="7.7999999999999998"/>
       </dia:attribute>
       <dia:attribute name="name">
         <dia:string>#Patches#</dia:string>
@@ -1493,22 +1493,22 @@
     </dia:object>
     <dia:object type="Database - Table" version="0" id="O10">
       <dia:attribute name="obj_pos">
-        <dia:point val="-2.65417,-1.76669"/>
+        <dia:point val="-2.55417,-2.51669"/>
       </dia:attribute>
       <dia:attribute name="obj_bb">
-        <dia:rectangle val="-2.65417,-1.76669;12.5058,2.83331"/>
+        <dia:rectangle val="-2.55417,-2.51669;12.6058,2.88331"/>
       </dia:attribute>
       <dia:attribute name="meta">
         <dia:composite type="dict"/>
       </dia:attribute>
       <dia:attribute name="elem_corner">
-        <dia:point val="-2.65417,-1.76669"/>
+        <dia:point val="-2.55417,-2.51669"/>
       </dia:attribute>
       <dia:attribute name="elem_width">
         <dia:real val="15.16"/>
       </dia:attribute>
       <dia:attribute name="elem_height">
-        <dia:real val="4.6000000000000005"/>
+        <dia:real val="5.4000000000000004"/>
       </dia:attribute>
       <dia:attribute name="name">
         <dia:string>#PendingPatches#</dia:string>
@@ -1552,6 +1552,29 @@
             <dia:string>##</dia:string>
           </dia:attribute>
         </dia:composite>
+        <dia:composite type="table_attribute">
+          <dia:attribute name="name">
+            <dia:string>#PendingPatchSetVersion#</dia:string>
+          </dia:attribute>
+          <dia:attribute name="type">
+            <dia:string>#INT(2)#</dia:string>
+          </dia:attribute>
+          <dia:attribute name="comment">
+            <dia:string>##</dia:string>
+          </dia:attribute>
+          <dia:attribute name="primary_key">
+            <dia:boolean val="true"/>
+          </dia:attribute>
+          <dia:attribute name="nullable">
+            <dia:boolean val="false"/>
+          </dia:attribute>
+          <dia:attribute name="unique">
+            <dia:boolean val="true"/>
+          </dia:attribute>
+          <dia:attribute name="default_value">
+            <dia:string>##</dia:string>
+          </dia:attribute>
+        </dia:composite>
         <dia:composite type="table_attribute">
           <dia:attribute name="name">
             <dia:string>#PendingPatchSetTotalParts#</dia:string>
@@ -1658,7 +1681,7 @@
         <dia:point val="8.24583,-14.8834"/>
       </dia:attribute>
       <dia:attribute name="obj_bb">
-        <dia:rectangle val="8.24583,-14.8834;22.2508,-5.4834"/>
+        <dia:rectangle val="8.24583,-14.8834;22.2508,-6.2834"/>
       </dia:attribute>
       <dia:attribute name="meta">
         <dia:composite type="dict"/>
@@ -1670,7 +1693,7 @@
         <dia:real val="14.004999999999999"/>
       </dia:attribute>
       <dia:attribute name="elem_height">
-        <dia:real val="9.3999999999999986"/>
+        <dia:real val="8.5999999999999996"/>
       </dia:attribute>
       <dia:attribute name="name">
         <dia:string>#Steps#</dia:string>
@@ -1935,7 +1958,7 @@
         <dia:point val="25.4792,-14.8834"/>
       </dia:attribute>
       <dia:attribute name="obj_bb">
-        <dia:rectangle val="25.4792,-14.8834;36.0192,-5.4834"/>
+        <dia:rectangle val="25.4792,-14.8834;36.0192,-4.6834"/>
       </dia:attribute>
       <dia:attribute name="meta">
         <dia:composite type="dict"/>
@@ -1947,7 +1970,7 @@
         <dia:real val="10.539999999999999"/>
       </dia:attribute>
       <dia:attribute name="elem_height">
-        <dia:real val="9.3999999999999986"/>
+        <dia:real val="10.199999999999999"/>
       </dia:attribute>
       <dia:attribute name="name">
         <dia:string>#Tasks#</dia:string>
@@ -2258,7 +2281,7 @@
         <dia:point val="25.6708,-2.02919"/>
       </dia:attribute>
       <dia:attribute name="obj_bb">
-        <dia:rectangle val="25.6708,-2.02919;36.5958,10.5708"/>
+        <dia:rectangle val="25.6708,-2.02919;36.5958,12.1708"/>
       </dia:attribute>
       <dia:attribute name="meta">
         <dia:composite type="dict"/>
@@ -2270,7 +2293,7 @@
         <dia:real val="10.925000000000001"/>
       </dia:attribute>
       <dia:attribute name="elem_height">
-        <dia:real val="12.600000000000001"/>
+        <dia:real val="14.200000000000003"/>
       </dia:attribute>
       <dia:attribute name="name">
         <dia:string>#VMs#</dia:string>
@@ -3005,7 +3028,7 @@
         <dia:point val="-4.57083,-6.8167"/>
         <dia:point val="-18.2307,-6.8167"/>
         <dia:point val="-18.2307,-0.85002"/>
-        <dia:point val="-16.4708,-0.85002"/>
+        <dia:point val="-16.3208,-0.85002"/>
       </dia:attribute>
       <dia:attribute name="orth_orient">
         <dia:enum val="0"/>
@@ -3053,19 +3076,19 @@
     </dia:object>
     <dia:object type="Database - Reference" version="0" id="O20">
       <dia:attribute name="obj_pos">
-        <dia:point val="-5.9308,-0.85002"/>
+        <dia:point val="-6.1658,-0.85002"/>
       </dia:attribute>
       <dia:attribute name="obj_bb">
-        <dia:rectangle val="-5.9808,-1.50002;-2.60417,2.38331"/>
+        <dia:rectangle val="-6.2158,-1.50002;-2.50417,1.63331"/>
       </dia:attribute>
       <dia:attribute name="meta">
         <dia:composite type="dict"/>
       </dia:attribute>
       <dia:attribute name="orth_points">
-        <dia:point val="-5.9308,-0.85002"/>
+        <dia:point val="-6.1658,-0.85002"/>
         <dia:point val="-4.29249,-0.85002"/>
-        <dia:point val="-4.29249,2.33331"/>
-        <dia:point val="-2.65417,2.33331"/>
+        <dia:point val="-4.29249,1.58331"/>
+        <dia:point val="-2.55417,1.58331"/>
       </dia:attribute>
       <dia:attribute name="orth_orient">
         <dia:enum val="0"/>
@@ -3113,19 +3136,19 @@
     </dia:object>
     <dia:object type="Database - Reference" version="0" id="O21">
       <dia:attribute name="obj_pos">
-        <dia:point val="12.5058,-0.06669"/>
+        <dia:point val="12.6058,-0.81669"/>
       </dia:attribute>
       <dia:attribute name="obj_bb">
-        <dia:rectangle val="12.4558,-0.71669;15.3193,-2.33e-05"/>
+        <dia:rectangle val="12.5558,-1.50002;15.1193,-0.76669"/>
       </dia:attribute>
       <dia:attribute name="meta">
         <dia:composite type="dict"/>
       </dia:attribute>
       <dia:attribute name="orth_points">
-        <dia:point val="12.5058,-0.06669"/>
-        <dia:point val="13.7696,-0.06669"/>
-        <dia:point val="13.7696,-0.0500233"/>
-        <dia:point val="15.2693,-0.0500233"/>
+        <dia:point val="12.6058,-0.81669"/>
+        <dia:point val="13.7696,-0.81669"/>
+        <dia:point val="13.7696,-0.85002"/>
+        <dia:point val="15.0693,-0.85002"/>
       </dia:attribute>
       <dia:attribute name="orth_orient">
         <dia:enum val="0"/>
@@ -3173,22 +3196,22 @@
     </dia:object>
     <dia:object type="Database - Table" version="0" id="O22">
       <dia:attribute name="obj_pos">
-        <dia:point val="15.2693,-1.75002"/>
+        <dia:point val="15.0693,-2.55002"/>
       </dia:attribute>
       <dia:attribute name="obj_bb">
-        <dia:rectangle val="15.2693,-1.75002;24.6543,1.24998"/>
+        <dia:rectangle val="15.0693,-2.55002;24.4543,1.24998"/>
       </dia:attribute>
       <dia:attribute name="meta">
         <dia:composite type="dict"/>
       </dia:attribute>
       <dia:attribute name="elem_corner">
-        <dia:point val="15.2693,-1.75002"/>
+        <dia:point val="15.0693,-2.55002"/>
       </dia:attribute>
       <dia:attribute name="elem_width">
         <dia:real val="9.3850000000000016"/>
       </dia:attribute>
       <dia:attribute name="elem_height">
-        <dia:real val="3"/>
+        <dia:real val="3.7999999999999998"/>
       </dia:attribute>
       <dia:attribute name="name">
         <dia:string>#PendingPatchSets#</dia:string>
@@ -3232,6 +3255,29 @@
             <dia:string>##</dia:string>
           </dia:attribute>
         </dia:composite>
+        <dia:composite type="table_attribute">
+          <dia:attribute name="name">
+            <dia:string>#Version#</dia:string>
+          </dia:attribute>
+          <dia:attribute name="type">
+            <dia:string>#INT(2)#</dia:string>
+          </dia:attribute>
+          <dia:attribute name="comment">
+            <dia:string>##</dia:string>
+          </dia:attribute>
+          <dia:attribute name="primary_key">
+            <dia:boolean val="true"/>
+          </dia:attribute>
+          <dia:attribute name="nullable">
+            <dia:boolean val="false"/>
+          </dia:attribute>
+          <dia:attribute name="unique">
+            <dia:boolean val="true"/>
+          </dia:attribute>
+          <dia:attribute name="default_value">
+            <dia:string>##</dia:string>
+          </dia:attribute>
+        </dia:composite>
         <dia:composite type="table_attribute">
           <dia:attribute name="name">
             <dia:string>#TotalParts#</dia:string>
diff --git a/testbot/lib/WineTestBot/PendingPatchSets.pm b/testbot/lib/WineTestBot/PendingPatchSets.pm
index 9e386af588..0fedc52e63 100644
--- a/testbot/lib/WineTestBot/PendingPatchSets.pm
+++ b/testbot/lib/WineTestBot/PendingPatchSets.pm
@@ -191,6 +191,7 @@ sub CreateItem($)
 
 my @PropertyDescriptors = (
   CreateBasicPropertyDescriptor("EMail", "EMail of series author", 1, 1, "A", 40),
+  CreateBasicPropertyDescriptor("Version", "Version", 1, 1, "N", 2),
   CreateBasicPropertyDescriptor("TotalParts", "Expected number of parts in series", 1, 1, "N", 2),
   CreateDetailrefPropertyDescriptor("Parts", "Parts received so far", !1, !1, \&CreatePendingPatches),
 );
@@ -233,11 +234,12 @@ sub NewSubmission($$$)
     return undef;
   }
 
-  my $Set = $self->GetItem($self->CombineKey($Patch->FromEMail, $SubjectInfo->{MaxPartNo}));
+  my $Set = $self->GetItem($self->CombineKey($Patch->FromEMail, $SubjectInfo->{Version}, $SubjectInfo->{MaxPartNo}));
   if (! defined($Set))
   {
     $Set = $self->Add();
     $Set->EMail($Patch->FromEMail);
+    $Set->Version($SubjectInfo->{Version});
     $Set->TotalParts($SubjectInfo->{MaxPartNo});
   }
 
diff --git a/testbot/lib/WineTestBot/PendingPatches.pm b/testbot/lib/WineTestBot/PendingPatches.pm
index 74121d7477..118c74900d 100644
--- a/testbot/lib/WineTestBot/PendingPatches.pm
+++ b/testbot/lib/WineTestBot/PendingPatches.pm
@@ -69,6 +69,7 @@ my @PropertyDescriptors = (
 );
 my @FlatPropertyDescriptors = (
   CreateBasicPropertyDescriptor("PendingPatchSetEMail", "EMail of series author", 1, 1, "A", 40),
+  CreateBasicPropertyDescriptor("PendingPatchSetVersion", "Expected version of the series", 1, 1, "N", 2),
   CreateBasicPropertyDescriptor("PendingPatchSetTotalParts", "Expected number of parts in series", 1, 1, "N", 2),
   @PropertyDescriptors
 );
@@ -83,7 +84,7 @@ corresponding parts. In this case the PendingPatch objects don't store the
 key of their parent.
 
 If no PendingPatchSet object is specified all the table rows are returned and
-the PendingPatch objects have PendingPatchSetEMail and
+the PendingPatch objects have PendingPatchSetEMail, PendingPatchSetVersion and
 PendingPatchSetTotalParts properties.
 
 =back
-- 
2.20.1



More information about the wine-devel mailing list