Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1886359: fix PostgreSQL support on Harmony #115

Merged
merged 28 commits into from
Mar 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
208e22d
Bug 1886342: Move docker-based tests from CircleCI into GitHub Actions
justdave Mar 20, 2024
ff0669d
Bug 1886352: docker config for testing PostgreSQL
justdave Mar 20, 2024
ef9b957
Merge branch 'harmony-gha-ci' into pgfix-harmony
justdave Mar 20, 2024
5088fa7
Add Pg test to the test suite
justdave Mar 20, 2024
9443527
disable broken webservices test
justdave Mar 20, 2024
646d272
disable broken webservices test
justdave Mar 20, 2024
a32b614
Merge branch 'harmony-gha-ci' into pgfix-harmony
justdave Mar 20, 2024
3fd6ba3
more accurate way to get DBD name
justdave Mar 20, 2024
8f7fa97
Merge branch 'pg-docker-harmony' into pgfix-harmony
justdave Mar 20, 2024
49d1ba9
Bug 1888068: out-of-the-box Docker to demo Bugzilla
justdave Mar 27, 2024
960313e
urlbase needs to work
justdave Mar 27, 2024
61871b6
put some useful output on console after starting
justdave Mar 27, 2024
e8e6974
mark docker as completed in RELEASE_BLOCKERS
justdave Mar 27, 2024
d975871
rename some obvious stuff from bmo to bugzilla6
justdave Mar 28, 2024
4252cd2
hopefully fix tests
justdave Mar 28, 2024
3837c78
make test script clean up after itself
justdave Mar 28, 2024
09b0aa2
avoid mysql and pg images overwriting each other
justdave Mar 29, 2024
f4c08e9
Merge branch 'harmony' into pgfix-harmony
justdave Mar 29, 2024
1c2e805
let me run pg tests locally
justdave Mar 29, 2024
4a7271f
Merge branch 'justdave/dockerize' into pgfix-harmony
justdave Mar 29, 2024
e6fe7f4
ci config moved to github
justdave Mar 29, 2024
4bd21de
port missing check_dbd function from 5.2
justdave Mar 29, 2024
fe4b464
use generic type instead of MySQL-specific
justdave Mar 29, 2024
83147b5
clean up docker better after tests
justdave Mar 29, 2024
8ee9960
replace MySQL-specific SQL
justdave Mar 29, 2024
8a5491d
oops, missed an image rename
justdave Mar 29, 2024
6f4b4bb
mark Pg as complete in RELEASE_BLOCKERS
justdave Mar 29, 2024
de1a03b
Merge branch 'harmony' into pgfix-harmony
justdave Mar 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
# - name: Run webservice tests
# run: docker-compose -f docker-compose.test.yml run bugzilla6.test test_webservices

test_bugzilla6:
test_bugzilla6_mysql:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -37,3 +37,14 @@ jobs:
- name: Run bmo specific tests
run: docker-compose -f docker-compose.test.yml run -e CI=1 bugzilla6.test test_bmo -q -f t/bmo/*.t

test_bugzilla6_pg:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install docker-compose
run: sudo apt update && sudo apt install -y docker-compose
- name: Build the Docker images
run: docker compose -f docker-compose.test-pg.yml build
- name: Run bmo specific tests
run: docker-compose -f docker-compose.test-pg.yml run -e CI=1 bugzilla6.test test_bmo -q -f t/bmo/*.t

13 changes: 10 additions & 3 deletions Bugzilla/Attachment/Storage/Base.pm
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,16 @@ has 'attach_id' => (

sub set_class {
my ($self) = @_;
Bugzilla->dbh->do(
"REPLACE INTO attachment_storage_class (id, storage_class) VALUES (?, ?)",
undef, $self->attach_id, $self->data_type);
if ($self->data_exists()) {
Bugzilla->dbh->do(
"UPDATE attachment_storage_class SET storage_class = ? WHERE id = ?",
undef, $self->data_type, $self->attach_id);
}
else {
Bugzilla->dbh->do(
"INSERT INTO attachment_storage_class (id, storage_class) VALUES (?, ?)",
undef, $self->attach_id, $self->data_type);
}
return $self;
}

Expand Down
25 changes: 18 additions & 7 deletions Bugzilla/Attachment/Storage/Database.pm
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,24 @@ sub data_type { return 'database'; }
sub set_data {
my ($self, $data) = @_;
my $dbh = Bugzilla->dbh;
my $sth
= $dbh->prepare(
"REPLACE INTO attach_data (id, thedata) VALUES (?, ?)"
);
$sth->bind_param(1, $self->attach_id);
$sth->bind_param(2, $data, $dbh->BLOB_TYPE);
$sth->execute();
if ($self->data_exists()) {
my $sth
= $dbh->prepare(
"UPDATE attach_data SET thedata = ? WHERE id = ?"
);
$sth->bind_param(1, $data, $dbh->BLOB_TYPE);
$sth->bind_param(2, $self->attach_id);
$sth->execute();
}
else {
my $sth
= $dbh->prepare(
"INSERT INTO attach_data (id, thedata) VALUES (?, ?)"
);
$sth->bind_param(1, $self->attach_id);
$sth->bind_param(2, $data, $dbh->BLOB_TYPE);
$sth->execute();
}
return $self;
}

Expand Down
21 changes: 21 additions & 0 deletions Bugzilla/DB.pm
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,27 @@ sub bz_check_requirements {
print "\n" if $output;
}

sub _bz_check_dbd {
my ($db, $output) = @_;

my $dbd = $db->{dbd};
unless (vers_cmp($dbd, $output)) {
my $sql_server = $db->{name};
my $command = install_command($dbd);
my $root = ROOT_USER;
my $dbd_mod = $dbd->{module};
my $dbd_ver = $dbd->{version};
die <<EOT;

For $sql_server, Bugzilla requires that perl's $dbd_mod $dbd_ver or later be
installed. To install this module, run the following command (as $root):

$command

EOT
}
}

sub bz_check_server_version {
my ($self, $db, $output) = @_;

Expand Down
2 changes: 1 addition & 1 deletion Bugzilla/Install/DB.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4242,7 +4242,7 @@ sub _migrate_nicknames {
my $dbh = Bugzilla->dbh;
my $sth
= $dbh->prepare(
'SELECT userid FROM profiles WHERE realname LIKE "%:%" AND is_enabled = 1 AND NOT nickname'
"SELECT userid FROM profiles WHERE realname LIKE '%:%' AND is_enabled = 1 AND nickname = ''"
);
$sth->execute();
while (my ($user_id) = $sth->fetchrow_array) {
Expand Down
2 changes: 2 additions & 0 deletions RELEASE_BLOCKERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ they used for their local customizations instead of in the actual database
abstraction modules. This code needs to be migrated back to the database
abstraction modules so their extension can be disposed of.

**[COMPLETED]**

# Sensible, Default Logging Configuration

Bugzilla::Logging controls how the application logs. It has support for
Expand Down
10 changes: 5 additions & 5 deletions docker-compose.test-pg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ services:
environment:
- 'BMO_inbound_proxies=*'
- BMO_db_driver=pg
- BMO_db_host=bugzilla6.db
- BMO_db_host=bugzilla6.pgsql9
- BMO_db_name=bugs
- BMO_db_pass=bugs
- BMO_db_user=bugs
Expand All @@ -27,8 +27,8 @@ services:
- BMO_urlbase=AUTOMATIC
- BUGZILLA_ALLOW_INSECURE_HTTP=1
- BZ_ANSWERS_FILE=/app/conf/checksetup_answers.txt
- BZ_QA_ANSWERS_FILE=/app/.circleci/checksetup_answers.txt
- BZ_QA_CONF_FILE=/app/.circleci/selenium_test.conf
- BZ_QA_ANSWERS_FILE=/app/.github/checksetup_answers.txt
- BZ_QA_CONF_FILE=/app/.github/selenium_test.conf
- BZ_QA_CONFIG=1
- LOCALCONFIG_ENV=1
- LOG4PERL_CONFIG_FILE=log4perl-test.conf
Expand All @@ -38,11 +38,11 @@ services:
- TWD_HOST=selenium
- TWD_PORT=4444
depends_on:
- bugzilla6.db
- bugzilla6.pgsql9
- memcached
- selenium

bugzilla6.db:
bugzilla6.pgsql9:
image: postgres:9.0
tmpfs:
- /tmp
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
- /run
environment:
- 'BMO_inbound_proxies=*'
- BMO_db_host=bugzilla6.db
- BMO_db_host=bugzilla6.mysql8
- BMO_db_name=bugs
- BMO_db_pass=bugs
- BMO_db_user=bugs
Expand All @@ -38,11 +38,11 @@ services:
- TWD_HOST=selenium
- TWD_PORT=4444
depends_on:
- bugzilla6.db
- bugzilla6.mysql8
- memcached
- selenium

bugzilla6.db:
bugzilla6.mysql8:
image: mysql:8
tmpfs:
- /tmp
Expand Down
12 changes: 6 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ services:
- /run
environment: &bz_env
- 'BMO_inbound_proxies=*'
- BMO_db_host=bugzilla6.db
- BMO_db_host=bugzilla6.mysql8
- BMO_db_name=bugs
- BMO_db_pass=bugs
- BMO_db_user=bugs
Expand All @@ -36,7 +36,7 @@ services:
- MOJO_LISTEN=http://*:8000
- PORT=8000
depends_on:
- bugzilla6.db
- bugzilla6.mysql8
- memcached
# - tinyproxy
ports:
Expand All @@ -53,7 +53,7 @@ services:
# environment: *bz_env
# restart: always
# depends_on:
# - bugzilla6.db
# - bugzilla6.mysql8
# - memcached

# bugzilla6.feed:
Expand All @@ -72,7 +72,7 @@ services:
# environment: *bz_env
# restart: always
# depends_on:
# - bugzilla6.db
# - bugzilla6.mysql8
# - memcached

# bugzilla6.pushd:
Expand All @@ -91,10 +91,10 @@ services:
# environment: *bz_env
# restart: always
# depends_on:
# - bugzilla6.db
# - bugzilla6.mysql8
# - memcached

bugzilla6.db:
bugzilla6.mysql8:
build:
context: .
dockerfile: Dockerfile.mysql8
Expand Down
10 changes: 7 additions & 3 deletions docker/run-tests-in-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,14 @@ export DOCKER_CLI_HINTS=false
export CI=""
export CIRCLE_SHA1=""
export CIRCLE_BUILD_URL=""
$DOCKER compose -f docker-compose.test.yml build
DOCKER_COMPOSE_FILE=docker-compose.test.yml
if [ "$1" == "pg" ]; then
DOCKER_COMPOSE_FILE=docker-compose.test-pg.yml
fi
$DOCKER compose -f $DOCKER_COMPOSE_FILE build
if [ $? == 0 ]; then
$DOCKER compose -f docker-compose.test.yml run --rm --name bugzilla6.test bugzilla6.test test_bmo -q -f t/bmo/*.t
$DOCKER compose -f docker-compose.test.yml stop
$DOCKER compose -f $DOCKER_COMPOSE_FILE run --rm --name bugzilla6.test bugzilla6.test test_bmo -q -f t/bmo/*.t
$DOCKER compose -f $DOCKER_COMPOSE_FILE down
else
echo "docker compose build failed."
fi
2 changes: 1 addition & 1 deletion extensions/FlagTypeComment/Extension.pm
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ sub db_schema_abstract_schema {
$args->{'schema'}->{'flagtype_comments'} = {
FIELDS => [
type_id => {
TYPE => 'SMALLINT(6)',
TYPE => 'INT2',
NOTNULL => 1,
REFERENCES => {TABLE => 'flagtypes', COLUMN => 'id', DELETE => 'CASCADE'}
},
Expand Down
11 changes: 9 additions & 2 deletions extensions/PhabBugz/lib/Feed.pm
Original file line number Diff line number Diff line change
Expand Up @@ -740,8 +740,15 @@ sub save_last_id {
# Store the largest last key so we can start from there in the next session
my $type_full = $type . "_last_id";
TRACE("UPDATING " . uc($type_full) . ": $last_id");
Bugzilla->dbh->do("REPLACE INTO phabbugz (name, value) VALUES (?, ?)",
undef, $type_full, $last_id);
if (Bugzilla->dbh->selectrow_array("SELECT 1 FROM phabbugz WHERE name = ?",
undef, $type_full)) {
Bugzilla->dbh->do("UPDATE phabbugz SET value = ? WHERE name = ?",
undef, $last_id, $type_full);
}
else {
Bugzilla->dbh->do("INSERT INTO phabbugz (name, value) VALUES (?, ?)",
undef, $type_full, $last_id);
}
}

sub get_group_members {
Expand Down
30 changes: 24 additions & 6 deletions scripts/generate_conduit_data.pl
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,19 @@ BEGIN
if ($oauth_id && $oauth_secret) {
print "creating phabricator oauth2 client...\n";

$dbh->do(
'REPLACE INTO oauth2_client (client_id, description, secret) VALUES (?, \'Phabricator\', ?)',
undef, $oauth_id, $oauth_secret
);
if ($dbh->selectrow_array("SELECT 1 FROM oauth2_client WHERE client_id = ?",
undef, $oauth_id)) {
$dbh->do(
"UPDATE oauth2_client SET description = 'Phabricator', secret = ? WHERE client_id = ?",
undef, $oauth_secret, $oauth_id
);
}
else {
$dbh->do(
'INSERT INTO oauth2_client (client_id, description, secret) VALUES (?, \'Phabricator\', ?)',
undef, $oauth_id, $oauth_secret
);
}

my $client_data
= $dbh->selectrow_hashref('SELECT * FROM oauth2_client WHERE client_id = ?',
Expand All @@ -199,8 +208,17 @@ BEGIN
my $scope_id = $dbh->selectrow_array(
'SELECT id FROM oauth2_scope WHERE name = \'user:read\'', undef);

$dbh->do('REPLACE INTO oauth2_client_scope (client_id, scope_id) VALUES (?, ?)',
undef, $client_data->{id}, $scope_id);
if ($dbh->selectrow_array("SELECT 1 FROM oauth2_client_scope WHERE client_id = ?",
undef, $client_data->{id})) {
$dbh->do("UPDATE oauth2_client_scope SET scope_id = ? WHERE client_id = ?",
undef, $scope_id, $client_data->{id}
);
}
else {
$dbh->do('INSERT INTO oauth2_client_scope (client_id, scope_id) VALUES (?, ?)',
undef, $client_data->{id}, $scope_id
);
}
}

print "installation and configuration complete!\n";
Expand Down
Loading