testbot/Engine: Fix support for interfacing directly with the wine-patches mailing list.

Francois Gouget fgouget at codeweavers.com
Mon Oct 15 08:35:04 CDT 2012


---

Compatibility Note: If applying this to an existing WineTestBot 
server, the database schema update will need to be updated.

 testbot/bin/Engine.pl                    |   29 +++++++++++++------------
 testbot/bin/WinePatchesWebGet.pl         |   34 +++++++++++++++---------------
 testbot/bin/WineSendLog.pl               |    6 +++---
 testbot/ddl/update12.sql                 |    8 +++++++
 testbot/ddl/winetestbot.sql              |    6 ++++--
 testbot/doc/winetestbot-schema.dia       |   30 +++++++++++++++++++++-----
 testbot/lib/WineTestBot/Engine/Notify.pm |    4 ++--
 testbot/lib/WineTestBot/Patches.pm       |    7 +++---
 8 files changed, 78 insertions(+), 46 deletions(-)
 create mode 100644 testbot/ddl/update12.sql

diff --git a/testbot/bin/Engine.pl b/testbot/bin/Engine.pl
index 29dd2f7..8723c9e 100755
--- a/testbot/bin/Engine.pl
+++ b/testbot/bin/Engine.pl
@@ -316,15 +316,15 @@ sub HandleWinePatchWebNotification
   }
   my $FullMessageFileName = "$DataDir/staging/$1";
 
-  my $LatestPatchId;
+  my $LatestWebPatchId;
   if (open(NOTIFICATION, "<$FullMessageFileName"))
   {
     my $Line;
-    while (defined($Line = <NOTIFICATION>) && ! defined($LatestPatchId))
+    while (defined($Line = <NOTIFICATION>) && ! defined($LatestWebPatchId))
     {
       if ($Line =~ m/^The latest patch is (\d+)$/)
       {
-        $LatestPatchId = $1;
+        $LatestWebPatchId = $1;
       }
     }
     close(NOTIFICATION);
@@ -332,29 +332,29 @@ sub HandleWinePatchWebNotification
 
   unlink($FullMessageFileName);
 
-  if (! defined($LatestPatchId))
+  if (! defined($LatestWebPatchId))
   {
     return "0No patch id found in message";
   }
 
-  my $MaxExistingPatchId = 0;
+  my $MaxExistingWebPatchId = 0;
   my $Patches = CreatePatches();
   foreach my $PatchKey (@{$Patches->GetKeys()})
   {
-    if ($MaxExistingPatchId < $Patches->GetItem($PatchKey)->Id)
+    if ($MaxExistingWebPatchId < $Patches->GetItem($PatchKey)->WebPatchId)
     {
-      $MaxExistingPatchId = $Patches->GetItem($PatchKey)->Id;
+      $MaxExistingWebPatchId = $Patches->GetItem($PatchKey)->WebPatchId;
     }
   }
 
-  if ($MaxExistingPatchId < $LatestPatchId)
+  if ($MaxExistingWebPatchId < $LatestWebPatchId)
   {
     $ActiveBackEnds{'WineTestBot'}->PrepareForFork();
     my $Pid = fork;
     if (defined($Pid) && ! $Pid)
     {
-      exec("$BinDir/WinePatchesWebGet.pl " . ($MaxExistingPatchId + 1) . " " .
-           $LatestPatchId);
+      exec("$BinDir/WinePatchesWebGet.pl " . ($MaxExistingWebPatchId + 1) .
+           " " . $LatestWebPatchId);
     }
     if (defined($Pid) && ! $Pid)
     {
@@ -382,11 +382,12 @@ sub HandleWinePatchWebSubmission
   {
     return "0Invalid patch id";
   }
-  my $PatchId = $1;
+  my $WebPatchId = $1;
   my $Patches = CreatePatches();
-  if (defined($Patches->GetItem($PatchId)))
+  $Patches->AddFilter("WebPatchId", [$WebPatchId]);
+  if (@{$Patches->GetKeys()})
   {
-    LogMsg "Engine: patch $PatchId already exists\n";
+    LogMsg "Engine: patch $WebPatchId already exists\n";
     return "1OK";
   }
 
@@ -402,7 +403,7 @@ sub HandleWinePatchWebSubmission
   my $Parser = new MIME::Parser;
   $Parser->output_dir($WorkDir);
   my $Entity = $Parser->parse_open($FullFileName);
-  my $ErrMessage = CreatePatches()->NewPatch($Entity, $PatchId);
+  my $ErrMessage = CreatePatches()->NewPatch($Entity, $WebPatchId);
 
   # Clean up
   system("rm -rf $WorkDir");
diff --git a/testbot/bin/WinePatchesWebGet.pl b/testbot/bin/WinePatchesWebGet.pl
index 8533b95..d1bcd4b 100755
--- a/testbot/bin/WinePatchesWebGet.pl
+++ b/testbot/bin/WinePatchesWebGet.pl
@@ -38,31 +38,31 @@ use WineTestBot::Log;
 use WineTestBot::Utils;
 use WineTestBot::Engine::Notify;
 
-my ($StartPatchId, $EndPatchId) = @ARGV;
-if (! $StartPatchId || ! $EndPatchId)
+my ($StartWebPatchId, $EndWebPatchId) = @ARGV;
+if (! $StartWebPatchId || ! $EndWebPatchId)
 {
-  die "Usage: WinePatchesWebGet.pl <StartPatchId> <EndPatchId>";
+  die "Usage: WinePatchesWebGet.pl <StartWebPatchId> <EndWebPatchId>";
 }
 
-if ($StartPatchId =~ m/^(\d+)$/)
+if ($StartWebPatchId =~ m/^(\d+)$/)
 {
-  $StartPatchId = $1;
+  $StartWebPatchId = $1;
 }
 else
 {
-  die "WinePatchesWebGet: Invalid StartPatchId $StartPatchId";
+  die "WinePatchesWebGet: Invalid StartWebPatchId $StartWebPatchId";
 }
-if ($EndPatchId =~ m/^(\d+)$/)
+if ($EndWebPatchId =~ m/^(\d+)$/)
 {
-  $EndPatchId = $1;
+  $EndWebPatchId = $1;
 }
 else
 {
-  die "WinePatchesWebGet: Invalid EndPatchId $EndPatchId";
+  die "WinePatchesWebGet: Invalid EndWebPatchId $EndWebPatchId";
 }
-if ($EndPatchId < $StartPatchId)
+if ($EndWebPatchId < $StartWebPatchId)
 {
-  die "WinePatchesWebGet: EndPatchId $EndPatchId shouldn't be smaller than StartPatchId $StartPatchId";
+  die "WinePatchesWebGet: EndWebPatchId $EndWebPatchId shouldn't be smaller than StartWebPatchId $StartWebPatchId";
 }
 
 my $BaseURL = "http://source.winehq.org/patches/data";
@@ -70,9 +70,9 @@ my $BaseURL = "http://source.winehq.org/patches/data";
 my $UA = LWP::UserAgent->new();
 $UA->agent("WineTestBot");
 
-foreach my $PatchId ($StartPatchId..$EndPatchId)
+foreach my $WebPatchId ($StartWebPatchId..$EndWebPatchId)
 {
-  my $Request = HTTP::Request->new(GET => "$BaseURL/$PatchId");
+  my $Request = HTTP::Request->new(GET => "$BaseURL/$WebPatchId");
   my $Response = $UA->request($Request);
   if ($Response->code != RC_OK)
   {
@@ -81,11 +81,11 @@ foreach my $PatchId ($StartPatchId..$EndPatchId)
     exit 1;
   }
   my $FileNameRandomPart = GenerateRandomString(32);
-  while (-e "$DataDir/staging/${FileNameRandomPart}_patch_$PatchId")
+  while (-e "$DataDir/staging/${FileNameRandomPart}_patch_$WebPatchId")
   {
     $FileNameRandomPart = GenerateRandomString(32);
   }
-  my $StagingFileName = "$DataDir/staging/${FileNameRandomPart}_patch_$PatchId";
+  my $StagingFileName = "$DataDir/staging/${FileNameRandomPart}_patch_$WebPatchId";
   if (! open STAGINGFILE, ">$StagingFileName")
   {
     LogMsg "WinePatchesWebGet: can't create staging file $StagingFileName: $!\n";
@@ -94,9 +94,9 @@ foreach my $PatchId ($StartPatchId..$EndPatchId)
   print STAGINGFILE $Response->decoded_content();
   close STAGINGFILE;
 
-  WinePatchWebSubmission("${FileNameRandomPart}_patch_$PatchId", $PatchId);
+  WinePatchWebSubmission("${FileNameRandomPart}_patch_$WebPatchId", $WebPatchId);
 
-  LogMsg "WinePatchesWebGet: retrieved patch $PatchId\n";
+  LogMsg "WinePatchesWebGet: retrieved patch $WebPatchId\n";
 }
 
 exit;
diff --git a/testbot/bin/WineSendLog.pl b/testbot/bin/WineSendLog.pl
index c8c2dce..bc0e72b 100755
--- a/testbot/bin/WineSendLog.pl
+++ b/testbot/bin/WineSendLog.pl
@@ -445,13 +445,13 @@ EOF
     open (SENDMAIL, "|/usr/sbin/sendmail -oi -t -odq");
     print SENDMAIL "From: Marvin <$RobotEMail>\n";
     print SENDMAIL "To: $PatchResultsEMail\n";
-    print SENDMAIL "X-TestBot-Results: ", $Patch->Id,
+    print SENDMAIL "X-TestBot-Results: ", $Patch->WebPatchId,
           ($Messages ? " failed\n" : " passed\n");
-    print SENDMAIL "Subject: TestBot results for patch ", $Patch->Id,
+    print SENDMAIL "Subject: TestBot results for patch ", $Patch->WebPatchId,
           ($Messages ? ": Failed\n" : ": Passed\n");
     print SENDMAIL "\n";
     print SENDMAIL "--- BEGIN GENERAL ---\n";
-    print SENDMAIL "Patch: ", $Patch->Id, "\n";
+    print SENDMAIL "Patch: ", $Patch->WebPatchId, "\n";
     print SENDMAIL "Patch-Subject: ", $Patch->Subject, "\n";
     print SENDMAIL "Test-Result: ", $Messages ? "Failed" : "Passed", "\n";
     print SENDMAIL "--- END GENERAL ---\n";
diff --git a/testbot/ddl/update12.sql b/testbot/ddl/update12.sql
new file mode 100644
index 0000000..41024c4
--- /dev/null
+++ b/testbot/ddl/update12.sql
@@ -0,0 +1,8 @@
+ALTER TABLE Patches
+  MODIFY Id INT(7) NOT NULL AUTO_INCREMENT,
+  ADD WebPatchId INT(7) NULL
+      AFTER Id,
+  ADD INDEX PatchesWebPatchId (WebPatchId);
+
+UPDATE Patches
+  SET WebPatchId = Id;
diff --git a/testbot/ddl/winetestbot.sql b/testbot/ddl/winetestbot.sql
index 5f885c4..8734f9b 100644
--- a/testbot/ddl/winetestbot.sql
+++ b/testbot/ddl/winetestbot.sql
@@ -60,14 +60,16 @@ ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 CREATE TABLE Patches
 (
-  Id          INT(7)          NOT NULL,
+  Id          INT(7)          NOT NULL AUTO_INCREMENT,
+  WebPatchId  INT(7)          NULL,
   Received    DATETIME        NOT NULL,
   Disposition VARCHAR(40)     NOT NULL,
   AffectsTests ENUM('Y', 'N') NOT NULL,
   FromName    VARCHAR(40)     NULL,
   FromEMail   VARCHAR(40)     NULL,
   Subject     VARCHAR(120)    NULL,
-  PRIMARY KEY (Id)
+  PRIMARY KEY (Id),
+  INDEX PatchesWebPatchId (WebPatchId)
 )
 ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
diff --git a/testbot/doc/winetestbot-schema.dia b/testbot/doc/winetestbot-schema.dia
index aedb8f2..145a4e9 100644
--- a/testbot/doc/winetestbot-schema.dia
+++ b/testbot/doc/winetestbot-schema.dia
@@ -898,7 +898,7 @@
         <dia:point val="-16.4708,-2.55002"/>
       </dia:attribute>
       <dia:attribute name="obj_bb">
-        <dia:rectangle val="-16.4708,-2.55002;-5.9308,4.44998"/>
+        <dia:rectangle val="-16.4708,-2.55002;-5.9308,5.24998"/>
       </dia:attribute>
       <dia:attribute name="meta">
         <dia:composite type="dict"/>
@@ -910,7 +910,7 @@
         <dia:real val="10.539999999999999"/>
       </dia:attribute>
       <dia:attribute name="elem_height">
-        <dia:real val="7"/>
+        <dia:real val="7.7999999999999998"/>
       </dia:attribute>
       <dia:attribute name="text_colour">
         <dia:color val="#000000"/>
@@ -983,6 +983,26 @@
         </dia:composite>
         <dia:composite type="table_attribute">
           <dia:attribute name="name">
+            <dia:string>#WebPatchId#</dia:string>
+          </dia:attribute>
+          <dia:attribute name="type">
+            <dia:string>#INT(7)#</dia:string>
+          </dia:attribute>
+          <dia:attribute name="comment">
+            <dia:string>##</dia:string>
+          </dia:attribute>
+          <dia:attribute name="primary_key">
+            <dia:boolean val="false"/>
+          </dia:attribute>
+          <dia:attribute name="nullable">
+            <dia:boolean val="true"/>
+          </dia:attribute>
+          <dia:attribute name="unique">
+            <dia:boolean val="false"/>
+          </dia:attribute>
+        </dia:composite>
+        <dia:composite type="table_attribute">
+          <dia:attribute name="name">
             <dia:string>#Received#</dia:string>
           </dia:attribute>
           <dia:attribute name="type">
@@ -2638,7 +2658,7 @@
         <dia:point val="-4.57083,-5.96669"/>
       </dia:attribute>
       <dia:attribute name="obj_bb">
-        <dia:rectangle val="-18.2307,-6.61669;-4.57083,-0.850023"/>
+        <dia:rectangle val="-18.2307,-6.61669;-4.57083,-0.85002"/>
       </dia:attribute>
       <dia:attribute name="meta">
         <dia:composite type="dict"/>
@@ -2646,8 +2666,8 @@
       <dia:attribute name="orth_points">
         <dia:point val="-4.57083,-5.96669"/>
         <dia:point val="-18.2307,-5.96669"/>
-        <dia:point val="-18.2307,-0.850023"/>
-        <dia:point val="-16.4708,-0.850023"/>
+        <dia:point val="-18.2307,-0.85002"/>
+        <dia:point val="-16.4708,-0.85002"/>
       </dia:attribute>
       <dia:attribute name="orth_orient">
         <dia:enum val="0"/>
diff --git a/testbot/lib/WineTestBot/Engine/Notify.pm b/testbot/lib/WineTestBot/Engine/Notify.pm
index abe9030..6bbec87 100644
--- a/testbot/lib/WineTestBot/Engine/Notify.pm
+++ b/testbot/lib/WineTestBot/Engine/Notify.pm
@@ -234,9 +234,9 @@ sub WinePatchWebNotification
 
 sub WinePatchWebSubmission
 {
-  my ($FileName, $PatchId) = @_;
+  my ($FileName, $WebPatchId) = @_;
 
-  my $Reply = SendCmdReceiveReply("winepatchwebsubmission $FileName $PatchId\n");
+  my $Reply = SendCmdReceiveReply("winepatchwebsubmission $FileName $WebPatchId\n");
   if (length($Reply) < 1)
   {
     return "Unrecognized reply received from engine";
diff --git a/testbot/lib/WineTestBot/Patches.pm b/testbot/lib/WineTestBot/Patches.pm
index 48c5f53..be8ba9a 100644
--- a/testbot/lib/WineTestBot/Patches.pm
+++ b/testbot/lib/WineTestBot/Patches.pm
@@ -341,7 +341,8 @@ my @PropertyDescriptors;
 BEGIN
 {
   @PropertyDescriptors = (
-    CreateBasicPropertyDescriptor("Id", "Patch id", 1, 1, "N",  7),
+    CreateBasicPropertyDescriptor("Id", "Patch id", 1, 1, "S",  7),
+    CreateBasicPropertyDescriptor("WebPatchId", "Wine Web Patch id", !1, !1, "N",  7),
     CreateBasicPropertyDescriptor("Received", "Received", !1, 1, "DT", 19),
     CreateBasicPropertyDescriptor("AffectsTests", "Affects tests", !1, 1, "B", 1),
     CreateBasicPropertyDescriptor("FromName", "Author", !1, !1, "A", 40),
@@ -420,10 +421,10 @@ others, then C<WineTestBot::Patch::Submit()> is called right away.
 sub NewPatch
 {
   my $self = shift;
-  my ($MsgEntity, $PatchId) = @_;
+  my ($MsgEntity, $WebPatchId) = @_;
 
   my $Patch = $self->Add();
-  $Patch->Id($PatchId) if (defined $PatchId);
+  $Patch->WebPatchId($WebPatchId) if (defined $WebPatchId);
   $Patch->FromSubmission($MsgEntity);
 
   my @PatchBodies;
-- 
1.7.10.4




More information about the wine-patches mailing list