]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1886352: docker config for testing PostgreSQL (#114)
authorDave Miller <justdave@bugzilla.org>
Fri, 22 Mar 2024 02:00:47 +0000 (22:00 -0400)
committerGitHub <noreply@github.com>
Fri, 22 Mar 2024 02:00:47 +0000 (22:00 -0400)
Bugzilla/DaemonControl.pm
Dockerfile
Dockerfile.bmo-slim
Dockerfile.cpanfile
Makefile.PL
docker-compose.test-pg.yml [new file with mode: 0644]

index 7cf79ffb16f713e025bb52d26b90f750d4bc449c..40a1de2738b0ee0beaeeeb1105e282dc6600dd92 100644 (file)
@@ -11,7 +11,7 @@ use strict;
 use warnings;
 
 use Bugzilla::Logging;
-use Bugzilla::Constants qw(bz_locations);
+use Bugzilla::Constants qw(bz_locations DB_MODULE);
 use Cwd qw(realpath);
 use English qw(-no_match_vars $PROGRAM_NAME);
 use File::Spec::Functions qw(catfile catdir);
@@ -226,24 +226,27 @@ sub assert_database {
   my $loop = IO::Async::Loop->new;
   my $lc   = Bugzilla::Install::Localconfig::read_localconfig();
 
-  for my $var (qw(db_name db_host db_user db_pass)) {
+  for my $var (qw(db_driver db_name db_host db_user db_pass)) {
     return $loop->new_future->die("$var is not set!") unless $lc->{$var};
   }
+  my ($db_driver) = (DB_MODULE->{$lc->{db_driver}}->{dbd}->{module} =~ m/::([^:]+)$/);
 
-  my $dsn    = "dbi:mysql:database=$lc->{db_name};host=$lc->{db_host}";
+  my $dsn    = "dbi:$db_driver:database=$lc->{db_name};host=$lc->{db_host}";
   my $repeat = try_repeat_until_success {
     $loop->delay_future(after => 0.25)->then(sub {
       my $attrs = {RaiseError => 1, PrintError => 1};
-      my ($ssl_ca_file, $ssl_ca_path, $ssl_cert, $ssl_key, $ssl_pubkey) =
-        @$lc{qw(db_mysql_ssl_ca_file db_mysql_ssl_ca_path
-                db_mysql_ssl_client_cert db_mysql_ssl_client_key db_mysql_ssl_get_pubkey)};
-      if ($ssl_ca_file || $ssl_ca_path || $ssl_cert || $ssl_key || $ssl_pubkey) {
-        $attrs->{'mysql_ssl'}               = 1;
-        $attrs->{'mysql_ssl_ca_file'}       = $ssl_ca_file if $ssl_ca_file;
-        $attrs->{'mysql_ssl_ca_path'}       = $ssl_ca_path if $ssl_ca_path;
-        $attrs->{'mysql_ssl_client_cert'}   = $ssl_cert    if $ssl_cert;
-        $attrs->{'mysql_ssl_client_key'}    = $ssl_key     if $ssl_key;
-        $attrs->{'mysql_get_server_pubkey'} = $ssl_pubkey  if $ssl_pubkey;
+      if ($lc->{db_driver} eq 'mysql') {
+        my ($ssl_ca_file, $ssl_ca_path, $ssl_cert, $ssl_key, $ssl_pubkey) =
+          @$lc{qw(db_mysql_ssl_ca_file db_mysql_ssl_ca_path
+                  db_mysql_ssl_client_cert db_mysql_ssl_client_key db_mysql_ssl_get_pubkey)};
+        if ($ssl_ca_file || $ssl_ca_path || $ssl_cert || $ssl_key || $ssl_pubkey) {
+          $attrs->{'mysql_ssl'}               = 1;
+          $attrs->{'mysql_ssl_ca_file'}       = $ssl_ca_file if $ssl_ca_file;
+          $attrs->{'mysql_ssl_ca_path'}       = $ssl_ca_path if $ssl_ca_path;
+          $attrs->{'mysql_ssl_client_cert'}   = $ssl_cert    if $ssl_cert;
+          $attrs->{'mysql_ssl_client_key'}    = $ssl_key     if $ssl_key;
+          $attrs->{'mysql_get_server_pubkey'} = $ssl_pubkey  if $ssl_pubkey;
+        }
       }
       my $dbh;
       eval {
index 9a39eacc714ec9f0198b56ec428b112a825bfbf6..202ac9b6284a5d440d2684454312ce1cb366286b 100644 (file)
@@ -1,4 +1,4 @@
-FROM bugzilla/bugzilla-perl-slim:20240316.1
+FROM bugzilla/bugzilla-perl-slim:20240320.1
 
 ENV DEBIAN_FRONTEND noninteractive
 
index b62ad7d1638be4fa85f37539ce3b95a4e9be3270..980b014e7f7be4eaa09cb92fb273c8d92344b56e 100644 (file)
@@ -23,7 +23,7 @@ RUN gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mysql-
  && gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mysql-8.0.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys B7B3B788A8D3785C \
  && echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/mysql-8.0.gpg] http://repo.mysql.com/apt/debian/ bookworm mysql-8.0' > /etc/apt/sources.list.d/mysql-8.0.list
 RUN apt-get update \
- && apt-get install -y libmysqlclient-dev
+ && apt-get install -y libmysqlclient-dev libpq-dev
 
 RUN cpanm --notest --quiet App::cpm Module::CPANfile Carton::Snapshot
 
@@ -64,6 +64,7 @@ RUN apt-get update \
        graphviz \
        libcap2-bin \
        libmysqlclient21 \
+       postgresql-client \
        rsync \
        $(cat /app/PACKAGES) \
     && rm -rf /var/cache/apt/* /var/lib/apt/lists/*
index 66a93aab0a0591fed0ec44835fd38b789c3d5a6d..71d4ca1ceb2782d65798b962b26ef26af7ab0aa7 100644 (file)
@@ -15,7 +15,7 @@ RUN gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mysql-
  && gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mysql-8.0.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys B7B3B788A8D3785C \
  && echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/mysql-8.0.gpg] http://repo.mysql.com/apt/debian/ bookworm mysql-8.0' > /etc/apt/sources.list.d/mysql-8.0.list
 RUN apt-get update \
- && apt-get install -y libmysqlclient-dev
+ && apt-get install -y libmysqlclient-dev libpq-dev
 
 RUN cpanm --notest --quiet App::cpm Module::CPANfile Carton::Snapshot
 
index 6a0ca232084702ddd1cd679206209a21fb45afa5..ef465954e0c70224e84da008b551413dfe154d4d 100755 (executable)
@@ -386,7 +386,7 @@ WriteMakefile(
 
 sub MY::postamble {
   return <<"MAKE";
-GEN_CPANFILE_ARGS = -D better_xff -D mysql -D jsonrpc -D xmlrpc -D documentation
+GEN_CPANFILE_ARGS = -D better_xff -D mysql -D jsonrpc -D xmlrpc -D documentation -D pg
 cpanfile: MYMETA.json
 \t\$(PERLRUN) gen-cpanfile.pl \$(GEN_CPANFILE_ARGS)
 
diff --git a/docker-compose.test-pg.yml b/docker-compose.test-pg.yml
new file mode 100644 (file)
index 0000000..cfa0576
--- /dev/null
@@ -0,0 +1,69 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+version: '3.6'
+
+services:
+  bmo.test:
+    build: &bmo_build
+      context: .
+      dockerfile: Dockerfile
+    command: dev_httpd
+    tmpfs:
+      - /tmp
+      - /run
+    environment:
+      - 'BMO_inbound_proxies=*'
+      - BMO_db_driver=pg
+      - BMO_db_host=bmo.db
+      - BMO_db_name=bugs
+      - BMO_db_pass=bugs
+      - BMO_db_user=bugs
+      - BMO_memcached_namespace=bugzilla
+      - BMO_memcached_servers=memcached:11211
+      - BMO_ses_username=ses@mozilla.bugs
+      - BMO_ses_password=password123456789!
+      - 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_CONFIG=1
+      - CI=${CI}
+      - CIRCLE_SHA1=${CIRCLE_SHA1}
+      - CIRCLE_BUILD_URL=${CIRCLE_BUILD_URL}
+      - LOCALCONFIG_ENV=1
+      - LOG4PERL_CONFIG_FILE=log4perl-test.conf
+      - LOGGING_PORT=5880
+      - PORT=8000
+      - TWD_BROWSER=firefox
+      - TWD_HOST=selenium
+      - TWD_PORT=4444
+    depends_on:
+      - bmo.db
+      - memcached
+      - selenium
+
+  bmo.db:
+    image: postgres:9.0
+    tmpfs:
+      - /tmp
+    logging:
+      driver: "none"
+    environment:
+      - POSTGRES_DB=bugs
+      - POSTGRES_USER=bugs
+      - POSTGRES_PASSWORD=bugs
+
+  memcached:
+    image: memcached:latest
+
+  selenium:
+    image: selenium/standalone-firefox:3.141.59
+    shm_size: '512m'
+    ports:
+      - "5900:5900"
+
+volumes:
+  bmo-pg-db: