]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1540857 - Change simple ping document id
authorDylan William Hardison <dylan@hardison.net>
Thu, 4 Apr 2019 15:25:44 +0000 (11:25 -0400)
committerGitHub <noreply@github.com>
Thu, 4 Apr 2019 15:25:44 +0000 (11:25 -0400)
.circleci/config.yml
Bugzilla/Model/Result/Bug.pm
Bugzilla/Report/Ping/Simple.pm
Dockerfile
Makefile.PL
t/report-ping-simple.t

index 41b13594e646c18747db1732b5101dbc062e09fc..9ef319400cd90e45c133cad37b2a790a2f85161e 100644 (file)
@@ -7,7 +7,7 @@ version: 2
 
 defaults:
   bmo_slim_image: &bmo_slim_image
-    image: mozillabteam/bmo-slim:20190322.1
+    image: mozillabteam/bmo-slim:20190404.1
     user: app
 
   mysql_image: &mysql_image
index 4ec5b71ecec92636d2f937b2a4f367375f8081c9..42938bd5468d4b750c2f426aa7a283a703d9a09e 100644 (file)
@@ -8,15 +8,16 @@
 package Bugzilla::Model::Result::Bug;
 use Mojo::Base 'DBIx::Class::Core';
 
-__PACKAGE__->load_components('Helper::Row::NumifyGet');
+__PACKAGE__->load_components(qw( Helper::Row::NumifyGet InflateColumn::DateTime ));
 
 __PACKAGE__->table(Bugzilla::Bug->DB_TABLE);
 __PACKAGE__->add_columns(Bugzilla::Bug->DB_COLUMN_NAMES);
 __PACKAGE__->add_columns(
-  '+bug_id'   => {is_numeric => 1},
-  '+reporter' => {is_numeric => 1},
-  '+qa_contact' => {is_numeric => 1},
+  '+bug_id'      => {is_numeric => 1},
+  '+reporter'    => {is_numeric => 1},
+  '+qa_contact'  => {is_numeric => 1},
   '+assigned_to' => {is_numeric => 1},
+  '+delta_ts'    => {data_type  => 'timestamp'},
 );
 __PACKAGE__->set_primary_key(Bugzilla::Bug->ID_FIELD);
 
index e3363872e85c0672a41ab76d0f2274b99e5c4322..94f0de67ad84da4e0e04c7353ccc16ac93f00d4a 100644 (file)
@@ -86,7 +86,13 @@ sub prepare {
     flags            => [map { $self->_prepare_flag($_) } $bug->flags->all],
   };
 
-  return ($bug->id, $doc);
+  return ($self->_prepare_doc_id($bug), $doc);
+}
+
+sub _prepare_doc_id {
+  my ($self, $bug) = @_;
+
+  return sprintf("%d-%d", $bug->id, $bug->delta_ts->epoch);
 }
 
 sub _prepare_flag {
index dd37244cce4f7845bb965c2c33311b6783dbcc6d..935bba7e2c18ccb5d6455651961a9e4d9414e944 100644 (file)
@@ -1,4 +1,4 @@
-FROM mozillabteam/bmo-slim:20190322.1
+FROM mozillabteam/bmo-slim:20190404.1
 
 ARG CI
 ARG CIRCLE_SHA1
index fc586951eccb75be453ced737b3ae1004d9e1e5d..12621b36417fe1c3ab0abe8d414b1510de3feb3f 100755 (executable)
@@ -100,19 +100,6 @@ my %requires = (
 );
 
 my %build_requires = ('ExtUtils::MakeMaker' => '7.22',);
-my %test_requires = (
-  'Capture::Tiny'                   => 0,
-  'DBD::SQLite'                     => '1.29',
-  'Perl::Critic::Freenode'          => 0,
-  'Perl::Tidy'                      => '20180220',
-  'Pod::Coverage'                   => 0,
-  'Test::More'                      => 0,
-  'Test::Perl::Critic::Progressive' => 0,
-  'Test::Selenium::Firefox'         => 0,
-  'Selenium::Remote::Driver'        => 1.31,
-  'Test::WWW::Selenium'             => 0,
-  'Test2::V0'                       => 0,
-);
 my %recommends = (Safe => '2.30',);
 
 # Windows requires some additional modules.
@@ -248,11 +235,11 @@ my %optional_features = (
   },
   sqlite => {
     description => 'SQLite database support',
-    prereqs     => {runtime => {requires => {'DBD::SQLite' => '1.29'}}},
+    prereqs     => {runtime => {requires => {'DBD::SQLite' => '1.29', 'DateTime::Format::SQLite' => '0.11'}}},
   },
   mysql => {
     description => 'MySQL database support',
-    prereqs     => {runtime => {requires => {'DBD::mysql' => '4.037'}}}
+    prereqs     => {runtime => {requires => {'DBD::mysql' => '4.037', 'DateTime::Format::MySQL' => '0.06'}}}
   },
   jsonrpc => {
     description => 'JSON-RPC Interface',
@@ -371,6 +358,21 @@ for my $file (glob 'extensions/*/Config.pm') {
   }
 }
 
+my %test_requires = (
+  %{ $optional_features{sqlite}{prereqs}{runtime}{requires} },
+  'Capture::Tiny'                   => 0,
+  'DBD::SQLite'                     => '1.29',
+  'Perl::Critic::Freenode'          => 0,
+  'Perl::Tidy'                      => '20180220',
+  'Pod::Coverage'                   => 0,
+  'Test::More'                      => 0,
+  'Test::Perl::Critic::Progressive' => 0,
+  'Test::Selenium::Firefox'         => 0,
+  'Selenium::Remote::Driver'        => 1.31,
+  'Test::WWW::Selenium'             => 0,
+  'Test2::V0'                       => 0,
+);
+
 # BMO Customization
 my @bmo_features = grep { is_bmo_feature($_) } keys %optional_features;
 
index f1f532b4a73b706aa895e1c4f3f6524968b849f4..f2cf56decf5fd9d7300af27f65a652bba2e3dde9 100644 (file)
@@ -12,12 +12,16 @@ use lib qw( . lib local/lib/perl5 );
 BEGIN {
   unlink('data/db/report_ping_simple') if -f 'data/db/report_ping_simple';
   $ENV{test_db_name} = 'report_ping_simple';
+  # Our code will store dates in localtime with sqlite.
+  # So for these tests to pass, everything should be UTC.
+  $ENV{TZ} = 'UTC';
 }
 
 use Bugzilla::Test::MockDB;
 use Bugzilla::Test::MockParams (password_complexity => 'no_constraints');
 use Bugzilla::Test::Util qw(create_bug create_user);
 use Bugzilla;
+use Bugzilla::Util qw(datetime_from);
 use Bugzilla::Constants;
 use Bugzilla::Hook;
 BEGIN { Bugzilla->extensions }
@@ -30,14 +34,27 @@ use ok 'Bugzilla::Report::Ping::Simple';
 Bugzilla->dbh->model->resultset('Keyword')
   ->create({name => 'regression', description => 'the regression keyword'});
 
+# Our code will store dates in localtime with sqlite.
+# So for these tests to pass, everything should be UTC.
+my $UTC = DateTime::TimeZone->new(name => 'UTC');
+Bugzilla->local_timezone($UTC);
+my $User = mock 'Bugzilla::User' => (
+  override => [ timezone => sub { $UTC } ]
+);
+
 my $user = create_user('reportuser@invalid.tld', '*');
 Bugzilla->set_user($user);
-create_bug(
-  short_desc  => "test bug $_",
-  comment     => "Hello, world: $_",
-  provided $_ % 3 == 0, keywords => ['regression'],
-  assigned_to => 'reportuser@invalid.tld'
-) for (1..250);
+
+my %time;
+for (1..250) {
+  my $bug = create_bug(
+    short_desc  => "test bug $_",
+    comment     => "Hello, world: $_",
+    provided $_ % 3 == 0, keywords => ['regression'],
+    assigned_to => 'reportuser@invalid.tld'
+  );
+  $time{ $bug->id } = datetime_from($bug->delta_ts)->epoch;
+}
 
 my $report = Bugzilla::Report::Ping::Simple->new(
   base_url => 'http://localhost',
@@ -54,7 +71,8 @@ is($rs->first->id, 1, "first bug of page 1 is 1");
 my ($first, $second, $third, @rest) = $rs->all;
 {
   my ($id, $doc) = $report->prepare( $first );
-  is($id, 1, "doc id is 1");
+
+  is($id, "1-$time{1}", "doc id is correct");
   is($doc->{product}, 'Firefox');
   is($doc->{keywords}, []);
   is([map { "$_" } $report->validate($doc)], [], "No errors for first doc");
@@ -62,7 +80,7 @@ my ($first, $second, $third, @rest) = $rs->all;
 
 {
   my ($id, $doc) = $report->prepare( $third );
-  is($id, 3, "doc id is 3");
+  is($id, "3-$time{3}", "doc id is correct");
   is($doc->{product}, 'Firefox');
   is($doc->{keywords}, ['regression']);
 }