summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2018-04-08 21:19:01 +0200
committerGitHub <noreply@github.com>2018-04-08 21:19:01 +0200
commite8f272c6f79dc8a919911d88a5b455bc67792f64 (patch)
tree01f8cd3965e1db810573f65508ded737d86d82fd
parent3293a1f85c9e20893e6823d1f83b667ec9ca9534 (diff)
downloadbugzilla-e8f272c6f79dc8a919911d88a5b455bc67792f64.tar.gz
bugzilla-e8f272c6f79dc8a919911d88a5b455bc67792f64.tar.xz
Bug 1427884 - Add upgrade tests from 4.2 to Harmony on mysql
-rw-r--r--.circleci/config.yml33
-rw-r--r--Bugzilla/DB/Schema/Mysql.pm2
-rw-r--r--Bugzilla/Group.pm29
-rw-r--r--Bugzilla/Install/DB.pm11
-rw-r--r--extensions/ComponentWatching/Extension.pm4
-rw-r--r--extensions/ContributorEngagement/Extension.pm4
-rw-r--r--extensions/EditComments/Extension.pm4
-rw-r--r--extensions/RestrictComments/Extension.pm4
-rw-r--r--extensions/Review/Extension.pm6
-rw-r--r--extensions/SecureMail/Extension.pm2
-rw-r--r--extensions/TagNewUsers/Extension.pm15
-rw-r--r--extensions/UserProfile/Extension.pm4
-rwxr-xr-x[-rw-r--r--]jobqueue-worker.pl0
-rwxr-xr-xscripts/entrypoint.pl4
14 files changed, 96 insertions, 26 deletions
diff --git a/.circleci/config.yml b/.circleci/config.yml
index f5b35833a..de4f2549d 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -150,6 +150,28 @@ jobs:
path: /app/artifacts
- *store_log
+ migrate_4.2_mysql:
+ parallelism: 1
+ working_directory: /app
+ docker:
+ - <<: *bmo_slim_image
+ environment:
+ <<: *bmo_env
+ BMO_urlbase: http://localhost/
+ DB_DUMP_URL: "https://github.com/bugzilla/harmony-test-fixtures/blob/master/db-dumps/bugzilla-4.2_mysql.sql.gz?raw=true"
+ DB_DUMP_FILE: "bugzilla-4.2_mysql.sql"
+ - <<: *mysql_image
+ environment: *mysql_env
+ steps:
+ - checkout
+ - run: |
+ mv /opt/bmo/local /app/local
+ /app/scripts/entrypoint.pl wait_for_db
+ curl -L "$DB_DUMP_URL" > "$DB_DUMP_FILE"
+ zcat "$DB_DUMP_FILE" | mysql -u$BMO_db_user -p$BMO_db_pass -h $BMO_db_host $BMO_db_name
+ perl checksetup.pl
+
+
test_bmo:
parallelism: 1
working_directory: /app
@@ -189,9 +211,20 @@ workflows:
- test_selenium
- test_sanity:
filters: *main_filters
+ - migrate_4.2_mysql:
+ filters: *main_filters
- test_bmo:
filters: *main_filters
- test_webservices:
filters: *main_filters
- test_selenium:
filters: *main_filters
+ requires:
+ - test_sanity
+ - migrate_4.2_mysql
+ - build:
+ filters: *main_filters
+ requires:
+ - test_sanity
+ - test_bmo
+ - test_webservices
diff --git a/Bugzilla/DB/Schema/Mysql.pm b/Bugzilla/DB/Schema/Mysql.pm
index 0b88d94a6..5893c6a80 100644
--- a/Bugzilla/DB/Schema/Mysql.pm
+++ b/Bugzilla/DB/Schema/Mysql.pm
@@ -125,7 +125,7 @@ sub _get_create_table_ddl {
my($self, $table) = @_;
- my $charset = Bugzilla->dbh->bz_db_is_utf8 ? "CHARACTER SET utf8" : '';
+ my $charset = "CHARACTER SET utf8";
my $type = grep($_ eq $table, MYISAM_TABLES) ? 'MYISAM' : 'InnoDB';
return($self->SUPER::_get_create_table_ddl($table)
. " ENGINE = $type $charset");
diff --git a/Bugzilla/Group.pm b/Bugzilla/Group.pm
index fe2a90c05..06491f6a0 100644
--- a/Bugzilla/Group.pm
+++ b/Bugzilla/Group.pm
@@ -26,17 +26,24 @@ use Scalar::Util qw(blessed);
use constant IS_CONFIG => 1;
-use constant DB_COLUMNS => qw(
- groups.id
- groups.name
- groups.description
- groups.isbuggroup
- groups.userregexp
- groups.isactive
- groups.icon_url
- groups.owner_user_id
- groups.idle_member_removal
-);
+sub DB_COLUMNS {
+ my $class = shift;
+ my @columns = qw(
+ id
+ name
+ description
+ isbuggroup
+ userregexp
+ isactive
+ icon_url
+ owner_user_id
+ idle_member_removal
+ );
+ my $dbh = Bugzilla->dbh;
+ my $table = $class->DB_TABLE;
+
+ return map { "$table.$_" } grep { $dbh->bz_column_info($table, $_) } @columns;
+}
use constant DB_TABLE => 'groups';
diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm
index 2c8a22448..0d63f68b9 100644
--- a/Bugzilla/Install/DB.pm
+++ b/Bugzilla/Install/DB.pm
@@ -3895,7 +3895,16 @@ sub _migrate_group_owners {
my $dbh = Bugzilla->dbh;
return if $dbh->bz_column_info('groups', 'owner_user_id');
$dbh->bz_add_column('groups', 'owner_user_id', {TYPE => 'INT3'});
- my $nobody = Bugzilla::User->check(Bugzilla->params->{'nobody_user'});
+ my $nobody = Bugzilla::User->new({ name => Bugzilla->params->{'nobody_user'}, cache => 1 });
+ unless ($nobody) {
+ $nobody = Bugzilla::User->create(
+ {
+ login_name => Bugzilla->params->{'nobody_user'},
+ realname => 'Nobody (ok to assign bugs to)',
+ cryptpassword => '*',
+ }
+ );
+ }
$dbh->do('UPDATE groups SET owner_user_id = ?', undef, $nobody->id);
}
diff --git a/extensions/ComponentWatching/Extension.pm b/extensions/ComponentWatching/Extension.pm
index 526ba1c5e..ed47e64c3 100644
--- a/extensions/ComponentWatching/Extension.pm
+++ b/extensions/ComponentWatching/Extension.pm
@@ -158,7 +158,9 @@ sub object_columns {
my $columns = $args->{columns};
return unless $class->isa('Bugzilla::Component');
- push(@$columns, 'watch_user');
+ if (Bugzilla->dbh->bz_column_info($class->DB_TABLE, 'watch_user')) {
+ push @$columns, 'watch_user';
+ }
}
sub object_update_columns {
diff --git a/extensions/ContributorEngagement/Extension.pm b/extensions/ContributorEngagement/Extension.pm
index c5ce29966..35eba24ab 100644
--- a/extensions/ContributorEngagement/Extension.pm
+++ b/extensions/ContributorEngagement/Extension.pm
@@ -71,8 +71,8 @@ sub object_columns {
my ($class, $columns) = @$args{qw(class columns)};
if ($class->isa('Bugzilla::User')) {
my $dbh = Bugzilla->dbh;
- if ($dbh->bz_column_info('profiles', 'first_patch_reviewed_id')) {
- push(@$columns, 'first_patch_reviewed_id');
+ if ($dbh->bz_column_info($class->DB_TABLE, 'first_patch_reviewed_id')) {
+ push @$columns, 'first_patch_reviewed_id';
}
}
}
diff --git a/extensions/EditComments/Extension.pm b/extensions/EditComments/Extension.pm
index ab19ab6e7..e2ace3f23 100644
--- a/extensions/EditComments/Extension.pm
+++ b/extensions/EditComments/Extension.pm
@@ -191,7 +191,9 @@ sub object_columns {
my ($self, $args) = @_;
my ($class, $columns) = @$args{qw(class columns)};
if ($class->isa('Bugzilla::Comment')) {
- push(@$columns, 'edit_count');
+ if (Bugzilla->dbh->bz_column_info($class->DB_TABLE, 'edit_count')) {
+ push @$columns, 'edit_count';
+ }
}
}
diff --git a/extensions/RestrictComments/Extension.pm b/extensions/RestrictComments/Extension.pm
index 213a1c44a..e93540d5a 100644
--- a/extensions/RestrictComments/Extension.pm
+++ b/extensions/RestrictComments/Extension.pm
@@ -68,7 +68,9 @@ sub object_columns {
my ($self, $args) = @_;
my ($class, $columns) = @$args{qw(class columns)};
if ($class->isa('Bugzilla::Bug')) {
- push(@$columns, 'restrict_comments');
+ if (Bugzilla->dbh->bz_column_info($class->DB_TABLE, 'restrict_comments')) {
+ push @$columns, 'restrict_comments';
+ }
}
}
diff --git a/extensions/Review/Extension.pm b/extensions/Review/Extension.pm
index 967679eed..576c31c7e 100644
--- a/extensions/Review/Extension.pm
+++ b/extensions/Review/Extension.pm
@@ -284,12 +284,14 @@ sub object_columns {
my ($self, $args) = @_;
my ($class, $columns) = @$args{qw(class columns)};
if ($class->isa('Bugzilla::Product')) {
- push @$columns, 'reviewer_required';
+ my $dbh = Bugzilla->dbh;
+ my @new_columns = qw(reviewer_required);
+ push @$columns, grep { $dbh->bz_column_info($class->DB_TABLE, $_) } @new_columns;
}
elsif ($class->isa('Bugzilla::User')) {
my $dbh = Bugzilla->dbh;
my @new_columns = qw(review_request_count feedback_request_count needinfo_request_count);
- push @$columns, grep { $dbh->bz_column_info(Bugzilla::User->DB_TABLE, $_ } @new_columns;
+ push @$columns, grep { $dbh->bz_column_info($class->DB_TABLE, $_) } @new_columns;
}
}
diff --git a/extensions/SecureMail/Extension.pm b/extensions/SecureMail/Extension.pm
index 02714a230..1595fe98c 100644
--- a/extensions/SecureMail/Extension.pm
+++ b/extensions/SecureMail/Extension.pm
@@ -103,7 +103,7 @@ sub object_columns {
if ($class->isa('Bugzilla::Group')) {
my $dbh = Bugzilla->dbh;
- if ($dbh->bz_column_info(Bugzilla::Group->DB_TABLE, 'secure_mail')) {
+ if ($dbh->bz_column_info($class->DB_TABLE, 'secure_mail')) {
push @$columns, 'secure_mail';
}
}
diff --git a/extensions/TagNewUsers/Extension.pm b/extensions/TagNewUsers/Extension.pm
index b94873979..1810f204f 100644
--- a/extensions/TagNewUsers/Extension.pm
+++ b/extensions/TagNewUsers/Extension.pm
@@ -123,7 +123,9 @@ sub object_columns {
my ($self, $args) = @_;
my ($class, $columns) = @$args{qw(class columns)};
if ($class->isa('Bugzilla::User')) {
- push(@$columns, qw(comment_count creation_ts first_patch_bug_id));
+ my $dbh = Bugzilla->dbh;
+ my @new_columns = qw(comment_count creation_ts first_patch_bug_id);
+ push @$columns, grep { $dbh->bz_column_info($class->DB_TABLE, $_) } @new_columns;
}
}
@@ -131,9 +133,14 @@ sub object_before_create {
my ($self, $args) = @_;
my ($class, $params) = @$args{qw(class params)};
if ($class->isa('Bugzilla::User')) {
- my ($timestamp) = Bugzilla->dbh->selectrow_array("SELECT NOW()");
- $params->{comment_count} = 0;
- $params->{creation_ts} = $timestamp;
+ my $dbh = Bugzilla->dbh;
+ my ($timestamp) = $dbh->selectrow_array("SELECT NOW()");
+ if ($dbh->bz_column_info($class->DB_TABLE, 'comment_count')) {
+ $params->{comment_count} = 0;
+ }
+ if ($dbh->bz_column_info($class->DB_TABLE, 'creation_ts')) {
+ $params->{creation_ts} = $timestamp;
+ }
} elsif ($class->isa('Bugzilla::Attachment')) {
if ($params->{ispatch} && !Bugzilla->user->first_patch_bug_id) {
Bugzilla->user->first_patch_bug_id($params->{bug}->id);
diff --git a/extensions/UserProfile/Extension.pm b/extensions/UserProfile/Extension.pm
index 079f7a948..9171b942d 100644
--- a/extensions/UserProfile/Extension.pm
+++ b/extensions/UserProfile/Extension.pm
@@ -385,7 +385,9 @@ sub object_columns {
my ($self, $args) = @_;
my ($class, $columns) = @$args{qw(class columns)};
if ($class->isa('Bugzilla::User')) {
- push(@$columns, qw(last_activity_ts last_statistics_ts));
+ my $dbh = Bugzilla->dbh;
+ my @new_columns = qw(last_activity_ts last_statistics_ts);
+ push @$columns, grep { $dbh->bz_column_info($class->DB_TABLE, $_) } @new_columns;
}
}
diff --git a/jobqueue-worker.pl b/jobqueue-worker.pl
index b26aacdba..b26aacdba 100644..100755
--- a/jobqueue-worker.pl
+++ b/jobqueue-worker.pl
diff --git a/scripts/entrypoint.pl b/scripts/entrypoint.pl
index e80fa193a..1b0dcb7f1 100755
--- a/scripts/entrypoint.pl
+++ b/scripts/entrypoint.pl
@@ -246,6 +246,10 @@ sub copy_qa_extension {
dircopy('/app/qa/extensions/QA', '/app/extensions/QA');
}
+sub cmd_wait_for_db {
+ wait_for_db();
+}
+
sub wait_for_db {
assert_database()->get;
}